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

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

?? svm.m4

?? 支持向量機初學者可以
?? M4
?? 第 1 頁 / 共 5 頁
字號:
			for(j=0;j<begin;j++)			{				subprob.x[k] = prob.x[perm[j]];				subprob.y[k] = prob.y[perm[j]];				++k;			}			for(j=end;j<l;j++)			{				subprob.x[k] = prob.x[perm[j]];				subprob.y[k] = prob.y[perm[j]];				++k;			}			svm_model submodel = svm_train(subprob,param);			if(param.probability==1 &&			   (param.svm_type == svm_parameter.C_SVC ||			    param.svm_type == svm_parameter.NU_SVC))			{				double[] prob_estimates= new double[svm_get_nr_class(submodel)];				for(j=begin;j<end;j++)					target[perm[j]] = svm_predict_probability(submodel,prob.x[perm[j]],prob_estimates);			}			else				for(j=begin;j<end;j++)					target[perm[j]] = svm_predict(submodel,prob.x[perm[j]]);		}	}	public static int svm_get_svm_type(svm_model model)	{		return model.param.svm_type;	}	public static int svm_get_nr_class(svm_model model)	{		return model.nr_class;	}	public static void svm_get_labels(svm_model model, int[] label)	{		if (model.label != null)			for(int i=0;i<model.nr_class;i++)				label[i] = model.label[i];	}	public static double svm_get_svr_probability(svm_model model)	{		if ((model.param.svm_type == svm_parameter.EPSILON_SVR || model.param.svm_type == svm_parameter.NU_SVR) &&		    model.probA!=null)		return model.probA[0];		else		{			System.err.print("Model doesn't contain information for SVR probability inference\n");			return 0;		}	}	public static void svm_predict_values(svm_model model, svm_node[] x, double[] dec_values)	{		if(model.param.svm_type == svm_parameter.ONE_CLASS ||		   model.param.svm_type == svm_parameter.EPSILON_SVR ||		   model.param.svm_type == svm_parameter.NU_SVR)		{			double[] sv_coef = model.sv_coef[0];			double sum = 0;			for(int i=0;i<model.l;i++)				sum += sv_coef[i] * Kernel.k_function(x,model.SV[i],model.param);			sum -= model.rho[0];			dec_values[0] = sum;		}		else		{			int i;			int nr_class = model.nr_class;			int l = model.l;					double[] kvalue = new double[l];			for(i=0;i<l;i++)				kvalue[i] = Kernel.k_function(x,model.SV[i],model.param);			int[] start = new int[nr_class];			start[0] = 0;			for(i=1;i<nr_class;i++)				start[i] = start[i-1]+model.nSV[i-1];			int p=0;			for(i=0;i<nr_class;i++)				for(int j=i+1;j<nr_class;j++)				{					double sum = 0;					int si = start[i];					int sj = start[j];					int ci = model.nSV[i];					int cj = model.nSV[j];									int k;					double[] coef1 = model.sv_coef[j-1];					double[] coef2 = model.sv_coef[i];					for(k=0;k<ci;k++)						sum += coef1[si+k] * kvalue[si+k];					for(k=0;k<cj;k++)						sum += coef2[sj+k] * kvalue[sj+k];					sum -= model.rho[p];					dec_values[p] = sum;										p++;				}		}	}	public static double svm_predict(svm_model model, svm_node[] x)	{		if(model.param.svm_type == svm_parameter.ONE_CLASS ||		   model.param.svm_type == svm_parameter.EPSILON_SVR ||		   model.param.svm_type == svm_parameter.NU_SVR)		{			double[] res = new double[1];			svm_predict_values(model, x, res);			if(model.param.svm_type == svm_parameter.ONE_CLASS)				return (res[0]>0)?1:-1;			else				return res[0];		}		else		{			int i;			int nr_class = model.nr_class;			double[] dec_values = new double[nr_class*(nr_class-1)/2];			svm_predict_values(model, x, dec_values);			int[] vote = new int[nr_class];			for(i=0;i<nr_class;i++)				vote[i] = 0;			int pos=0;			for(i=0;i<nr_class;i++)				for(int j=i+1;j<nr_class;j++)				{					if(dec_values[pos++] > 0)						++vote[i];					else						++vote[j];				}			int vote_max_idx = 0;			for(i=1;i<nr_class;i++)				if(vote[i] > vote[vote_max_idx])					vote_max_idx = i;			return model.label[vote_max_idx];		}	}	public static double svm_predict_probability(svm_model model, svm_node[] x, double[] prob_estimates)	{		if ((model.param.svm_type == svm_parameter.C_SVC || model.param.svm_type == svm_parameter.NU_SVC) &&		    model.probA!=null && model.probB!=null)		{			int i;			int nr_class = model.nr_class;			double[] dec_values = new double[nr_class*(nr_class-1)/2];			svm_predict_values(model, x, dec_values);			double min_prob=1e-7;			double[][] pairwise_prob=new double[nr_class][nr_class];						int k=0;			for(i=0;i<nr_class;i++)				for(int j=i+1;j<nr_class;j++)				{					pairwise_prob[i][j]=Math.min(Math.max(sigmoid_predict(dec_values[k],model.probA[k],model.probB[k]),min_prob),1-min_prob);					pairwise_prob[j][i]=1-pairwise_prob[i][j];					k++;				}			multiclass_probability(nr_class,pairwise_prob,prob_estimates);			int prob_max_idx = 0;			for(i=1;i<nr_class;i++)				if(prob_estimates[i] > prob_estimates[prob_max_idx])					prob_max_idx = i;			return model.label[prob_max_idx];		}		else 			return svm_predict(model, x);	}	static final String svm_type_table[] =	{		"c_svc","nu_svc","one_class","epsilon_svr","nu_svr",	};	static final String kernel_type_table[]=	{		"linear","polynomial","rbf","sigmoid","precomputed"	};	public static void svm_save_model(String model_file_name, svm_model model) throws IOException	{		DataOutputStream fp = new DataOutputStream(new FileOutputStream(model_file_name));		svm_parameter param = model.param;		fp.writeBytes("svm_type "+svm_type_table[param.svm_type]+"\n");		fp.writeBytes("kernel_type "+kernel_type_table[param.kernel_type]+"\n");		if(param.kernel_type == svm_parameter.POLY)			fp.writeBytes("degree "+param.degree+"\n");		if(param.kernel_type == svm_parameter.POLY ||		   param.kernel_type == svm_parameter.RBF ||		   param.kernel_type == svm_parameter.SIGMOID)			fp.writeBytes("gamma "+param.gamma+"\n");		if(param.kernel_type == svm_parameter.POLY ||		   param.kernel_type == svm_parameter.SIGMOID)			fp.writeBytes("coef0 "+param.coef0+"\n");		int nr_class = model.nr_class;		int l = model.l;		fp.writeBytes("nr_class "+nr_class+"\n");		fp.writeBytes("total_sv "+l+"\n");			{			fp.writeBytes("rho");			for(int i=0;i<nr_class*(nr_class-1)/2;i++)				fp.writeBytes(" "+model.rho[i]);			fp.writeBytes("\n");		}			if(model.label != null)		{			fp.writeBytes("label");			for(int i=0;i<nr_class;i++)				fp.writeBytes(" "+model.label[i]);			fp.writeBytes("\n");		}		if(model.probA != null) // regression has probA only		{			fp.writeBytes("probA");			for(int i=0;i<nr_class*(nr_class-1)/2;i++)				fp.writeBytes(" "+model.probA[i]);			fp.writeBytes("\n");		}		if(model.probB != null) 		{			fp.writeBytes("probB");			for(int i=0;i<nr_class*(nr_class-1)/2;i++)				fp.writeBytes(" "+model.probB[i]);			fp.writeBytes("\n");		}		if(model.nSV != null)		{			fp.writeBytes("nr_sv");			for(int i=0;i<nr_class;i++)				fp.writeBytes(" "+model.nSV[i]);			fp.writeBytes("\n");		}		fp.writeBytes("SV\n");		double[][] sv_coef = model.sv_coef;		svm_node[][] SV = model.SV;		for(int i=0;i<l;i++)		{			for(int j=0;j<nr_class-1;j++)				fp.writeBytes(sv_coef[j][i]+" ");			svm_node[] p = SV[i];			if(param.kernel_type == svm_parameter.PRECOMPUTED)				fp.writeBytes("0:"+(int)(p[0].value));			else					for(int j=0;j<p.length;j++)					fp.writeBytes(p[j].index+":"+p[j].value+" ");			fp.writeBytes("\n");		}		fp.close();	}	private static double atof(String s)	{		return Double.valueOf(s).doubleValue();	}	private static int atoi(String s)	{		return Integer.parseInt(s);	}	public static svm_model svm_load_model(String model_file_name) throws IOException	{		BufferedReader fp = new BufferedReader(new FileReader(model_file_name));		// read parameters		svm_model model = new svm_model();		svm_parameter param = new svm_parameter();		model.param = param;		model.rho = null;		model.probA = null;		model.probB = null;		model.label = null;		model.nSV = null;		while(true)		{			String cmd = fp.readLine();			String arg = cmd.substring(cmd.indexOf(' ')+1);			if(cmd.startsWith("svm_type"))			{				int i;				for(i=0;i<svm_type_table.length;i++)				{					if(arg.indexOf(svm_type_table[i])!=-1)					{						param.svm_type=i;						break;					}				}				if(i == svm_type_table.length)				{					System.err.print("unknown svm type.\n");					return null;				}			}			else if(cmd.startsWith("kernel_type"))			{				int i;				for(i=0;i<kernel_type_table.length;i++)				{					if(arg.indexOf(kernel_type_table[i])!=-1)					{						param.kernel_type=i;						break;					}				}				if(i == kernel_type_table.length)				{					System.err.print("unknown kernel function.\n");					return null;				}			}			else if(cmd.startsWith("degree"))				param.degree = atoi(arg);			else if(cmd.startsWith("gamma"))				param.gamma = atof(arg);			else if(cmd.startsWith("coef0"))				param.coef0 = atof(arg);			else if(cmd.startsWith("nr_class"))				model.nr_class = atoi(arg);			else if(cmd.startsWith("total_sv"))				model.l = atoi(arg);			else if(cmd.startsWith("rho"))			{				int n = model.nr_class * (model.nr_class-1)/2;				model.rho = new double[n];				StringTokenizer st = new StringTokenizer(arg);				for(int i=0;i<n;i++)					model.rho[i] = atof(st.nextToken());			}			else if(cmd.startsWith("label"))			{				int n = model.nr_class;				model.label = new int[n];				StringTokenizer st = new StringTokenizer(arg);				for(int i=0;i<n;i++)					model.label[i] = atoi(st.nextToken());								}			else if(cmd.startsWith("probA"))			{				int n = model.nr_class*(model.nr_class-1)/2;				model.probA = new double[n];				StringTokenizer st = new StringTokenizer(arg);				for(int i=0;i<n;i++)					model.probA[i] = atof(st.nextToken());								}			else if(cmd.startsWith("probB"))			{				int n = model.nr_class*(model.nr_class-1)/2;				model.probB = new double[n];				StringTokenizer st = new StringTokenizer(arg);				for(int i=0;i<n;i++)					model.probB[i] = atof(st.nextToken());								}			else if(cmd.startsWith("nr_sv"))			{				int n = model.nr_class;				model.nSV = new int[n];				StringTokenizer st = new StringTokenizer(arg);				for(int i=0;i<n;i++)					model.nSV[i] = atoi(st.nextToken());			}			else if(cmd.startsWith("SV"))			{				break;			}			else			{				System.err.print("unknown text in model file: ["+cmd+"]\n");				return null;			}		}		// read sv_coef and SV		int m = model.nr_class - 1;		int l = model.l;		model.sv_coef = new double[m][l];		model.SV = new svm_node[l][];		for(int i=0;i<l;i++)		{			String line = fp.readLine();			StringTokenizer st = new StringTokenizer(line," \t\n\r\f:");			for(int k=0;k<m;k++)				model.sv_coef[k][i] = atof(st.nextToken());			int n = st.countTokens()/2;			model.SV[i] = new svm_node[n];			for(int j=0;j<n;j++)			{				model.SV[i][j] = new svm_node();				model.SV[i][j].index = atoi(st.nextToken());				model.SV[i][j].value = atof(st.nextToken());			}		}		fp.close();		return model;	}	public static String svm_check_parameter(svm_problem prob, svm_parameter param)	{		// svm_type		int svm_type = param.svm_type;		if(svm_type != svm_parameter.C_SVC &&		   svm_type != svm_parameter.NU_SVC &&		   svm_type != svm_parameter.ONE_CLASS &&		   svm_type != svm_parameter.EPSILON_SVR &&		   svm_type != svm_parameter.NU_SVR)		return "unknown svm type";		// kernel_type, degree			int kernel_type = param.kernel_type;		if(kernel_type != svm_parameter.LINEAR &&		   kernel_type != svm_parameter.POLY &&		   kernel_type != svm_parameter.RBF &&		   kernel_type != svm_parameter.SIGMOID &&		   kernel_type != svm_parameter.PRECOMPUTED)			return "unknown kernel type";		if(param.degree < 0)			return "degree of polynomial kernel < 0";		// cache_size,eps,C,nu,p,shrinking		if(param.cache_size <= 0)			return "cache_size <= 0";		if(param.eps <= 0)			return "eps <= 0";		if(svm_type == svm_parameter.C_SVC ||		   svm_type == svm_parameter.EPSILON_SVR ||		   svm_type == svm_parameter.NU_SVR)			if(param.C <= 0)				return "C <= 0";		if(svm_type == svm_parameter.NU_SVC ||		   svm_type == svm_parameter.ONE_CLASS ||		   svm_type == svm_parameter.NU_SVR)			if(param.nu <= 0 || param.nu > 1)				return "nu <= 0 or nu > 1";		if(svm_type == svm_parameter.EPSILON_SVR)			if(param.p < 0)				return "p < 0";		if(param.shrinking != 0 &&		   param.shrinking != 1)			return "shrinking != 0 and shrinking != 1";		if(param.probability != 0 &&		   param.probability != 1)			return "probability != 0 and probability != 1";		if(param.probability == 1 &&		   svm_type == svm_parameter.ONE_CLASS)			return "one-class SVM probability output not supported yet";				// check whether nu-svc is feasible			if(svm_type == svm_parameter.NU_SVC)		{			int l = prob.l;			int max_nr_class = 16;			int nr_class = 0;			int[] label = new int[max_nr_class];			int[] count = new int[max_nr_class];			int i;			for(i=0;i<l;i++)			{				int this_label = (int)prob.y[i];				int j;				for(j=0;j<nr_class;j++)					if(this_label == label[j])					{						++count[j];						break;					}				if(j == nr_class)				{					if(nr_class == max_nr_class)					{						max_nr_class *= 2;						int[] new_data = new int[max_nr_class];						System.arraycopy(label,0,new_data,0,label.length);						label = new_data;												new_data = new int[max_nr_class];						System.arraycopy(count,0,new_data,0,count.length);						count = new_data;					}					label[nr_class] = this_label;					count[nr_class] = 1;					++nr_class;				}			}			for(i=0;i<nr_class;i++)			{				int n1 = count[i];				for(int j=i+1;j<nr_class;j++)				{					int n2 = count[j];					if(param.nu*(n1+n2)/2 > Math.min(n1,n2))						return "specified nu is infeasible";				}			}		}		return null;	}	public static int svm_check_probability_model(svm_model model)	{		if (((model.param.svm_type == svm_parameter.C_SVC || model.param.svm_type == svm_parameter.NU_SVC) &&		model.probA!=null && model.probB!=null) ||		((model.param.svm_type == svm_parameter.EPSILON_SVR || model.param.svm_type == svm_parameter.NU_SVR) &&		 model.probA!=null))			return 1;		else			return 0;	}}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩主播视频在线| 美美哒免费高清在线观看视频一区二区 | 91免费在线看| 国内精品免费**视频| 亚洲国产日日夜夜| 一区二区三区在线免费视频 | 91精品视频网| 99久久精品国产一区二区三区| 国产精品影视在线| 国产成人午夜视频| 高清久久久久久| 成人精品小蝌蚪| 丁香婷婷综合激情五月色| 欧美精品丝袜中出| 精品1区2区3区| 欧美亚洲高清一区二区三区不卡| av色综合久久天堂av综合| 色偷偷久久人人79超碰人人澡| 成人免费av在线| 精品国产污污免费网站入口 | 欧美日韩亚洲综合一区| 中文字幕av一区二区三区| 久久久久国产精品厨房| 久久精品在这里| 亚洲三级在线观看| 亚洲一区视频在线| 久久精品国产色蜜蜜麻豆| 国产99久久久精品| 久久影院午夜论| 亚洲与欧洲av电影| 91猫先生在线| 亚洲精品视频自拍| 国内偷窥港台综合视频在线播放| 欧美精品国产精品| 日本欧美大码aⅴ在线播放| 国产精品77777| 日韩不卡免费视频| 欧美一区二区播放| 亚洲欧洲日韩av| 日韩高清在线不卡| 91精品国产色综合久久| 美国欧美日韩国产在线播放| 91精品啪在线观看国产60岁| 乱中年女人伦av一区二区| 日韩视频一区二区在线观看| 1024成人网| 色哟哟精品一区| 日本麻豆一区二区三区视频| 精品国偷自产国产一区| 国产真实乱偷精品视频免| 国产精品免费视频网站| 美女国产一区二区| 国产日韩欧美不卡| 久久国产婷婷国产香蕉| 精品999久久久| 99在线精品视频| 午夜视频一区在线观看| 91成人免费电影| 国产精品美日韩| 欧美视频日韩视频| 另类专区欧美蜜桃臀第一页| 久久精品夜色噜噜亚洲aⅴ| 99久久婷婷国产| 青青草91视频| 91精品国产综合久久久久久久久久| 蜜桃av一区二区三区| 国产精品欧美久久久久无广告| 色狠狠av一区二区三区| 奇米888四色在线精品| 国产色爱av资源综合区| 在线免费不卡视频| 一区二区高清视频在线观看| 日韩一区二区在线观看| eeuss鲁片一区二区三区| 亚洲高清免费观看高清完整版在线观看 | 欧美一区二区人人喊爽| 国产成都精品91一区二区三| 亚洲成人第一页| 51精品国自产在线| 成+人+亚洲+综合天堂| 中文字幕亚洲视频| 欧美一二三四在线| 不卡av免费在线观看| 日本成人在线视频网站| 亚洲男人的天堂av| 欧美日韩欧美一区二区| 丁香婷婷综合激情五月色| 日本aⅴ免费视频一区二区三区| 国产精品久久久一本精品| 成人精品视频一区二区三区 | 韩国精品主播一区二区在线观看| 亚洲男人电影天堂| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 色婷婷激情综合| 国产夫妻精品视频| 久久丁香综合五月国产三级网站| 亚洲丝袜另类动漫二区| 国产亚洲精品免费| 精品av久久707| 欧美一级二级在线观看| 7777精品伊人久久久大香线蕉经典版下载 | 亚洲视频一区二区免费在线观看| 日韩欧美中文字幕一区| 欧美电影一区二区三区| 欧美在线影院一区二区| 一道本成人在线| 91在线视频官网| k8久久久一区二区三区| 成人激情av网| av在线综合网| 91伊人久久大香线蕉| 99久久综合精品| a级高清视频欧美日韩| av不卡一区二区三区| 91在线视频官网| 色呦呦一区二区三区| 欧美影院一区二区三区| 91成人国产精品| 欧美日韩和欧美的一区二区| 国产资源在线一区| 韩国三级在线一区| 国产精品18久久久久久vr| 国产精品夜夜爽| 成人动漫一区二区| 99国产精品久久久久久久久久| 成人午夜视频网站| 色综合中文字幕国产 | 亚洲私人黄色宅男| 亚洲麻豆国产自偷在线| 亚洲最新在线观看| 日本欧美在线观看| 国产精品69毛片高清亚洲| 成人午夜伦理影院| 色偷偷久久一区二区三区| 欧美日韩在线播放三区四区| 欧美一级在线免费| 中文字幕高清一区| 一区二区三区精品在线观看| 日韩激情视频在线观看| 久久精品国产精品青草| 成人激情黄色小说| 欧美日本不卡视频| 久久九九全国免费| 一区二区三区国产| 久久国内精品视频| 色视频成人在线观看免| 91精品国产高清一区二区三区 | 56国语精品自产拍在线观看| 精品国产一区二区三区四区四| 国产精品人成在线观看免费| 亚洲午夜三级在线| 国产精品一区二区三区四区 | 日韩一区二区三区免费观看| 国产亚洲精品超碰| 亚洲综合色丁香婷婷六月图片| 久久成人免费日本黄色| 99久久er热在这里只有精品66| 亚洲视频一二三| 老司机免费视频一区二区三区| 97精品电影院| 精品国产乱码久久久久久久久| 又紧又大又爽精品一区二区| 久久91精品国产91久久小草| 午夜日韩在线电影| 粉嫩aⅴ一区二区三区四区五区| 欧美精品色综合| 亚洲人精品一区| 久久66热偷产精品| 欧美日韩国产精品成人| 国产精品乱人伦| 精品亚洲porn| 精品视频免费在线| 亚洲青青青在线视频| 国产成人在线网站| 911精品国产一区二区在线| 一区精品在线播放| 国产成人自拍在线| 日韩一区二区在线观看视频播放| 一区二区三区四区激情| 丁香婷婷综合激情五月色| 精品美女被调教视频大全网站| 国产性天天综合网| 麻豆国产一区二区| 911精品国产一区二区在线| 亚洲精品va在线观看| 东方欧美亚洲色图在线| 欧美精品一区二| 亚洲成人av电影在线| 欧美在线高清视频| 一区二区三区美女视频| 日本精品裸体写真集在线观看| 中文字幕av一区二区三区高| 国产成人福利片| 欧美国产一区在线| 成人精品一区二区三区中文字幕| 久久蜜臀精品av| 国产成人av电影| 中文av字幕一区| 北岛玲一区二区三区四区| 国产精品久久看|