• 大小: 54KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-09
  • 语言: C/C++
  • 标签: C语言  

资源简介

纯C语言实现的支持向量机程序,很不错的参考程序

资源截图

代码片段和文件信息

/***********************************************************************/
/*                                                                     */
/*   svm_classify.c                                                    */
/*                                                                     */
/*   Classification module of Support Vector Machine.                  */
/*                                                                     */
/*   Author: Thorsten Joachims                                         */
/*   Date: 02.07.02                                                    */
/*                                                                     */
/*   Copyright (c) 2002  Thorsten Joachims - All rights reserved       */
/*                                                                     */
/*   This software is available for non-commercial use only. It must   */
/*   not be modified and distributed without prior permission of the   */
/*   author. The author is not responsible for implications from the   */
/*   use of this software.                                             */
/*                                                                     */
/************************************************************************/

# include “svm_common.h“

char docfile[200];
char modelfile[200];
char predictionsfile[200];

void read_input_parameters(int char ** char * char * char * long * 
   long *);
void print_help(void);


int main (int argc char* argv[])
{
  DOC *doc;   /* test example */
  WORD *words;
  long max_docsmax_words_doclld;
  long totdoc=0queryidslackid;
  long correct=0incorrect=0no_accuracy=0;
  long res_a=0res_b=0res_c=0res_d=0wnumpred_format;
  long j;
  double t1runtime=0;
  double distdoc_labelcostfactor;
  char *line*comment; 
  FILE *predfl*docfl;
  MODEL *model; 

  read_input_parameters(argcargvdocfilemodelfilepredictionsfile
&verbosity&pred_format);

  nol_ll(docfile&max_docs&max_words_doc&lld); /* scan size of input file */
  max_words_doc+=2;
  lld+=2;

  line = (char *)my_malloc(sizeof(char)*lld);
  words = (WORD *)my_malloc(sizeof(WORD)*(max_words_doc+10));

  model=read_model(modelfile);

  if(model->kernel_parm.kernel_type == 0) { /* linear kernel */
    /* compute weight vector */
    add_weight_vector_to_linear_model(model);
  }
  
  if(verbosity>=2) {
    printf(“Classifying test examples..“); fflush(stdout);
  }

  if ((docfl = fopen (docfile “r“)) == NULL)
  { perror (docfile); exit (1); }
  if ((predfl = fopen (predictionsfile “w“)) == NULL)
  { perror (predictionsfile); exit (1); }

  while((!feof(docfl)) && fgets(line(int)llddocfl)) {
    if(line[0] == ‘#‘) continue;  /* line contains comments */
    parse_document(linewords&doc_label&queryid&slackid&costfactor&wnum
   max_words_doc&comment);
    totdoc++;
    if(model->kernel_parm.kernel_type == 0) {   /* linear kernel */

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1999  2004-05-15 00:48  支持向量机的C语言程序源码\Ssvmm_lighht3V\svm_light\kernel.h

     文件       2195  2004-05-15 00:48  支持向量机的C语言程序源码\Ssvmm_lighht3V\svm_light\LICENSE.txt

     文件       2665  2004-08-04 04:47  支持向量机的C语言程序源码\Ssvmm_lighht3V\svm_light\Makefile

     文件       7102  2004-07-15 02:50  支持向量机的C语言程序源码\Ssvmm_lighht3V\svm_light\svm_classify.c

     文件      25471  2004-08-07 05:41  支持向量机的C语言程序源码\Ssvmm_lighht3V\svm_light\svm_common.c

     文件      12832  2004-07-16 22:29  支持向量机的C语言程序源码\Ssvmm_lighht3V\svm_light\svm_common.h

     文件      27790  2004-06-02 18:22  支持向量机的C语言程序源码\Ssvmm_lighht3V\svm_light\svm_hideo.c

     文件     135816  2004-07-17 10:51  支持向量机的C语言程序源码\Ssvmm_lighht3V\svm_light\svm_learn.c

     文件       8580  2004-07-16 23:38  支持向量机的C语言程序源码\Ssvmm_lighht3V\svm_light\svm_learn.h

     文件      17691  2004-07-25 15:44  支持向量机的C语言程序源码\Ssvmm_lighht3V\svm_light\svm_learn_main.c

     文件       7124  2004-07-15 05:45  支持向量机的C语言程序源码\Ssvmm_lighht3V\svm_light\svm_loqo.c

    ..AD...         0  2005-03-28 20:22  支持向量机的C语言程序源码\Ssvmm_lighht3V\svm_light

     目录          0  2012-03-18 11:44  支持向量机的C语言程序源码\Ssvmm_lighht3V

     目录          0  2012-10-08 15:45  支持向量机的C语言程序源码

----------- ---------  ---------- -----  ----

               249265                    14


评论

共有 条评论