资源简介
SVM本身是一个二值分类器,SVM算法最初是为二值分类问题设计的,当处理多类问题时,就需要构造合适的多类分类器。此安装包可以直接调用。
代码片段和文件信息
#include
#include
#include
#include
#include
#include “svm.h“
int print_null(const char *s...) {return 0;}
static int (*info)(const char *fmt...) = &printf;
struct svm_node *x;
int max_nr_attr = 64;
struct svm_model* model;
int predict_probability=0;
static char *line = NULL;
static int max_line_len;
static char* readline(FILE *input)
{
int len;
if(fgets(linemax_line_leninput) == NULL)
return NULL;
while(strrchr(line‘\n‘) == NULL)
{
max_line_len *= 2;
line = (char *) realloc(linemax_line_len);
len = (int) strlen(line);
if(fgets(line+lenmax_line_len-leninput) == NULL)
break;
}
return line;
}
void exit_input_error(int line_num)
{
fprintf(stderr“Wrong input format at line %d\n“ line_num);
exit(1);
}
void predict(FILE *input FILE *output)
{
int correct = 0;
int total = 0;
double error = 0;
double sump = 0 sumt = 0 sumpp = 0 sumtt = 0 sumpt = 0;
int svm_type=svm_get_svm_type(model);
int nr_class=svm_get_nr_class(model);
double *prob_estimates=NULL;
int j;
if(predict_probability)
{
if (svm_type==NU_SVR || svm_type==EPSILON_SVR)
info(“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
{
int *labels=(int *) malloc(nr_class*sizeof(int));
svm_get_labels(modellabels);
prob_estimates = (double *) malloc(nr_class*sizeof(double));
fprintf(output“labels“);
for(j=0;j fprintf(output“ %d“labels[j]);
fprintf(output“\n“);
free(labels);
}
}
max_line_len = 1024;
line = (char *)malloc(max_line_len*sizeof(char));
while(readline(input) != NULL)
{
int i = 0;
double target_label predict_label;
char *idx *val *label *endptr;
int inst_max_index = -1; // strtol gives 0 if wrong format and precomputed kernel has start from 0
label = strtok(line“ \t\n“);
if(label == NULL) // empty line
exit_input_error(total+1);
target_label = strtod(label&endptr);
if(endptr == label || *endptr != ‘\0‘)
exit_input_error(total+1);
while(1)
{
if(i>=max_nr_attr-1) // need one more for index = -1
{
max_nr_attr *= 2;
x = (struct svm_node *) realloc(xmax_nr_attr*sizeof(struct svm_node));
}
idx = strtok(NULL“:“);
val = strtok(NULL“ \t“);
if(val == NULL)
break;
errno = 0;
x[i].index = (int) strtol(idx&endptr10);
if(endptr == idx || errno != 0 || *endptr != ‘\0‘ || x[i].index <= inst_max_index)
exit_input_error(total+1);
else
inst_max_index = x[i].index;
errno = 0;
x[i].value = strtod(val&endptr);
if(endptr == val || errno != 0 || (*endptr != ‘\0‘ && !isspace(*endptr)))
exit_input_error(total+1);
++i;
}
x[i].index = -1;
if (predict_probability && (svm_type==C_SVC || svm_type==NU_SVC))
{
predict_label = svm_predict_probability(modelxprob_estimates);
fprintf(output“%g“predict_label);
for(j
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1497 2018-07-15 22:16 libsvm-3.21\COPYRIGHT
文件 83238 2018-07-15 22:16 libsvm-3.21\FAQ.html
文件 27670 2018-07-15 22:16 libsvm-3.21\heart_scale
目录 0 2018-11-27 16:06 libsvm-3.21\java\
文件 55181 2018-07-15 22:17 libsvm-3.21\java\libsvm.jar
目录 0 2018-11-27 16:06 libsvm-3.21\java\libsvm\
文件 64084 2018-07-15 22:17 libsvm-3.21\java\libsvm\svm.java
文件 63281 2018-07-15 22:16 libsvm-3.21\java\libsvm\svm.m4
文件 868 2018-07-15 22:16 libsvm-3.21\java\libsvm\svm_model.java
文件 115 2018-07-15 22:16 libsvm-3.21\java\libsvm\svm_node.java
文件 1285 2018-07-15 22:16 libsvm-3.21\java\libsvm\svm_parameter.java
文件 87 2018-07-15 22:16 libsvm-3.21\java\libsvm\svm_print_interface.java
文件 136 2018-07-15 22:16 libsvm-3.21\java\libsvm\svm_problem.java
文件 659 2018-07-15 22:16 libsvm-3.21\java\Makefile
文件 4945 2018-07-15 22:16 libsvm-3.21\java\svm_predict.java
文件 8937 2018-07-15 22:16 libsvm-3.21\java\svm_scale.java
文件 12262 2018-07-15 22:16 libsvm-3.21\java\svm_toy.java
文件 8354 2018-07-15 22:16 libsvm-3.21\java\svm_train.java
文件 81 2018-07-15 22:16 libsvm-3.21\java\test_ap
文件 732 2018-07-15 22:16 libsvm-3.21\Makefile
文件 1135 2018-07-15 22:16 libsvm-3.21\Makefile.win
目录 0 2018-11-27 16:06 libsvm-3.21\matlab\
文件 4060 2018-07-15 22:16 libsvm-3.21\matlab\libsvmread.c
文件 2326 2018-07-15 22:16 libsvm-3.21\matlab\libsvmwrite.c
文件 888 2018-07-15 22:16 libsvm-3.21\matlab\make.m
文件 1240 2018-07-15 22:16 libsvm-3.21\matlab\Makefile
文件 9815 2018-07-15 22:16 libsvm-3.21\matlab\README
文件 8196 2018-07-15 22:16 libsvm-3.21\matlab\svm_model_matlab.c
文件 201 2018-07-15 22:16 libsvm-3.21\matlab\svm_model_matlab.h
文件 9818 2018-07-15 22:16 libsvm-3.21\matlab\svmpredict.c
文件 11817 2018-07-15 22:16 libsvm-3.21\matlab\svmtrain.c
............此处省略35个文件信息
相关资源
- 距离矢量算法Distance Vector Algorithm的动
- 支持向量数据描述Support Vector Data De
- vectorMapDemo挺好看的地图(各个省不同
- vector实现矩阵运算
- GoogleNews-vectors-negative300.bin 压缩包2/
- GoogleNews-vectors-negative300.bin 压缩包1/
- A Tutorial on Support Vector Machines for Patt
- NGSIM 数据集NGSIM__Vehicle_Trajectories_and
- zw_vectshapes_src.zip
-
解决The type org.springfr
amework.dao.supp - DBC 文件格式
- Qt读取txt文件的内容,保存到数组,并
- GBK Encoding Support
- support vector networks中文翻译
- LitJson for unity
- chrome etBrains IDE Support
- Vectorcontrolinductionmotor.rar
- Fisher Vector
-
em
bedded Coder Support Package for Texas In - Chrome插件jetbrainsidesupport207.zip
- Effect of photocatalysis on Fischer-Tropsch sy
- Nonlinear Separation and Optimality Conditions
- Computer supported cooperative work and shared
- The Inner Workings - of - word2vec :一文搞懂
- Finite-Dimensional Vector Spaces - P. Halmos (
- WEEE 垃圾桶标志 矢量图
- iOS11.2 DeviceSupport
- VECTOR公司的AUTOSAR入门资料,非常经典
- teamviewer quicksupport HUAWEI等各类插件
- QuickSupport 插件 QS Add-On Huawei(安卓7
评论
共有 条评论