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

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

?? svmpredict.c

?? A simple MATLAB interface LIBSVM authors at National Taiwan University.
?? C
字號:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include "svm.h"#include "mex.h"#include "svm_model_matlab.h"#if MX_API_VER < 0x07030000typedef int mwIndex;#endif #define CMD_LEN 2048void read_sparse_instance(const mxArray *prhs, int index, struct svm_node *x){	int i, j, low, high;	mwIndex *ir, *jc;	double *samples;	ir = mxGetIr(prhs);	jc = mxGetJc(prhs);	samples = mxGetPr(prhs);	// each column is one instance	j = 0;	low = jc[index], high = jc[index+1];	for(i=low;i<high;i++)	{		x[j].index = ir[i] + 1;		x[j].value = samples[i];		j++; 	}	x[j].index = -1;}static void fake_answer(mxArray *plhs[]){	plhs[0] = mxCreateDoubleMatrix(0, 0, mxREAL);	plhs[1] = mxCreateDoubleMatrix(0, 0, mxREAL);	plhs[2] = mxCreateDoubleMatrix(0, 0, mxREAL);}void predict(mxArray *plhs[], const mxArray *prhs[], struct svm_model *model, const int predict_probability){	int label_vector_row_num, label_vector_col_num;	int feature_number, testing_instance_number;	int instance_index;	double *ptr_instance, *ptr_label, *ptr_predict_label; 	double *ptr_prob_estimates, *ptr_dec_values, *ptr;	struct svm_node *x;	mxArray *pplhs[1]; // transposed instance sparse matrix	int correct = 0;	int total = 0;	double error = 0;	double sumv = 0, sumy = 0, sumvv = 0, sumyy = 0, sumvy = 0;	int svm_type=svm_get_svm_type(model);	int nr_class=svm_get_nr_class(model);	double *prob_estimates=NULL;	// prhs[1] = testing instance matrix	feature_number = mxGetN(prhs[1]);	testing_instance_number = mxGetM(prhs[1]);	label_vector_row_num = mxGetM(prhs[0]);	label_vector_col_num = mxGetN(prhs[0]);	if(label_vector_row_num!=testing_instance_number)	{		mexPrintf("Length of label vector does not match # of instances.\n");		fake_answer(plhs);		return;	}	if(label_vector_col_num!=1)	{		mexPrintf("label (1st argument) should be a vector (# of column is 1).\n");		fake_answer(plhs);		return;	}	ptr_instance = mxGetPr(prhs[1]);	ptr_label    = mxGetPr(prhs[0]);		// transpose instance matrix	if(mxIsSparse(prhs[1]))	{		if(model->param.kernel_type == PRECOMPUTED)		{			// precomputed kernel requires dense matrix, so we make one			mxArray *rhs[1], *lhs[1];			rhs[0] = mxDuplicateArray(prhs[1]);			if(mexCallMATLAB(1, lhs, 1, rhs, "full"))			{				mexPrintf("Error: cannot full testing instance matrix\n");				fake_answer(plhs);				return;			}			ptr_instance = mxGetPr(lhs[0]);			mxDestroyArray(rhs[0]);		}		else		{			mxArray *pprhs[1];			pprhs[0] = mxDuplicateArray(prhs[1]);			if(mexCallMATLAB(1, pplhs, 1, pprhs, "transpose"))			{				mexPrintf("Error: cannot transpose testing instance matrix\n");				fake_answer(plhs);				return;			}		}	}	if(predict_probability)	{		if(svm_type==NU_SVR || svm_type==EPSILON_SVR)			mexPrintf("Prob. model for test data: target value = predicted value + z,\nz: Laplace distribution e^(-|z|/sigma)/(2sigma),sigma=%g\n",svm_get_svr_probability(model));		else			prob_estimates = (double *) malloc(nr_class*sizeof(double));	}	plhs[0] = mxCreateDoubleMatrix(testing_instance_number, 1, mxREAL);	if(predict_probability)	{		// prob estimates are in plhs[2]		if(svm_type==C_SVC || svm_type==NU_SVC)			plhs[2] = mxCreateDoubleMatrix(testing_instance_number, nr_class, mxREAL);		else			plhs[2] = mxCreateDoubleMatrix(0, 0, mxREAL);	}	else	{		// decision values are in plhs[2]		if(svm_type == ONE_CLASS ||		   svm_type == EPSILON_SVR ||		   svm_type == NU_SVR)			plhs[2] = mxCreateDoubleMatrix(testing_instance_number, 1, mxREAL);		else			plhs[2] = mxCreateDoubleMatrix(testing_instance_number, nr_class*(nr_class-1)/2, mxREAL);	}	ptr_predict_label = mxGetPr(plhs[0]);	ptr_prob_estimates = mxGetPr(plhs[2]);	ptr_dec_values = mxGetPr(plhs[2]);	x = (struct svm_node*)malloc((feature_number+1)*sizeof(struct svm_node) );	for(instance_index=0;instance_index<testing_instance_number;instance_index++)	{		int i;		double target,v;		target = ptr_label[instance_index];		if(mxIsSparse(prhs[1]) && model->param.kernel_type != PRECOMPUTED) // prhs[1]^T is still sparse			read_sparse_instance(pplhs[0], instance_index, x);		else		{			for(i=0;i<feature_number;i++)			{				x[i].index = i+1;				x[i].value = ptr_instance[testing_instance_number*i+instance_index];			}			x[feature_number].index = -1;		}		if(predict_probability) 		{			if(svm_type==C_SVC || svm_type==NU_SVC)			{				v = svm_predict_probability(model, x, prob_estimates);				ptr_predict_label[instance_index] = v;				for(i=0;i<nr_class;i++)					ptr_prob_estimates[instance_index + i * testing_instance_number] = prob_estimates[i];			} else {				v = svm_predict(model,x);				ptr_predict_label[instance_index] = v;			}		}		else		{			v = svm_predict(model,x);			ptr_predict_label[instance_index] = v;			if(svm_type == ONE_CLASS ||			   svm_type == EPSILON_SVR ||			   svm_type == NU_SVR)			{				double res;				svm_predict_values(model, x, &res);				ptr_dec_values[instance_index] = res;			}			else			{				double *dec_values = (double *) malloc(sizeof(double) * nr_class*(nr_class-1)/2);				svm_predict_values(model, x, dec_values);				for(i=0;i<(nr_class*(nr_class-1))/2;i++)					ptr_dec_values[instance_index + i * testing_instance_number] = dec_values[i];				free(dec_values);			}		}		if(v == target)			++correct;		error += (v-target)*(v-target);		sumv += v;		sumy += target;		sumvv += v*v;		sumyy += target*target;		sumvy += v*target;		++total;	}	if(svm_type==NU_SVR || svm_type==EPSILON_SVR)	{		mexPrintf("Mean squared error = %g (regression)\n",error/total);		mexPrintf("Squared correlation coefficient = %g (regression)\n",			((total*sumvy-sumv*sumy)*(total*sumvy-sumv*sumy))/			((total*sumvv-sumv*sumv)*(total*sumyy-sumy*sumy))			);	}	else		mexPrintf("Accuracy = %g%% (%d/%d) (classification)\n",			(double)correct/total*100,correct,total);	// return accuracy, mean squared error, squared correlation coefficient	plhs[1] = mxCreateDoubleMatrix(3, 1, mxREAL);	ptr = mxGetPr(plhs[1]);	ptr[0] = (double)correct/total*100;	ptr[1] = error/total;	ptr[2] = ((total*sumvy-sumv*sumy)*(total*sumvy-sumv*sumy))/				((total*sumvv-sumv*sumv)*(total*sumyy-sumy*sumy));	free(x);	if(prob_estimates != NULL)		free(prob_estimates);}void exit_with_help(){	mexPrintf(	"Usage: [predicted_label, accuracy, decision_values/prob_estimates] = svmpredict(testing_label_vector, testing_instance_matrix, model, 'libsvm_options')\n"	"libsvm_options:\n"	"-b probability_estimates: whether to predict probability estimates, 0 or 1 (default 0); one-class SVM not supported yet\n"	);}void mexFunction( int nlhs, mxArray *plhs[],		 int nrhs, const mxArray *prhs[] ){	int prob_estimate_flag = 0;	struct svm_model *model;	if(nrhs > 4 || nrhs < 3)	{		exit_with_help();		fake_answer(plhs);		return;	}	if(!mxIsDouble(prhs[0]) || !mxIsDouble(prhs[1])) {		mexPrintf("Error: label vector and instance matrix must be double\n");		fake_answer(plhs);		return;	}	if(mxIsStruct(prhs[2]))	{		const char *error_msg;		// parse options		if(nrhs==4)		{			int i, argc = 1;			char cmd[CMD_LEN], *argv[CMD_LEN/2];			// put options in argv[]			mxGetString(prhs[3], cmd,  mxGetN(prhs[3]) + 1);			if((argv[argc] = strtok(cmd, " ")) != NULL)				while((argv[++argc] = strtok(NULL, " ")) != NULL)					;			for(i=1;i<argc;i++)			{				if(argv[i][0] != '-') break;				if(++i>=argc)				{					exit_with_help();					fake_answer(plhs);					return;				}				switch(argv[i-1][1])				{					case 'b':						prob_estimate_flag = atoi(argv[i]);						break;					default:						mexPrintf("Unknown option: -%c\n", argv[i-1][1]);						exit_with_help();						fake_answer(plhs);						return;				}			}		}		model = matlab_matrix_to_model(prhs[2], &error_msg);		if (model == NULL)		{			mexPrintf("Error: can't read model: %s\n", error_msg);			fake_answer(plhs);			return;		}		if(prob_estimate_flag)		{			if(svm_check_probability_model(model)==0)			{				mexPrintf("Model does not support probabiliy estimates\n");				fake_answer(plhs);				svm_destroy_model(model);				return;			}		}		else		{			if(svm_check_probability_model(model)!=0)				printf("Model supports probability estimates, but disabled in predicton.\n");		}		predict(plhs, prhs, model, prob_estimate_flag);		// destroy model		svm_destroy_model(model);	}	else	{		mexPrintf("model file should be a struct array\n");		fake_answer(plhs);	}	return;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久另类综合| 免费的国产精品| 丝袜美腿高跟呻吟高潮一区| 欧美96一区二区免费视频| 国产高清精品在线| 欧美主播一区二区三区| 日韩精品中文字幕在线一区| 中文字幕不卡三区| 亚洲电影你懂得| 成人一区二区在线观看| 欧美三区在线观看| 欧美国产一区二区| 首页国产丝袜综合| 97久久精品人人做人人爽50路| 欧美老年两性高潮| 中文字幕一区二区三区在线不卡| 亚洲综合丁香婷婷六月香| 亚洲va中文字幕| caoporm超碰国产精品| 精品国产乱码久久久久久图片 | 欧美精品色综合| 国产欧美一区二区精品久导航| 亚洲柠檬福利资源导航| 国产精品一二一区| 91精品午夜视频| 一区二区三区四区亚洲| 粉嫩av一区二区三区粉嫩| 日韩一区二区三区电影在线观看| 亚洲精品ww久久久久久p站| 青青草成人在线观看| 色综合色综合色综合色综合色综合 | 欧美一区二区三区在| 亚洲欧洲一区二区三区| 蜜乳av一区二区三区| 欧亚洲嫩模精品一区三区| 国产精品免费视频一区| 亚洲v日本v欧美v久久精品| 99久久99久久精品免费观看| 国产色91在线| 久久国产精品免费| 日韩精品在线一区二区| 日韩精品色哟哟| 欧美久久婷婷综合色| 亚洲高清在线精品| 欧洲精品中文字幕| 亚洲第一精品在线| 欧美日韩二区三区| 亚洲福利视频导航| 在线视频中文字幕一区二区| 亚洲影院久久精品| 欧美性生活影院| 中文字幕日韩精品一区| aa级大片欧美| 亚洲精品五月天| 色狠狠色狠狠综合| 亚洲无人区一区| 在线91免费看| 美女网站视频久久| 久久影视一区二区| 蜜桃传媒麻豆第一区在线观看| 在线播放欧美女士性生活| 亚洲午夜视频在线观看| 777a∨成人精品桃花网| 另类的小说在线视频另类成人小视频在线| 欧美主播一区二区三区| 天天综合网天天综合色| 日韩视频一区在线观看| 久久精品国内一区二区三区| 久久久久久电影| 99视频精品免费视频| 亚洲美女一区二区三区| 欧美欧美欧美欧美| 成人精品小蝌蚪| 青草av.久久免费一区| 国产精品高清亚洲| 日韩一二三区视频| 一本色道久久综合狠狠躁的推荐| 久久超碰97人人做人人爱| 亚洲免费av高清| 久久男人中文字幕资源站| 欧美剧情片在线观看| 成人黄色在线网站| 麻豆精品在线看| 亚洲男人天堂av| 精品国产伦一区二区三区观看方式 | 亚洲18女电影在线观看| 国产精品久久夜| 欧美精品一区二区蜜臀亚洲| 91麻豆自制传媒国产之光| 久久精品国产亚洲aⅴ| 亚洲人成伊人成综合网小说| 欧美mv日韩mv| 欧美三日本三级三级在线播放| 国产精品一区二区久久精品爱涩| 五月天中文字幕一区二区| 国产精品的网站| 久久久久99精品国产片| 在线成人av影院| 欧美日韩一区二区三区四区| 不卡av免费在线观看| 国产麻豆精品在线| 精品在线播放午夜| 日韩经典中文字幕一区| 亚洲欧美区自拍先锋| 国产欧美日韩激情| 国产亚洲一区字幕| 久久精品夜夜夜夜久久| 日韩一级高清毛片| 宅男噜噜噜66一区二区66| 欧美综合一区二区| 色狠狠桃花综合| 91污片在线观看| 成人毛片老司机大片| 国模套图日韩精品一区二区| 韩国毛片一区二区三区| 久久99精品久久久久久动态图 | 国产精品亚洲第一区在线暖暖韩国 | 欧美高清在线一区| 国产清纯白嫩初高生在线观看91 | caoporn国产精品| 91在线视频观看| 在线亚洲免费视频| 在线不卡一区二区| 精品捆绑美女sm三区| 久久精品日产第一区二区三区高清版 | 国产欧美一区二区精品性色超碰 | 日韩午夜在线播放| 欧美大片一区二区三区| 久久精品夜色噜噜亚洲aⅴ| 国产欧美精品日韩区二区麻豆天美| 久久久久久久久99精品| 亚洲欧美在线视频观看| 亚洲国产欧美在线| 黄色资源网久久资源365| 国产高清久久久久| 91精品福利视频| 4438x成人网最大色成网站| 日韩欧美的一区二区| 久久久激情视频| 最新不卡av在线| 日韩精品午夜视频| 国产精品系列在线播放| 91国产精品成人| 日韩欧美国产麻豆| 国产精品热久久久久夜色精品三区 | 久久久久国色av免费看影院| 亚洲欧美综合网| 日本va欧美va瓶| 99re6这里只有精品视频在线观看| 欧美美女直播网站| 国产精品剧情在线亚洲| 丝袜亚洲另类丝袜在线| 国产在线不卡一区| 欧美色综合久久| 久久精品一区二区三区不卡| 一区二区三区不卡视频| 国产一本一道久久香蕉| 欧美日韩视频专区在线播放| 国产女人水真多18毛片18精品视频 | 555www色欧美视频| 中文字幕一区免费在线观看| 麻豆91精品视频| 在线免费观看成人短视频| 久久看人人爽人人| 欧美aaa在线| 欧美自拍偷拍午夜视频| 国产精品美女久久久久高潮| 毛片av一区二区三区| 日本高清成人免费播放| 国产视频不卡一区| 青青草伊人久久| 欧美在线一二三| 中文字幕日韩av资源站| 国产精选一区二区三区| 欧美一区二区三区电影| 亚洲一区二区偷拍精品| 99视频精品免费视频| 欧美激情一区三区| 国产一区二区三区在线看麻豆| 欧美浪妇xxxx高跟鞋交| 亚洲精品国久久99热| 国产精品白丝jk黑袜喷水| 欧美精品vⅰdeose4hd| 亚洲综合色噜噜狠狠| 99国产精品国产精品毛片| 国产欧美日韩中文久久| 久久激情五月婷婷| 日韩视频123| 奇米影视在线99精品| 91精品婷婷国产综合久久| 亚洲人亚洲人成电影网站色| 成人毛片视频在线观看| 中文文精品字幕一区二区| 国产成人亚洲综合a∨婷婷图片 | 国产一区二区三区日韩| 精品福利二区三区| 国产精品综合二区| 欧美国产日韩一二三区| 不卡视频在线看| 国产精品美女久久久久久|