⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 corrupt-main.c

📁 Ripper 分类算法
💻 C
字号:
/***************************************************************************** * corrupt-main.c --- main routine to add class noise to a dataset ****************************************************************************/#include <stdio.h>#include "ripper.h"#include "mdb.h"#include "protos.h"/******************************************************************************/char *Program="corrupt";char *Help_str[] = {    "syntax: corrupt [options] [stem]",    "   adds class noise to data",         "",    "options are:",    "  -s:       read from stdin (not stem.data)",    "  -p#:      class noise rate in pct (default 20)",      "  -R:       randomize operation",    NULL};main(argc,argv)int argc;char *argv[];{    int i,j;    example_t *exi;    int o;     vec_t *data;    char *stem;    int use_stdin;    int pct;    double frac;        pct = 20;    while ((o=getopt(argc,argv,"stp:Rh"))!=EOF) {	switch (o) {	  case 'R':	    randomize();	    break;	  case 's':	    use_stdin = TRUE;	    break;	  case 'p':	    frac = atof(optarg);	    if (frac<1.0 && frac>0.0) pct = 100*frac;	    else pct=frac;	    break;	  case 'h':	  case '?':	  default: 	    give_help();	    if (o=='h') exit(0);	    else fatal("option not implemented");	}    }    if (optind<argc) {	stem = argv[optind++];	ld_names(add_ext(stem,".names"));	if (use_stdin) data = ld_data(NULL);	else data = ld_data(add_ext(stem,".data"));    } else {	/* no stem */	stem = "stdin";	data = ld_data(NULL);    }    if (data==NULL || vmax(data)==0) fatal("no data!");    if (optind<argc) {	warning("not all arguments were used: %s ...",argv[optind]);    }    if (pct<0 || pct>=100) {	fatal("p must be between 0 and 100");    }    for (i=0; i<vmax(data); i++) {	exi = vref(example_t,data,i); 		if (random()%100 < pct) {	    j = random()%vmax(Classes);	    exi->lab.nom = vref(atom_t,Classes,j)->nom;	}    }    fprint_data(stdout,data);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -