zoukankan      html  css  js  c++  java
  • libsvm 接口 [供自己的C/C++程序训练预测用]

    #pragma once
    /*
     * lp_svm.h : a svm class use libSVM to train and predict data.
     */
    #include <cstdio>
    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    #include <vector>
    #include <iterator>
    #include <math.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <float.h>
    #include <string.h>
    #include <stdarg.h>
    #include <limits.h>
    #include <locale.h>
    #include <errno.h>
    #include "/home/lvpeng/src/lpinclude/svm/svm.h"
    using namespace std;
    
    #define Malloc(type,n) (type *)malloc((n)*sizeof(type))
    
    /*
     * Class: lpCSVM
     * Func: read & predict & train data
     * Author: Peng Lv
     * Data: 12/04/2012
     */
    class lpCSVM{
    public:
    	struct svm_parameter m_param;
    	struct svm_problem m_prob;
    	struct svm_model *m_model;
    	struct svm_node *m_xSpace;
    
    	int m_crossValid;
    	int m_nrFold;
    	int m_dim;
    
    	char* line;
    	int max_line_len;
    	int max_nr_attr;
    	int m_predict_probability;
    public:
    	lpCSVM(){};
    	~lpCSVM();
    
    	char* readLine(FILE *);
    
    	/////////////////////////////////
    	//   interface functions 
    	/////////////////////////////////
    	void initSVM();
    	void readProblem(const char*);
    	void trainModel(char* input, char * output);
    	int loadModel(char* );
    	void predictFile(FILE* , FILE* );
    	double predictX(vector<double>& );
    };
    
  • 相关阅读:
    爬取数据问题
    b站评论区爬取
    词云图制作
    情感分析
    一个progressbar widget
    jQuery ui effects
    在使用jQuery的时候不小心的内存泄漏
    在javascript中实现类似asp.net webcontrol中的render的方法
    jQuery 1.7的隐藏改动
    jQuery编写widget的一些窍门
  • 原文地址:https://www.cnblogs.com/lvpengms/p/2446608.html
Copyright © 2011-2022 走看看