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

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

?? svm.java

?? 支撐向量機庫文件
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:
					}				model.nSV[i] = nSV;				nz_count[i] = nSV;			}					System.out.print("Total nSV = "+nnz+"\n");			model.l = nnz;			model.SV = new svm_node[nnz][];			p = 0;			for(i=0;i<l;i++)				if(nonzero[i]) model.SV[p++] = x[i];			int[] nz_start = new int[nr_class];			nz_start[0] = 0;			for(i=1;i<nr_class;i++)				nz_start[i] = nz_start[i-1]+nz_count[i-1];			model.sv_coef = new double[nr_class-1][];			for(i=0;i<nr_class-1;i++)				model.sv_coef[i] = new double[nnz];			p = 0;			for(i=0;i<nr_class;i++)				for(int j=i+1;j<nr_class;j++)				{					// classifier (i,j): coefficients with					// i are in sv_coef[j-1][nz_start[i]...],					// j are in sv_coef[i][nz_start[j]...]					int si = start[i];					int sj = start[j];					int ci = count[i];					int cj = count[j];									int q = nz_start[i];					int k;					for(k=0;k<ci;k++)						if(nonzero[si+k])							model.sv_coef[j-1][q++] = f[p].alpha[k];					q = nz_start[j];					for(k=0;k<cj;k++)						if(nonzero[sj+k])							model.sv_coef[i][q++] = f[p].alpha[ci+k];					++p;				}		}		return model;	}	public static void svm_cross_validation(svm_problem prob, svm_parameter param, int nr_fold, double[] target)	{		int i;		int[] perm = new int[prob.l];				// random shuffle		for(i=0;i<prob.l;i++) perm[i]=i;		for(i=0;i<prob.l;i++)		{			int j = i+(int)(Math.random()*(prob.l-i));			do {int _=perm[i]; perm[i]=perm[j]; perm[j]=_;} while(false);		}		for(i=0;i<nr_fold;i++)		{			int begin = i*prob.l/nr_fold;			int end = (i+1)*prob.l/nr_fold;			int j,k;			svm_problem subprob = new svm_problem();			subprob.l = prob.l-(end-begin);			subprob.x = new svm_node[subprob.l][];			subprob.y = new double[subprob.l];			k=0;			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<prob.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;			int pos=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[pos++] = sum;									}		}	}	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",	};	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];			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 = atof(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\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			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)		return "unknown kernel type";		// 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一区二区三区免费野_久草精品视频
色综合色狠狠综合色| 青青草成人在线观看| 成人黄色av电影| 国产情人综合久久777777| 高清成人在线观看| 中文字幕制服丝袜成人av| 91小视频在线免费看| 亚洲一区中文日韩| 欧美久久一区二区| 蜜臀a∨国产成人精品| 精品福利一区二区三区| 国产激情一区二区三区四区| 国产欧美精品在线观看| 色哟哟精品一区| 午夜视频在线观看一区二区| 日韩欧美一级片| 国产成人av电影免费在线观看| 中文字幕在线观看一区| 欧美三级韩国三级日本一级| 黄一区二区三区| 亚洲国产岛国毛片在线| 欧美色图12p| 韩国视频一区二区| 亚洲免费色视频| 91精品国产高清一区二区三区蜜臀| 国产在线国偷精品产拍免费yy| 中文字幕巨乱亚洲| 欧美午夜免费电影| 国产一区二区成人久久免费影院| |精品福利一区二区三区| 欧美精品久久99久久在免费线 | 国产福利91精品一区| 中文字幕亚洲成人| 日韩精品一区二区三区视频播放| 不卡一卡二卡三乱码免费网站| 午夜精品福利视频网站| 国产色综合久久| 欧美日韩夫妻久久| 成人亚洲一区二区一| 日韩精品视频网站| 国产精品污网站| 欧美一区二区成人6969| 色婷婷国产精品综合在线观看| 久久精品理论片| 一区二区在线观看av| 久久视频一区二区| 欧美日韩高清在线| 色综合久久综合网欧美综合网| 日本一不卡视频| 亚洲欧美日韩久久| 国产999精品久久久久久绿帽| 日韩成人精品在线| 99视频一区二区三区| 亚洲777理论| 中文字幕制服丝袜一区二区三区| 欧美大片一区二区| 精品婷婷伊人一区三区三| av激情综合网| 国产一区视频导航| 日韩电影网1区2区| 亚洲激情中文1区| 国产精品乱码人人做人人爱| 久久久久国产免费免费 | 乱中年女人伦av一区二区| 亚洲精品国久久99热| 国产精品丝袜91| 国产欧美久久久精品影院| 精品sm在线观看| 日韩欧美一级在线播放| 日韩区在线观看| 91精品在线免费| 欧美酷刑日本凌虐凌虐| 欧美色偷偷大香| 欧美三级欧美一级| 欧美日韩卡一卡二| 欧美成人一区二区三区片免费| 日韩一区二区免费电影| 欧美日韩性生活| 欧美性色黄大片手机版| 日本精品视频一区二区三区| 91在线精品一区二区| 99久久er热在这里只有精品66| 国产成人免费视频网站高清观看视频| 国产综合色在线| 韩国av一区二区| 国产成人亚洲精品青草天美| 国产不卡视频一区二区三区| 成人av在线网| 色呦呦国产精品| 在线看日本不卡| 欧美日韩视频在线第一区| 欧美二区三区91| 欧美一区二区三区视频免费| 精品美女一区二区三区| 久久综合久久综合久久| 中文av字幕一区| 亚洲三级久久久| 亚洲国产毛片aaaaa无费看| 亚洲成a人片综合在线| 日本aⅴ免费视频一区二区三区| 蜜臀久久99精品久久久久宅男| 欧美精品一区二区不卡| 97精品久久久久中文字幕| 亚洲图片有声小说| 亚洲电影在线播放| 日本色综合中文字幕| 国产在线不卡一区| 国产成人啪免费观看软件| 99re成人在线| 欧美一区二区三区免费观看视频 | 日韩一区二区精品葵司在线| 欧美精品一区二区精品网| ●精品国产综合乱码久久久久| 亚洲成人你懂的| 激情综合色综合久久综合| 成人91在线观看| 4438成人网| 中文字幕精品三区| 亚洲国产aⅴ成人精品无吗| 久88久久88久久久| 91啪在线观看| 精品国产免费一区二区三区四区 | 一区二区三区精密机械公司| 国产人久久人人人人爽| 亚洲人xxxx| 精彩视频一区二区三区| 91麻豆国产精品久久| 精品国产免费一区二区三区四区 | 91精品国产色综合久久不卡蜜臀| 久久嫩草精品久久久久| 亚洲自拍都市欧美小说| 久久超碰97中文字幕| 色香蕉成人二区免费| 精品999久久久| 亚洲午夜久久久久久久久久久 | 91精品综合久久久久久| 国产精品动漫网站| 精品在线免费观看| 色哟哟在线观看一区二区三区| 久久综合九色欧美综合狠狠| 亚洲国产精品人人做人人爽| 国产成人av一区二区三区在线| 欧美色视频在线| 欧美激情资源网| 麻豆国产精品视频| 欧美日韩国产三级| 亚洲天堂成人在线观看| 国产999精品久久| 精品人伦一区二区色婷婷| 天天亚洲美女在线视频| 色美美综合视频| 亚洲欧美影音先锋| 丰满白嫩尤物一区二区| 日韩亚洲欧美成人一区| 性久久久久久久| 欧美主播一区二区三区| 中文字幕av资源一区| 国产一区二区主播在线| 日韩区在线观看| 男人操女人的视频在线观看欧美| 欧美日韩一级片在线观看| 亚洲一区在线电影| 99精品国产视频| 国产精品久久久久精k8| 成人h动漫精品| 18涩涩午夜精品.www| 不卡视频在线看| 亚洲色图一区二区| 色婷婷久久久综合中文字幕| 亚洲精品你懂的| 欧美色综合天天久久综合精品| 一区二区三区免费网站| 日本韩国一区二区| 一区二区三区精品视频| 欧美日韩一区在线观看| 日韩精品成人一区二区三区| 欧美一区二区三区免费大片| 日韩中文字幕一区二区三区| 8v天堂国产在线一区二区| 日韩avvvv在线播放| 精品第一国产综合精品aⅴ| 国产一区二区影院| 欧美激情一区二区| 91麻豆国产自产在线观看| 亚洲国产中文字幕| 91精品福利在线一区二区三区| 看片的网站亚洲| 国产亚洲自拍一区| 99国产精品国产精品久久| 一区二区三区四区不卡在线 | 5566中文字幕一区二区电影| 日韩精品乱码免费| 久久一区二区三区国产精品| 99综合电影在线视频| 亚洲一卡二卡三卡四卡五卡| 91精品国产色综合久久不卡蜜臀| 麻豆91精品91久久久的内涵| 久久久久久久av麻豆果冻| 国产 日韩 欧美大片| 亚洲男帅同性gay1069|