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

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

?? icsiboost.c

?? Boosting is a meta-learning approach that aims at combining an ensemble of weak classifiers to form
?? C
?? 第 1 頁 / 共 5 頁
字號:
/* Copyright (C) (2007) (Benoit Favre) <favre@icsi.berkeley.edu>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#if HAVE_CONFIG_H# include <config.h>#endif#define USE_THREADS//#define USE_FLOATS#include "utils/common.h"#include "utils/debug.h"#include "utils/vector.h"#include "utils/string.h"#include "utils/hashtable.h"#include "utils/mapped.h"#include "utils/array.h"#ifdef USE_THREADS#include "utils/threads.h"#include <pthread.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#endif#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <time.h>#ifdef USE_FLOATS#define double float#endif// declare vectors that are interesting for usvector_implement_functions_for_type(float, 0.0);vector_implement_functions_for_type(int32_t, 0);/*int num_EXP=0;double EXP(double number){	num_EXP++;	if(isnan(number))die("exp(): had a NAN");	return exp(number);}int num_SQRT=0;double SQRT(double number){	num_SQRT++;	if(isnan(number))die("sqrt(): had a NAN");	return sqrt(number);}int num_LOG=0;double LOG(double number){	num_LOG++;	if(isnan(number))die("log(): had a NAN");	return log(number);}*/#define EXP(a) exp(a)#define LOG(a) log(a)inline double SQRT(double number){	if(number<0)return 0;	return sqrt(number);}/*WARNING:- garbage collection is not working yet => do not activate itTODO:- free memory and remove leaks (and go through that again and again)- frequency cutoff- sampleing and ranking- more COMMENTS !!!NOTES ON THE ORIGINAL:- text features are treated as bag-of-ngrams- shyp file: boostexter saves non-text discrete features as their id- shyp file: when combining the same classifiers, boostexter adds the alphas and averages the C_js*/#define FEATURE_TYPE_IGNORE 0#define FEATURE_TYPE_CONTINUOUS 1#define FEATURE_TYPE_TEXT 2#define FEATURE_TYPE_SCORED_TEXT 3#define FEATURE_TYPE_SET 4typedef struct template { // a column definition	int column;	string_t* name;	int type;	hashtable_t* dictionary;       // dictionary for token based template	vector_t* tokens;              // the actual tokens (if the feature is text; contains tokeninfo)	vector_t* values;              // continuous values (if the feature is continuous)	int32_t* ordered;             // ordered example ids according to value for continuous columns	vector_t* classifiers;         // classifiers related to that template (in classification mode only)} template_t;typedef struct example { // an instance	//vector_t* features;            // vector of (int or float according to templates)	int class;	double* weight;                // example weight by class	double* score;                 // example score by class, updated iteratively} example_t;#define CLASSIFIER_TYPE_THRESHOLD 1#define CLASSIFIER_TYPE_TEXT 2typedef struct weakclassifier { // a weak learner	template_t* template;          // the corresponding template	int type;                      // type in CLASSIFIER_TYPE_TEXT or CLASSIFIER_TYPE_THRESHOLD	int32_t token;                     // token for TEXT classifier	int column;                    // redundant with template	double threshold;              // threshold for THRESHOLD classifier	double alpha;                  // alpha from the paper	double objective;              // Z() value from minimization	double *c0;                    // weight by class, unknown	double *c1;                    // weight by class, token absent or below threshold	double *c2;                    // weight by class, token present or above threshold} weakclassifier_t;typedef struct tokeninfo { // store info about a word (or token)	int32_t id;	char* key;	size_t count;	vector_t* examples;} tokeninfo_t;double smoothing=0.5;              // -E <number> in boostexterint verbose=0;int output_weights=0;int output_scores=0;//int *random_sequence;#define y_l(x,y) (x->class==y?1.0:-1.0)    // y_l() from the paper#define b(x,y) (x->class==y?1:0)           // b() from the paper (binary class match)weakclassifier_t* train_text_stump(double min_objective, template_t* template, vector_t* examples, double** sum_of_weights, int num_classes){	int i,l;	int column=template->column;	size_t num_tokens=template->tokens->length;	int32_t t;	double* weight[2][num_classes]; // weight[b][label][token] (=> D() in the paper), only for token presence (absence is infered from sum_of_weights)	for(l=0;l<num_classes;l++)	{		weight[0][l]=MALLOC(sizeof(double)*num_tokens);		weight[1][l]=MALLOC(sizeof(double)*num_tokens);	}	for(t=1;t<num_tokens;t++)  // initialize	{		for(l=0;l<num_classes;l++)		{			weight[0][l][t]=0.0;			weight[1][l][t]=0.0;		}		tokeninfo_t* tokeninfo=(tokeninfo_t*)vector_get(template->tokens, t);		//fprintf(stdout,"%s [%s] %d\n",template->name->data,tokeninfo->key,tokeninfo->examples->length);		for(i=0;i<tokeninfo->examples->length;i++) // compute the presence weights		{			example_t* example=(example_t*)vector_get(examples,vector_get_int32_t(tokeninfo->examples,i));			for(l=0;l<num_classes;l++)			{				weight[b(example,l)][l][t]+=example->weight[l];			}		}	}	weakclassifier_t* classifier=NULL; // init an empty classifier	classifier=MALLOC(sizeof(weakclassifier_t));	classifier->template=template;	classifier->threshold=NAN;	classifier->alpha=1.0;	classifier->type=CLASSIFIER_TYPE_TEXT;	classifier->token=0;	classifier->column=column;	classifier->objective=1.0;	classifier->c0=MALLOC(sizeof(double)*num_classes);	classifier->c1=MALLOC(sizeof(double)*num_classes);	classifier->c2=MALLOC(sizeof(double)*num_classes);	double epsilon=smoothing/(num_classes*examples->length);	//min_objective=1;	for(t=1;t<num_tokens;t++)	{		double objective=0;		for(l=0;l<num_classes;l++) // compute the objective function Z()=sum_j(sum_l(SQRT(W+*W-))		{			/*if(weight[0][l][t]<0)weight[0][l][t]=0.0;			if(weight[1][l][t]<0)weight[1][l][t]=0.0;*/			objective+=SQRT((sum_of_weights[1][l]-weight[1][l][t])*(sum_of_weights[0][l]-weight[0][l][t]));			objective+=SQRT(weight[1][l][t]*weight[0][l][t]);		}		objective*=2;		//fprintf(stdout,"DEBUG: column=%d token=%d obj=%f\n",column,t,objective);		if(objective-min_objective<-1e-11) // select the argmin()		{			min_objective=objective;			classifier->token=t;			classifier->objective=objective;			for(l=0;l<num_classes;l++)  // update c0, c1 and c2 => c0 and c1 are the same for text stumps			{				classifier->c0[l]=0.5*LOG((sum_of_weights[1][l]-weight[1][l][t]+epsilon)/(sum_of_weights[0][l]-weight[0][l][t]+epsilon));				classifier->c1[l]=classifier->c0[l];				//classifier->c0[l]=0;				//classifier->c1[l]=0.5*LOG((sum_of_weights[1][l]-weight[1][l][t]+epsilon)/(sum_of_weights[0][l]-weight[0][l][t]+epsilon));				classifier->c2[l]=0.5*LOG((weight[1][l][t]+epsilon)/(weight[0][l][t]+epsilon));			}		}	}	for(l=0;l<num_classes;l++) // free memory	{		FREE(weight[0][l]);		FREE(weight[1][l]);	}	//tokeninfo_t* info=vector_get(template->tokens,classifier->token);	//fprintf(stdout,"DEBUG: column=%d token=%s obj=%f %s\n",column,info->key,classifier->objective,template->name->data);	if(classifier->token==0) // no better classifier has been found	{		FREE(classifier->c0);		FREE(classifier->c1);		FREE(classifier->c2);		FREE(classifier);		return NULL;	}	return classifier;}weakclassifier_t* train_continuous_stump(double min_objective, template_t* template, vector_t* examples_vector, int num_classes){	size_t i,j,l;	int column=template->column;	float* values=(float*)template->values->data;	int32_t* ordered=template->ordered;	example_t** examples=(example_t**)examples_vector->data;	if(ordered==NULL) // only order examples once, then keep the result in the template	{		ordered=MALLOC(sizeof(int32_t)*examples_vector->length);		int32_t index=0;		for(index=0;index<examples_vector->length;index++)ordered[index]=index;		//for(i=0;i<examples->length && i<4;i++)fprintf(stdout,"%d %f\n",i,vector_get_float(((example_t*)vector_get(examples,i))->features,column));		int local_comparator(const void* a, const void* b)		{			int32_t aa=*(int32_t*)a;			int32_t bb=*(int32_t*)b;			float aa_value=values[aa];			float bb_value=values[bb];			//float aa_value=vector_get_float(template->values,(size_t)aa);			//float bb_value=vector_get_float(template->values,(size_t)bb);			//float aa_value=vector_get_float(((example_t*)vector_get(examples,(size_t)aa))->features,column);			//float bb_value=vector_get_float(((example_t*)vector_get(examples,(size_t)bb))->features,column);			//fprintf(stdout,"%d(%f) <=> %d(%f)\n",aa,aa_value,bb,bb_value);			//if(aa_value<bb_value)return -1;			//if(aa_value>bb_value)return 1;			if(isnan(aa_value) || aa_value>bb_value)return 1; // put the NAN (unknown values) at the end of the list			if(isnan(bb_value) || aa_value<bb_value)return -1;			return 0;		}		qsort(ordered,examples_vector->length,sizeof(int32_t),local_comparator);		//vector_sort(ordered,local_comparator);		template->ordered=ordered;	}	double weight[3][2][num_classes]; // D(j,b,l)	for(j=0;j<3;j++)		for(l=0;l<num_classes;l++)		{			weight[j][0][l]=0.0;			weight[j][1][l]=0.0;		}	for(i=0;i<examples_vector->length;i++) // compute the "unknown" weights and the weight of examples after threshold	{		int32_t example_id=ordered[i];		example_t* example=examples[example_id];		//fprintf(stdout,"%d %f\n",column,vector_get_float(example->features,column));		for(l=0;l<num_classes;l++)		{			if(isnan(values[example_id]))				weight[0][b(example,l)][l]+=example->weight[l];			else				weight[2][b(example,l)][l]+=example->weight[l];		}	}	weakclassifier_t* classifier=NULL; // new classifier	classifier=MALLOC(sizeof(weakclassifier_t));	classifier->template=template;	classifier->threshold=NAN;	classifier->alpha=1.0;	classifier->type=CLASSIFIER_TYPE_THRESHOLD;	classifier->token=0;	classifier->column=column;	classifier->objective=1.0;	classifier->c0=MALLOC(sizeof(double)*num_classes);	classifier->c1=MALLOC(sizeof(double)*num_classes);	classifier->c2=MALLOC(sizeof(double)*num_classes);	double epsilon=smoothing/(num_classes*examples_vector->length);	for(i=0;i<examples_vector->length-1;i++) // compute the objective function at every possible threshold (in between examples)	{		int32_t example_id=ordered[i];		example_t* example=examples[example_id];		//fprintf(stdout,"%zd %zd %f\n",i,vector_get_int32_t(ordered,i),vector_get_float(template->values,example_id));		if(isnan(values[example_id]))break; // skip unknown values		//example_t* next_example=(example_t*)vector_get(examples,(size_t)next_example_id);		for(l=0;l<num_classes;l++) // update the objective function by putting the current example the other side of the threshold		{			weight[1][b(example,l)][l]+=example->weight[l];			weight[2][b(example,l)][l]-=example->weight[l];		}		int next_example_id=ordered[i+1];		if(values[example_id]==values[next_example_id])continue; // same value		double objective=0;		for(l=0;l<num_classes;l++) // compute objective Z()		{			/*if(weight[0][1][l]<0)weight[0][1][l]=0.0;			if(weight[0][0][l]<0)weight[0][0][l]=0.0;			if(weight[1][1][l]<0)weight[1][1][l]=0.0;			if(weight[1][0][l]<0)weight[1][0][l]=0.0;			if(weight[2][1][l]<0)weight[2][1][l]=0.0;			if(weight[2][0][l]<0)weight[2][0][l]=0.0;*/			objective+=SQRT(weight[0][1][l]*weight[0][0][l]);			objective+=SQRT(weight[1][1][l]*weight[1][0][l]);			objective+=SQRT(weight[2][1][l]*weight[2][0][l]);		}		objective*=2;		//fprintf(stdout,"DEBUG: column=%d threshold=%f obj=%f\n",column,(vector_get_float(next_example->features,column)+vector_get_float(example->features,column))/2,objective);		if(objective-min_objective<-1e-11) // get argmin		{			classifier->objective=objective;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩中文字幕精品| 日韩精品中文字幕在线不卡尤物| 色哟哟一区二区在线观看| 欧美午夜视频网站| 国产日韩欧美激情| 午夜精品久久久久久久| youjizz国产精品| 日韩视频免费观看高清完整版 | 国模冰冰炮一区二区| 色综合中文综合网| 日韩精品一级二级| 日韩欧美久久久| 亚洲免费av高清| 国产成人在线色| 欧美一区二区观看视频| 专区另类欧美日韩| 国内精品国产成人| 日韩一区二区三区免费看| 亚洲免费观看高清完整版在线观看熊 | 欧美在线你懂的| 国产欧美va欧美不卡在线| 久久精品国产久精国产爱| 在线视频一区二区免费| 亚洲欧美综合在线精品| 国产69精品久久久久777| 日韩免费成人网| 无码av中文一区二区三区桃花岛| 不卡在线视频中文字幕| 欧美成人女星排行榜| 日本系列欧美系列| 欧美高清视频不卡网| 一个色综合网站| 在线一区二区观看| 亚洲精品国产精华液| 成人福利视频网站| 国产精品区一区二区三区| 国产成人激情av| 国产农村妇女毛片精品久久麻豆| 激情图区综合网| 久久综合九色综合97_久久久| 美腿丝袜亚洲综合| 日韩精品专区在线影院观看| 久久av中文字幕片| 久久免费午夜影院| 成人毛片在线观看| 亚洲人妖av一区二区| 色一情一伦一子一伦一区| 亚洲免费av网站| 欧美日本一区二区三区四区| 日本中文一区二区三区| 欧美一区二区三区男人的天堂| 免费成人av在线| 2024国产精品视频| 成人免费福利片| 国产麻豆视频一区二区| 久久亚洲精华国产精华液| 国产高清久久久| 亚洲精品菠萝久久久久久久| 欧美电影在线免费观看| 久久www免费人成看片高清| 欧美精品一区二区高清在线观看| 国产成人精品综合在线观看| 一区二区三区中文免费| 日韩午夜av一区| 成人高清免费观看| 性欧美大战久久久久久久久| 日韩欧美激情四射| 9人人澡人人爽人人精品| 亚洲成人综合网站| 26uuuu精品一区二区| 色视频欧美一区二区三区| 青青草国产精品97视觉盛宴 | 亚洲视频在线观看一区| 欧美日韩国产精选| 国产一区二区视频在线| 日韩伦理av电影| 欧美一区二区三区视频免费| 成人免费不卡视频| 欧美aaaaa成人免费观看视频| 国产精品美女久久久久久久久| 欧美日本国产视频| 成人激情动漫在线观看| 喷水一区二区三区| 亚洲靠逼com| 欧美国产日本韩| 日韩视频在线永久播放| 色综合久久综合| 国产不卡在线播放| 免费久久精品视频| 一区二区三区中文在线| 国产日本欧洲亚洲| 日韩精品影音先锋| 精品噜噜噜噜久久久久久久久试看| 91色porny| 国产高清亚洲一区| 久久国产精品露脸对白| 亚洲一区二区三区国产| 国产精品第一页第二页第三页| 日韩精品最新网址| 欧美人动与zoxxxx乱| 色综合天天综合网国产成人综合天| 麻豆91在线看| 五月开心婷婷久久| 一级日本不卡的影视| 日韩理论片中文av| 国产精品日韩成人| 国产色一区二区| 久久午夜电影网| 日韩欧美综合在线| 欧美一区二区福利在线| 欧美日本精品一区二区三区| 欧美亚洲尤物久久| 色婷婷精品大在线视频| 色综合久久久久综合体桃花网| 成人国产精品免费网站| 国产成人日日夜夜| 国产成人午夜99999| 高清视频一区二区| 成人黄色av电影| 不卡视频免费播放| av一本久道久久综合久久鬼色| 国产成人久久精品77777最新版本| 国产黄色精品网站| 国产黄人亚洲片| 99在线热播精品免费| 97se亚洲国产综合自在线| 99精品国产一区二区三区不卡| 91免费国产在线观看| 欧亚一区二区三区| 欧美日韩高清影院| 日韩精品最新网址| 国产日韩欧美精品在线| 亚洲欧洲精品成人久久奇米网| 久99久精品视频免费观看| 免费日本视频一区| 国产成人精品午夜视频免费| 成人app软件下载大全免费| 97久久超碰精品国产| 色播五月激情综合网| 欧美日韩精品一区二区三区四区 | 久久综合色之久久综合| 国产午夜精品一区二区三区视频| 亚洲国产精品成人综合色在线婷婷| 国产精品久久久久久久第一福利 | 精品亚洲porn| caoporm超碰国产精品| 欧美中文字幕久久| 日韩一区二区三区免费看| 国产日产欧美精品一区二区三区| 国产精品国产三级国产| 亚洲成人激情自拍| 国产在线看一区| 色综合av在线| 欧美精品一区二区久久久| 亚洲人精品一区| 久久成人综合网| 91国模大尺度私拍在线视频| 日韩女优av电影| 亚洲精品第一国产综合野| 蜜桃精品视频在线| av中文字幕一区| 日韩精品中文字幕一区二区三区| 亚洲欧美综合在线精品| 美女高潮久久久| 色综合久久久久综合| 久久天天做天天爱综合色| 一区二区三区四区视频精品免费 | 亚洲国产日韩一级| 国产高清亚洲一区| 在线不卡一区二区| 国产精品进线69影院| 美女诱惑一区二区| 欧美性色黄大片| 欧美国产精品专区| 老司机一区二区| 欧美日韩精品是欧美日韩精品| 国产精品美女久久久久久久久久久 | 欧美精品一区男女天堂| 一区二区三区四区亚洲| 国产成a人亚洲| 久久综合一区二区| 日韩av电影天堂| 欧美曰成人黄网| 成人欧美一区二区三区视频网页| 韩国三级电影一区二区| 91精品在线免费| 亚洲高清免费一级二级三级| 99这里只有久久精品视频| 久久久青草青青国产亚洲免观| 日韩成人dvd| 欧美人伦禁忌dvd放荡欲情| 亚洲免费在线播放| 不卡的电影网站| 国产精品萝li| 波波电影院一区二区三区| 国产午夜精品久久| 国产福利一区在线| 久久久久久久久久久99999| 看国产成人h片视频| 日韩一区国产二区欧美三区|