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

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

?? svmpredict.c

?? libsvm(matlb SVM code)可以使用來作為分類
?? 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\n");						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一区二区三区免费野_久草精品视频
美女国产一区二区| 亚洲精品欧美专区| 欧美久久一区二区| 欧美性受xxxx| 一本大道av伊人久久综合| 成人黄色在线网站| 不卡在线观看av| 99在线热播精品免费| 成人免费av在线| kk眼镜猥琐国模调教系列一区二区| 国产精品自产自拍| 国产成人亚洲综合色影视| 国产精品99久| 成人av在线影院| 色婷婷综合久久久久中文一区二区| 色哟哟精品一区| 欧美日韩大陆在线| 日韩免费在线观看| 久久品道一品道久久精品| 国产亚洲一区二区三区四区| 国产日本欧洲亚洲| 《视频一区视频二区| 一区二区三区四区五区视频在线观看| 亚洲精品成人天堂一二三| 亚洲一区二区欧美| 久久国产综合精品| 处破女av一区二区| 欧美三级中文字幕| 精品久久久久久久久久久院品网 | 亚洲一区二区三区四区中文字幕| 亚洲色图在线看| 日韩精品一二三区| 一本久道久久综合中文字幕| 在线观看av不卡| 精品日韩在线观看| 亚洲人成人一区二区在线观看| 亚洲午夜精品17c| 精品亚洲国内自在自线福利| 成人av在线观| 91精品一区二区三区久久久久久| 国产亚洲欧美一区在线观看| 一区二区三区免费网站| 久久国产精品72免费观看| 91在线云播放| 精品1区2区在线观看| 一区二区三区精品| 国产精品亚洲专一区二区三区 | 99精品久久只有精品| 欧美喷潮久久久xxxxx| 国产欧美日韩一区二区三区在线观看 | 久久麻豆一区二区| 玉米视频成人免费看| 国产一区二区三区在线观看免费视频| 色综合久久中文字幕综合网| 日韩免费高清视频| 亚洲综合自拍偷拍| 99久久久精品免费观看国产蜜| 91精品一区二区三区在线观看| 亚洲欧美成aⅴ人在线观看| 精久久久久久久久久久| 欧美三级视频在线观看| 日韩码欧中文字| 成人一区二区三区在线观看| 日韩视频中午一区| 亚洲成人激情自拍| 在线观看不卡一区| 亚洲视频图片小说| 成人性生交大片免费看视频在线| 91精品国产一区二区三区蜜臀| 一区二区三区在线视频播放| 成人涩涩免费视频| 久久久亚洲精品一区二区三区| 免费在线观看日韩欧美| 欧美日韩久久久| 亚洲亚洲人成综合网络| 91麻豆国产香蕉久久精品| 国产精品卡一卡二| 丁香婷婷综合色啪| 国产精品视频在线看| 国产精品一区二区久久精品爱涩| 欧美精品一区二区在线播放| 精品综合久久久久久8888| 日韩亚洲国产中文字幕欧美| 五月天精品一区二区三区| 欧美日韩高清一区二区三区| 午夜精品影院在线观看| 欧美电影影音先锋| 免费不卡在线观看| 精品久久久久久久久久久久久久久 | 成人免费观看视频| 91蝌蚪porny| 亚洲免费在线看| 精品日本一线二线三线不卡| 在线观看成人小视频| 国产不卡高清在线观看视频| 午夜欧美2019年伦理| 国产日产欧美一区| 日韩欧美一二三四区| 欧洲视频一区二区| 波多野结衣一区二区三区| 美美哒免费高清在线观看视频一区二区| 亚洲视频每日更新| 国产精品乱人伦| 久久精品视频在线看| 日韩一级免费一区| 8v天堂国产在线一区二区| 91色在线porny| 99视频一区二区| 高清不卡在线观看| 国产成人免费视频网站| 紧缚捆绑精品一区二区| 麻豆国产精品视频| 蜜桃视频一区二区三区在线观看| 亚洲高清免费在线| 亚洲成人手机在线| 午夜天堂影视香蕉久久| 亚洲资源中文字幕| 亚洲午夜免费电影| 亚洲国产精品久久一线不卡| 一区二区高清免费观看影视大全| 亚洲日本青草视频在线怡红院 | 男女性色大片免费观看一区二区| 一区二区成人在线视频 | 午夜成人在线视频| 午夜精品一区二区三区免费视频| 一区av在线播放| 亚洲伊人伊色伊影伊综合网| 亚洲国产视频网站| 日韩av电影天堂| 精品一区二区三区视频| 黑人巨大精品欧美黑白配亚洲| 蓝色福利精品导航| 国产在线精品国自产拍免费| 国产成人精品免费一区二区| 北岛玲一区二区三区四区| 91免费看`日韩一区二区| 色94色欧美sute亚洲13| 欧美日本韩国一区二区三区视频| 欧美一级片免费看| 久久婷婷国产综合精品青草| 中文字幕免费在线观看视频一区| 国产精品毛片无遮挡高清| 一区二区高清在线| 麻豆91在线看| 成人av第一页| 欧美精品自拍偷拍| 久久综合久久久久88| 综合网在线视频| 日本亚洲电影天堂| 成人ar影院免费观看视频| 欧美日本在线一区| 久久久久亚洲蜜桃| 夜色激情一区二区| 国产伦精品一区二区三区免费迷| 播五月开心婷婷综合| 欧美日韩成人综合| 欧美国产一区视频在线观看| 亚洲一区二区三区视频在线| 精品一区中文字幕| 在线一区二区视频| 欧美精品一区二区三区视频| 亚洲精品一二三四区| 精品在线免费观看| 欧美视频一区二区三区| 久久精品一区二区三区不卡| 亚洲一区二区三区中文字幕在线| 国产在线播放一区三区四| 欧日韩精品视频| 欧美经典一区二区| 免费高清在线一区| 日本韩国欧美一区| 欧美极品少妇xxxxⅹ高跟鞋| 日本免费在线视频不卡一不卡二| 成人av资源站| 久久久久久亚洲综合| 五月天激情综合| 色婷婷综合久久久久中文| www久久久久| 日韩av一区二区三区四区| 91理论电影在线观看| 国产午夜精品在线观看| 日本亚洲免费观看| 欧美日韩精品是欧美日韩精品| 亚洲欧美一区二区在线观看| 韩国成人精品a∨在线观看| 777奇米四色成人影色区| 亚洲美女在线一区| 不卡视频在线看| 欧美国产激情二区三区| 国模无码大尺度一区二区三区| 91精品婷婷国产综合久久性色| 一区二区三区成人| 色丁香久综合在线久综合在线观看| 国产欧美一区二区精品性| 国产一区三区三区| 欧美精品一区二区三区蜜桃视频 | 亚洲欧美日韩国产综合在线| 国产精品77777| 久久久91精品国产一区二区精品| 久久se这里有精品|