packages feed

HSvm 0.1.1.3.22 → 0.1.1.3.25

raw patch · 3 files changed

+17/−25 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

HSvm.cabal view
@@ -1,5 +1,5 @@ Name:               HSvm-Version:            0.1.1.3.22+Version:            0.1.1.3.25 Copyright:          (c) 2009 Paolo Losi, 2017 Pavel Ryzhov Maintainer:         Pavel Ryzhov <paul@paulrz.cz> License:            BSD3@@ -9,14 +9,16 @@ Synopsis:           Haskell Bindings for libsvm Stability:          provisional Build-Type:         Simple-Cabal-Version:      >= 1.6+Cabal-Version:      >= 1.10 Extra-Source-Files: cbits/svm.cpp cbits/svm.h+Description:        The library embeds libsvm and provides a type-safe interface into SVM models.  source-repository head   type:             git   location:         https://github.com/paulrzcz/HSvm.git  Library+  Default-language: Haskell2010   Build-Depends:    base >= 4 && < 5                   , containers   Exposed-modules:  Data.SVM
cbits/svm.cpp view
@@ -332,12 +332,6 @@ 			return powi(param.gamma*dot(x,y)+param.coef0,param.degree); 		case RBF: 		{-			// printf("x: ");-			// print_node(x);-			// printf("y: ");-			// print_node(y);-			//-			// printf("k_function - rbf: "); 			double sum = 0; 			while(x->index != -1 && y->index !=-1) 			{@@ -375,8 +369,6 @@ 				++y; 			} -			// printf(" sum=%g\n", sum);- 			return exp(-param.gamma*sum); 		} 		case SIGMOID:@@ -2526,14 +2518,11 @@ 	{ 		double *sv_coef = model->sv_coef[0]; 		double sum = 0;-		for(i=0;i<model->l;i++) {+		for(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 = sum; -		printf("%g\n", sum);- 		if(model->param.svm_type == ONE_CLASS) 			return (sum>0)?1:-1; 		else@@ -2598,7 +2587,6 @@  double svm_predict(const svm_model *model, const svm_node *x) {-	// print_node(x); 	int nr_class = model->nr_class; 	double *dec_values; 	if(model->param.svm_type == ONE_CLASS ||@@ -2687,10 +2675,10 @@ 		fprintf(fp,"degree %d\n", param.degree);  	if(param.kernel_type == POLY || param.kernel_type == RBF || param.kernel_type == SIGMOID)-		fprintf(fp,"gamma %g\n", param.gamma);+		fprintf(fp,"gamma %.17g\n", param.gamma);  	if(param.kernel_type == POLY || param.kernel_type == SIGMOID)-		fprintf(fp,"coef0 %g\n", param.coef0);+		fprintf(fp,"coef0 %.17g\n", param.coef0);  	int nr_class = model->nr_class; 	int l = model->l;@@ -2700,7 +2688,7 @@ 	{ 		fprintf(fp, "rho"); 		for(int i=0;i<nr_class*(nr_class-1)/2;i++)-			fprintf(fp," %g",model->rho[i]);+			fprintf(fp," %.17g",model->rho[i]); 		fprintf(fp, "\n"); 	} @@ -2716,14 +2704,14 @@ 	{ 		fprintf(fp, "probA"); 		for(int i=0;i<nr_class*(nr_class-1)/2;i++)-			fprintf(fp," %g",model->probA[i]);+			fprintf(fp," %.17g",model->probA[i]); 		fprintf(fp, "\n"); 	} 	if(model->probB) 	{ 		fprintf(fp, "probB"); 		for(int i=0;i<nr_class*(nr_class-1)/2;i++)-			fprintf(fp," %g",model->probB[i]);+			fprintf(fp," %.17g",model->probB[i]); 		fprintf(fp, "\n"); 	} @@ -2742,7 +2730,7 @@ 	for(int i=0;i<l;i++) 	{ 		for(int j=0;j<nr_class-1;j++)-			fprintf(fp, "%.16g ",sv_coef[j][i]);+			fprintf(fp, "%.17g ",sv_coef[j][i]);  		const svm_node *p = SV[i]; @@ -2761,7 +2749,7 @@ 	free(old_locale);  	if (ferror(fp) != 0 || fclose(fp) != 0) return -1;-		else return 0;+	else return 0; }  static char *line = NULL;@@ -3097,10 +3085,11 @@ 	   kernel_type != PRECOMPUTED) 		return "unknown kernel type"; -	if(param->gamma < 0)+	if((kernel_type == POLY || kernel_type == RBF || kernel_type == SIGMOID) &&+	   param->gamma < 0) 		return "gamma < 0"; -	if(param->degree < 0)+	if(kernel_type == POLY && param->degree < 0) 		return "degree of polynomial kernel < 0";  	// cache_size,eps,C,nu,p,shrinking
cbits/svm.h view
@@ -1,7 +1,7 @@ #ifndef _LIBSVM_H #define _LIBSVM_H -#define LIBSVM_VERSION 322+#define LIBSVM_VERSION 325  #ifdef __cplusplus extern "C" {@@ -100,6 +100,7 @@  // added by HSvm int clone_model_support_vectors(struct svm_model *model);+  #ifdef __cplusplus }