亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? prind.c

?? 機器學習作者tom mitchell的書上代碼
?? C
字號:
/* Weight-setting and scoring implementation for PrInd classification   (Fuhr's Probabilistic Indexing) *//* Copyright (C) 1997, 1998, 1999 Andrew McCallum   Written by:  Andrew Kachites McCallum <mccallum@cs.cmu.edu>   This file is part of the Bag-Of-Words Library, `libbow'.   This library is free software; you can redistribute it and/or   modify it under the terms of the GNU Library General Public License   as published by the Free Software Foundation, version 2.      This library is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   Library General Public License for more details.   You should have received a copy of the GNU Library General Public   License along with this library; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA */#include <bow/libbow.h>#include <math.h>#include <argp.h>static struct argp_option prind_options[] ={  {0,0,0,0,   "Probabilistic Indexing options, --method=prind:", 80},  {"prind-non-uniform-priors", 'U', 0, 0,   "Make PrInd use non-uniform class priors."},  {"prind-no-foilgain-weight-scaling", 'G', 0, 0,   "Don't have PrInd scale its weights by Quinlan's FoilGain."},  {"prind-no-score-normalization", 'N', 0, 0,   "Don't have PrInd normalize its class scores to sum to one."},  {0,0}};error_tprind_parse_opt (int key, char *arg, struct argp_state *state){  switch (key)    {    case 'U':      /* Don't have PrTFIDF use uniform class prior probabilities */      ((bow_params_prind*)(bow_method_prind.params))->uniform_priors	= bow_no;      break;    case 'G':      /* Don't scale weights (by foilgain or anything else) */      {	int i;	rainbow_method *m;	for (i = 0; i < bow_methods->array->length; i++)	  {	    m = bow_sarray_entry_at_index (bow_methods, i);	    if (m)	      m->scale_weights = NULL;	  }	break;      }    case 'N':      /* Don't normalize the scores from PrInd. */      ((bow_params_prind*)(bow_method_prind.params))->normalize_scores	= bow_no;      break;    default:      return ARGP_ERR_UNKNOWN;    }  return 0;}static const struct argp prind_argp ={  prind_options,  prind_parse_opt};static struct argp_child prind_argp_child ={  &prind_argp,		/* This child's argp structure */  0,			/* flags for child */  0,			/* optional header in help message */  0			/* arbitrary group number for ordering */};/* Function to assign `PrInd'-style weights to each element of   each document vector. */voidbow_prind_set_weights (bow_barrel *barrel){  int ci;  bow_cdoc *cdoc;  int wi;			/* a "word index" into WI2DVF */  int max_wi;			/* the highest "word index" in WI2DVF. */  bow_dv *dv;			/* the "document vector" at index WI */  int dvi;			/* an index into the DV */  int total_term_count;  /* We assume that we have already called BOW_BARREL_NEW_VPC() on     BARREL, so BARREL already has one-document-per-class. */      assert (!strcmp (barrel->method->name, "prind"));  max_wi = MIN (barrel->wi2dvf->size, bow_num_words());  /* The CDOC->PRIOR should have been set in bow_barrel_new_vpc();     verify it. */  for (ci = 0; ci < barrel->cdocs->length; ci++)    {      cdoc = bow_array_entry_at_index (barrel->cdocs, ci);      assert (cdoc->prior >= 0);    }  /* Get the total number of terms in each class; temporarily store     this in cdoc->word_count.  Also, get the total count for each     term across all classes, and store it in the IDF of the     respective word vector.  (WARNING: this is an odd use of the IDF     variable.)  Also, get the total number of terms, across all     terms, all classes, put it in TOTAL_TERM_COUNT. */  for (ci = 0; ci < barrel->cdocs->length; ci++)    {      cdoc = bow_array_entry_at_index (barrel->cdocs, ci);      cdoc->word_count = 0;    }  total_term_count = 0;  for (wi = 0; wi < max_wi; wi++)     {      dv = bow_wi2dvf_dv (barrel->wi2dvf, wi);      if (dv == NULL)	continue;      dv->idf = 0;      for (dvi = 0; dvi < dv->length; dvi++) 	{	  cdoc = bow_array_entry_at_index (barrel->cdocs, 					   dv->entry[dvi].di);	  if (cdoc->type != bow_doc_train)	    continue;	  /* Summing total number of words in each class */	  cdoc->word_count += dv->entry[dvi].count;	  /* Summing total word occurrences across all classes. */	  dv->idf += dv->entry[dvi].count;	  assert (dv->idf > 0);	  /* Summing total number of words, all words, all classes. */	  total_term_count += dv->entry[dvi].count;	}    }  /* Set the weights in the BARREL's WI2DVF so that they are     equal to P(w|C)/P(w), the probability of a class given a word,     divided by the probability of a word across all classes.   This     combination is equal to P(C|w), but without the prior P(C). */  for (wi = 0; wi < max_wi; wi++)     {      dv = bow_wi2dvf_dv (barrel->wi2dvf, wi);      if (dv == NULL)	continue;      /* Now loop through all the elements, setting their weights */      for (dvi = 0; dvi < dv->length; dvi++) 	{	  float pr_x_c;	  float pr_x;	  cdoc = bow_array_entry_at_index (barrel->cdocs, 					   dv->entry[dvi].di);	  /* Skip this document/class if it is not part of the model. */	  if (cdoc->type != bow_doc_train)	    {	      dv->entry[dvi].weight = 0;	      continue;	    }	  /* Here CDOC->WORD_COUNT is the total number of words in the class.	     Here DV->IDF is total num of occurrences of WI across classes. */	  /* The probability of a word given a class */	  pr_x_c = 	    (float)(dv->entry[dvi].count) / cdoc->word_count;	  /* The probability of a word across all classes. */	  pr_x = dv->idf / total_term_count;	  dv->entry[dvi].weight = pr_x_c / pr_x;	  assert (dv->entry[dvi].weight >= 0);	}      /* Don't reset the DV->IDF; we'll use its current value later */    }  /* NOTE: These weights are missing the prior probabilities P(C), and     are not normalized to sum to one. */}intbow_prind_score (bow_barrel *barrel, bow_wv *query_wv, 		 bow_score *bscores, int bscores_len, int loo_class){  double *scores;		/* will become prob(class), indexed over CI */  int ci;			/* a "class index" (document index) */  int wvi;			/* an index into the entries of QUERY_WV. */  int dvi;			/* an index into a "document vector" */  float pr_w_c;			/* P(w|C), prob a word is in a class */  float pr_c;			/* P(C), prior prob of a class */  int num_scores;		/* number of entries placed in SCORES */#if 0  if (loo_class >= 0)    bow_error ("PrInd hasn't yet implemented Leave-One-Out scoring.");#endif  /* Allocate space to store scores for *all* classes (documents) */  scores = alloca (barrel->cdocs->length * sizeof (double));  /* Initialize the SCORES to zero. */  for (ci = 0; ci < barrel->cdocs->length; ci++)    scores[ci] = 0;  /* Loop over each word in the word vector QUERY_WV, putting its     contribution into SCORES. */  for (wvi = 0; wvi < query_wv->num_entries; wvi++)    {      int wi;			/* the word index for the word at WVI */      bow_dv *dv;		/* the "document vector" for the word WI */      /* Get information about this word. */      wi = query_wv->entry[wvi].wi;      dv = bow_wi2dvf_dv (barrel->wi2dvf, wi);      /* If the model doesn't know about this word, skip it. */      if (!dv)	continue;      if (bow_print_word_scores)	printf ("%-30s (queryweight=%.8f)\n",		bow_int2word (wi), 		query_wv->entry[wvi].weight * query_wv->normalizer);      /* Loop over all classes, putting this word's (WI's)	 contribution into SCORES. */      for (ci = 0, dvi = 0; ci < barrel->cdocs->length; ci++)	{	  bow_cdoc *cdoc;	  double score_increment;	  /* Assign PR_W_C to P(w|C)/P(w), either using a DV entry,	     or, if there is no DV entry for this class, PR_W_C would	     be zero; adding zero to the score wouldn't change it, so	     we skip this class.  (NOTE: We could think about doing	     some smoothing here, but PrInd doesn't require it, since	     zero probability words do not cause the math to blow	     up. */	  while (dvi < dv->length && dv->entry[dvi].di < ci)	    dvi++;	  if (!(dv && dvi < dv->length && dv->entry[dvi].di == ci))	    continue;	  cdoc = bow_array_entry_at_index (barrel->cdocs, ci);	  /* Skip this document/class if it is not part of the model. */	  if (cdoc->type != bow_doc_train)	    {	      scores[ci] = 0;	      continue;	    }	  if (((bow_params_prind*)(barrel->method->params))->uniform_priors)	    pr_c = 1.0f;	  else	    pr_c = cdoc->prior;	  pr_w_c = dv->entry[dvi].weight * cdoc->normalizer;	  /* Here DV->IDF is an unnormalized P(wi), probability of word WI.	     Here CDOC->PRIOR is P(C), prior probability of class. */	  score_increment = 	    ((pr_w_c * pr_c) *	     (query_wv->entry[wvi].weight * query_wv->normalizer));	  /* Check for NaN */	  assert (score_increment == score_increment);	  scores[ci] += score_increment;	  if (bow_print_word_scores)	    printf ("%8.4f %16.10f %-40s  %10.9f\n", 		    pr_w_c,		    score_increment,		    (cdoc->filename 		     ? (strrchr (cdoc->filename, '/') ? : cdoc->filename)		     : "(NULL)"),		    scores[ci]);	}    }  /* Now SCORES[] contains a (unnormalized) probability for each class. */  if (((bow_params_prind*)(barrel->method->params))->normalize_scores)    {      /* Normalize the SCORES so they all sum to one. */      {	double scores_sum = 0;	for (ci = 0; ci < barrel->cdocs->length; ci++)	  scores_sum += scores[ci];	if (scores_sum)	  {	    for (ci = 0; ci < barrel->cdocs->length; ci++)	      {		scores[ci] /= scores_sum;		/* Check for NaN */		assert (scores[ci] == scores[ci]);	      }	  }	else	  {	    for (ci = 0; ci < barrel->cdocs->length; ci++)	      scores[ci] = 1.0 / barrel->cdocs->length;	  }      }    }  /* Return the SCORES by putting them (and the `class indices') into     SCORES in sorted order. */  {    num_scores = 0;    for (ci = 0; ci < barrel->cdocs->length; ci++)      {	if (num_scores < bscores_len	    || bscores[num_scores-1].weight < scores[ci])	  {	    /* We are going to put this score and CI into SCORES	       because either: (1) there is empty space in SCORES,	       or (2) SCORES[CI] is larger than the smallest score	       there currently. */	    int dsi;		/* an index into SCORES */	    if (num_scores < bscores_len)	      num_scores++;	    dsi = num_scores - 1;	    /* Shift down all the entries that are smaller than SCORES[CI] */	    for (; dsi > 0 && bscores[dsi-1].weight < scores[ci]; dsi--)	      bscores[dsi] = bscores[dsi-1];	    /* Insert the new score */	    bscores[dsi].weight = scores[ci];	    /* Check for NaN. */	    assert (bscores[dsi].weight == bscores[dsi].weight);	    bscores[dsi].di = ci;	  }      }  }  return num_scores;}bow_params_prind bow_prind_params ={  bow_yes,			/* Use uniform priors */  bow_yes			/* Normalize the scores */};rainbow_method bow_method_prind ={  "prind",  bow_prind_set_weights,  bow_barrel_scale_weights_by_foilgain,  bow_barrel_normalize_weights_by_summing,  bow_barrel_new_vpc_merge_then_weight,  bow_barrel_set_vpc_priors_by_counting,  bow_prind_score,  bow_wv_set_weights_to_count,  bow_wv_normalize_weights_by_summing,  bow_barrel_free,  &bow_prind_params};void _register_method_prind () __attribute__ ((constructor));void _register_method_prind (){  static int done = 0;  if (done)     return;  bow_method_register_with_name ((bow_method*)&bow_method_prind,				 "prind", 				 sizeof (rainbow_method),				 NULL);  bow_argp_add_child (&prind_argp_child);  done = 1;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合久久九月婷婷色综合| 免费一级欧美片在线观看| 国产精品一区二区你懂的| 精品欧美一区二区在线观看| 久久99国产精品久久99| 欧美精品一区二区在线播放| 国产精品综合在线视频| 国产日韩av一区| 波多野结衣在线一区| 国产精品综合久久| 日本一区二区成人| 日本韩国视频一区二区| 亚洲成a人v欧美综合天堂下载| 国产亚洲欧美一级| 成人国产精品免费网站| 亚洲综合一二三区| 4438x亚洲最大成人网| 国产一区二区三区黄视频| 欧美国产激情一区二区三区蜜月| 91啪九色porn原创视频在线观看| 亚洲在线视频网站| 欧美一区二区精品在线| 丰满少妇久久久久久久| 一区二区成人在线视频| 日韩欧美色电影| 成人性色生活片免费看爆迷你毛片| 最新日韩在线视频| 日韩欧美色电影| 91亚洲永久精品| 免费在线观看精品| 亚洲婷婷综合色高清在线| 91.成人天堂一区| 成人午夜看片网址| 日本欧美一区二区三区| 欧美激情在线一区二区三区| 欧美午夜一区二区三区| 国产一区二区三区四| 一区二区三区中文字幕在线观看| 欧美成人乱码一区二区三区| 99久久伊人精品| 理论片日本一区| 一区二区三区中文字幕电影 | 亚洲欧洲性图库| 91精品国产综合久久精品| 成人黄色综合网站| 青青草原综合久久大伊人精品| 亚洲欧洲色图综合| 2023国产精品自拍| 在线播放视频一区| 91国产免费看| 成人免费毛片片v| 经典三级一区二区| 丝袜诱惑亚洲看片| 一区二区三区四区在线免费观看 | 国产网站一区二区| 51精品秘密在线观看| 色综合久久久网| 成人免费视频一区| 国产成人免费在线| 久久精品国产免费| 视频在线观看一区二区三区| 自拍偷拍亚洲欧美日韩| 欧美激情综合五月色丁香| 久久综合九色综合97婷婷女人| 91精品国产综合久久久蜜臀粉嫩| 色综合久久综合网97色综合| 成人免费视频一区| 成人午夜免费电影| 成人午夜电影久久影院| 国产精品综合一区二区三区| 精品一区免费av| 九九视频精品免费| 九色综合狠狠综合久久| 狠狠色丁香婷婷综合| 久久精品国产成人一区二区三区| 欧美a级理论片| 三级久久三级久久久| 天天综合网天天综合色| 五月综合激情网| 日韩成人精品在线观看| 婷婷亚洲久悠悠色悠在线播放| 亚洲成a人v欧美综合天堂下载| 亚洲午夜久久久久久久久久久| 夜夜夜精品看看| 午夜天堂影视香蕉久久| 日韩激情视频在线观看| 美女视频黄频大全不卡视频在线播放| 日韩激情av在线| 美国十次了思思久久精品导航| 久久不见久久见中文字幕免费| 国产在线国偷精品免费看| 国产毛片精品一区| 国产成人精品影视| 91亚洲精品久久久蜜桃| 91黄色免费看| 欧美一区二区视频免费观看| 日韩精品最新网址| 日本一区二区三区久久久久久久久不| 国产精品三级在线观看| 亚洲老司机在线| 日韩中文字幕麻豆| 国产一区二区不卡| 99久久精品费精品国产一区二区| 在线视频欧美区| 日韩免费视频线观看| 中文字幕av一区二区三区高 | xnxx国产精品| 中文字幕精品综合| 亚洲午夜电影网| 久久69国产一区二区蜜臀| 99精品欧美一区| 欧美一区二区三区在线看| 国产色91在线| 亚洲成年人网站在线观看| 久久狠狠亚洲综合| 99麻豆久久久国产精品免费| 欧美精品在线一区二区| 国产视频一区不卡| 婷婷久久综合九色国产成人| 国产剧情av麻豆香蕉精品| 在线看一区二区| 久久久久久电影| 亚洲一区二区三区三| 国产精品自拍网站| 欧美日韩中文精品| 国产精品婷婷午夜在线观看| 午夜欧美一区二区三区在线播放| 国产九色sp调教91| 欧美精品精品一区| 一区在线播放视频| 国产毛片精品国产一区二区三区| 欧美日韩一区高清| 欧美国产日韩在线观看| 免费亚洲电影在线| 欧洲色大大久久| 国产精品欧美一区喷水| 美女性感视频久久| 欧美日韩综合在线免费观看| 国产精品国产自产拍在线| 麻豆精品一区二区| 欧美日韩日本视频| 国产精品电影一区二区| 国产一区亚洲一区| 日韩女同互慰一区二区| 五月激情丁香一区二区三区| 99久久国产综合精品麻豆| 国产区在线观看成人精品| 免费在线观看一区| 欧美精品粉嫩高潮一区二区| 综合欧美亚洲日本| 成人免费视频app| 国产日韩av一区二区| 久久不见久久见中文字幕免费| 欧美日韩国产免费一区二区| 亚洲精品国产第一综合99久久| 国产成人在线视频网站| 日韩精品一区二区三区三区免费| 亚洲福利视频一区二区| 91黄色激情网站| 亚洲欧洲99久久| 91原创在线视频| 国产精品第一页第二页第三页| 国产成人免费视频一区| 国产网红主播福利一区二区| 国产在线一区二区| 337p粉嫩大胆噜噜噜噜噜91av| 久久国产精品99久久人人澡| 欧美精品亚洲二区| 日韩成人av影视| 日韩欧美国产一区在线观看| 青草国产精品久久久久久| 日韩视频一区二区三区在线播放| 午夜精品久久久久久久蜜桃app | 欧美日韩高清影院| 午夜成人免费视频| 91麻豆精品国产无毒不卡在线观看| 亚洲成人免费av| 亚洲视频一区二区在线观看| youjizz久久| 亚洲黄色性网站| 欧美男女性生活在线直播观看| 日日夜夜免费精品视频| 日韩欧美国产一二三区| 国产在线精品免费| 一区精品在线播放| 欧美精品自拍偷拍| 国产一区二区三区免费看 | 亚洲第一av色| 日韩欧美亚洲国产另类| 国产一区二区三区精品欧美日韩一区二区三区 | 欧美日本在线一区| 蜜桃av噜噜一区| 国产三级三级三级精品8ⅰ区| 成人教育av在线| 亚洲一区在线免费观看| 欧美放荡的少妇| 国产精品99久久久| 又紧又大又爽精品一区二区| 欧美精品久久99久久在免费线 | 欧美日韩国产经典色站一区二区三区 |