亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? example_set.cpp

?? svm算法的實現分類技術
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
#include "stdafx.h"
#include "example_set.h"example_set_c::example_set_c(){  init(0,0);};example_set_c::example_set_c(SVMINT new_total, SVMINT new_dim){  init(new_total,new_dim);};void example_set_c::init(SVMINT new_total, SVMINT new_dim){  examples_total = 0;  capacity=0;  has_y = 0;  has_alphas = 0;  has_scale = 0;  has_pattern_y = 1;  b = 0;  all_alphas = 0;  all_ys = 0;  // create dummy  the_set = new svm_example[1];  the_set[0].example = 0;  dim=0;  Exp = 0;  Var = 0;  filename = new char[MAXCHAR];  filename[0]='\0';  set_dim(new_dim),  resize(capacity);  // set default file format  my_format.sparse = 0;  my_format.where_x = 2;  my_format.where_y = 1;  my_format.where_alpha = 0;  my_format.delimiter = ' ';}; example_set_c::~example_set_c(){  delete []filename;  clear();  if(the_set) delete []the_set;};void example_set_c::set_format(example_format new_format){  my_format = new_format;};void example_set_c::set_filename(char* new_filename){  strcpy(filename,new_filename);}; void example_set_c::clear(){  if(all_alphas){    delete []all_alphas;    all_alphas=0;  };  if(all_ys){    delete []all_ys;    all_ys=0;  };  if(the_set){    SVMINT i;    SVMINT c;    for(i=0;i<capacity;i++){      if(the_set[i].example != 0){	for(c=0;c<the_set[i].length;c++){	  (((the_set[i]).example)[c]).index=28;	  (((the_set[i]).example)[c]).att = 4;	};	delete [](the_set[i].example); 	the_set[i].example=0;      };    };    delete []the_set;  };  if(Exp) delete []Exp;  if(Var) delete []Var;  Exp = 0;  Var = 0;  the_set = new svm_example[1];  the_set[0].example = 0;  dim = 0;  b = 0;  examples_total = 0;  capacity = 0;  has_y = 0;  has_alphas = 0;  has_scale = 0;};  SVMINT example_set_c::size(){  return examples_total;};SVMINT example_set_c::size_pos(){  SVMINT i;  SVMINT count=0;  for(i=0;i<capacity;i++){    if(the_set[i].y > 0){      count++;    };  };  return count;};SVMINT example_set_c::size_neg(){  SVMINT i;  SVMINT count=0;  for(i=0;i<capacity;i++){    if(the_set[i].y < 0){      count++;    };  };  return count;};void example_set_c::set_dim(SVMINT new_dim){  if(new_dim<dim){    throw general_exception("ERROR: Trying to decrease dimension of examples");  };                                                                              dim = new_dim;  if(Exp) delete []Exp;  if(Var) delete []Var;  Exp = 0;  Var = 0;};SVMINT example_set_c::get_dim(){  return dim;};void example_set_c::resize(SVMINT new_total){  svm_example* new_set = 0;  SVMINT i;  if(new_total > capacity){    // add new space to set    new_set = new svm_example[new_total];    // copy old values    for(i=0;i<capacity;i++){      new_set[i] = the_set[i];    };    for(i=capacity;i<new_total;i++){      new_set[i].example = 0;      new_set[i].length = 0;    };    delete []the_set;    the_set=new_set;    capacity = new_total;    if(all_alphas != 0){      delete []all_alphas;      all_alphas = 0;    };    if(all_ys != 0){      delete []all_ys;      all_ys = 0;    };  }  else if(new_total < capacity){    new_set = new svm_example[new_total];    // copy remaining values    for(i=0;i<new_total;i++){      new_set[i] = the_set[i];    };    // delete obsolete values    for(i=new_total;i<capacity;i++){      if(the_set[i].example != 0){	delete [](the_set[i].example); 	the_set[i].example = 0;	examples_total--;      };    };    delete []the_set;    the_set=new_set;    capacity = new_total;    if(all_alphas != 0){      delete []all_alphas;      all_alphas = 0;    };    if(all_ys != 0){      delete []all_ys;      all_ys = 0;    };  };};void example_set_c::swap(SVMINT i, SVMINT j){  svm_example ex_dummy;  SVMFLOAT dummy;  ex_dummy=the_set[i];  the_set[i] = the_set[j];  the_set[j] = ex_dummy;  if(all_alphas != 0){    dummy=all_alphas[i];    all_alphas[i] = all_alphas[j];    all_alphas[j] = dummy;  };  if(all_ys != 0){    dummy = all_ys[i];    all_ys[i] = all_ys[j];    all_ys[j] = dummy;  };};void example_set_c::put_example(const SVMINT pos, const SVMFLOAT* example){  // examples is SVMFLOAT-array 1..dim  SVMINT non_zero=0;  svm_attrib* new_att;  SVMINT i;  for(i=0;i<dim;i++){    if(0 != example[i]){      non_zero++;    };  };  if(pos>=capacity){    // make set bigger    resize(2*capacity+1);  };  if(0 == the_set[pos].example){    // add new example, reserve space for y and alpha    examples_total++;  }  else{    delete [](the_set[pos].example);    the_set[pos].example = 0;  };  new_att = new svm_attrib[non_zero];  the_set[pos].example = new_att;  // add attributes  SVMINT j=0;  for(i=0;i<non_zero;i++){    while(0 == example[j]) j++;    new_att[i].att = example[j];    new_att[i].index=j;    j++;  };  the_set[pos].y = example[dim];  the_set[pos].alpha = example[dim+1];  the_set[pos].length = non_zero;  if(all_alphas != 0){    all_alphas[pos] = the_set[pos].alpha;  };  if(all_ys != 0){    all_ys[pos]=the_set[pos].y;  };  if((the_set[pos].y != 1) && (the_set[pos].y != -1)){    has_pattern_y = 0;  };};void example_set_c::put_example(const SVMFLOAT* example){  put_example(examples_total,example);};void example_set_c::put_example(const SVMINT pos, const svm_example example){  if(pos>=capacity){    // make set bigger    resize(2*capacity+1);  };  if(the_set[pos].example != 0){    // overwrite old    delete [](the_set[pos].example);    the_set[pos].example = 0;  }  else{    examples_total++;  };  the_set[pos].length = example.length;  svm_attrib* new_att = new svm_attrib[example.length];  SVMINT i;  for(i=0;i<example.length;i++){    new_att[i] = example.example[i];  };  the_set[pos].example = new_att;  the_set[pos].y = example.y;  the_set[pos].alpha = example.alpha;  if(all_alphas != 0){    all_alphas[pos] = the_set[pos].alpha;  };  if(all_ys != 0){    all_ys[pos] = the_set[pos].y;  };  if((the_set[pos].y != 1) && (the_set[pos].y != -1)){    has_pattern_y = 0;  };};void example_set_c::put_example(const svm_example example){  put_example(examples_total,example);};svm_example example_set_c::get_example(const SVMINT pos){  return the_set[pos];};void example_set_c::put_y(const SVMINT pos, const SVMFLOAT y){  the_set[pos].y = y;  if(all_ys != 0){    all_ys[pos] = y;  };  if((y != 1) && (y != -1)){    has_pattern_y = 0;  };};SVMFLOAT example_set_c::get_y(const SVMINT pos){  return (the_set[pos].y);};void example_set_c::put_alpha(const SVMINT pos, const SVMFLOAT alpha){  the_set[pos].alpha = alpha;  if(all_alphas != 0){    all_alphas[pos] = alpha;  };};SVMFLOAT example_set_c::get_alpha(const SVMINT pos){  return (the_set[pos].alpha);};void example_set_c::put_b(const SVMFLOAT new_b){  b=new_b;};SVMFLOAT example_set_c::get_b(){  return b;};SVMFLOAT* example_set_c::get_alphas(){  if(0 == all_alphas){    SVMINT the_size = size();    all_alphas = new SVMFLOAT[the_size];    SVMINT i;    for(i=0; i<the_size; i++){      all_alphas[i] = get_alpha(i);    };  };  return all_alphas;};SVMFLOAT* example_set_c::get_ys(){  if(0 == all_ys){    SVMINT the_size = size();    all_ys = new SVMFLOAT[the_size];    SVMINT i;    for(i=0; i<the_size; i++){      all_ys[i] = get_y(i);    };  };  return all_ys;};void example_set_c::compress(){  // remove zeros out of examples  SVMINT next=0;  SVMINT i=0;  for(i=0;i<capacity;i++){    if(the_set[i].example != 0){      the_set[next] = the_set[i];      if(next != i){	the_set[i].example = 0;	the_set[i].length = 0;      };      next++;    };  };  resize(next);};void example_set_c::scale_alphas(const SVMFLOAT factor){  // set alpha -> factor*alpha  SVMINT i;  for(i=0;i<capacity;i++){    put_alpha(i,factor*get_alpha(i));  };  if(all_alphas){    for(i=0;i<capacity;i++){      all_alphas[i] = get_alpha(i);    };  };};SVMFLOAT example_set_c::get_y_var(){  if(0 != Var ){    if(0 != Var[dim]){      return  Var[dim];    };  };  return 1;};void example_set_c::scale(){  scale(1);};void example_set_c::scale(int scale_y){  if(examples_total == 0) return;  if(Exp == 0) Exp = new SVMFLOAT[dim+1];  if(Var == 0) Var = new SVMFLOAT[dim+1];  SVMINT i;  // calculate Exp and Var   for(i=0;i<=dim;i++){    Exp[i] = 0;    Var[i] = 0;  };  SVMINT pos;  svm_attrib the_att;  for(pos=0;pos<capacity;pos++){    for(i=0;i<the_set[pos].length;i++){      the_att = (the_set[pos].example)[i];      Exp[the_att.index] += the_att.att;      Var[the_att.index] += the_att.att*the_att.att;    };    Exp[dim] += the_set[pos].y;    Var[dim] += the_set[pos].y*the_set[pos].y;  };  for(i=0;i<=dim;i++){    Exp[i] /= examples_total;    Var[i] = (Var[i]-examples_total*Exp[i]*Exp[i])/(examples_total-1);    if(Var[i] > 0){      Var[i] = sqrt(Var[i]);    }    else{      // numerical error      Var[i] = 0;    };  };  if(! scale_y){    Exp[dim] = 0;    Var[dim] = 0;  };  do_scale();};void example_set_c::do_scale(){  // scale  // precondition: Exp and Var are set.  SVMINT i;  SVMINT j=0;  SVMINT k;  //  SVMINT length;  SVMINT nonzero=0;  SVMINT pos;  for(i=0;i<dim;i++){    if(Var[i] != 0) nonzero++;  };  for(pos=0;pos<capacity;pos++){    //    length = the_set[pos].length;    // put zeros into vector, they might be scaled, kick constant atts out    svm_attrib* new_example = new svm_attrib[nonzero];    j = 0; // index in new vector    k = 0; // index in old vector    i=0;    while((i<dim) && (j < nonzero)){      if((k < the_set[pos].length) && (((the_set[pos].example)[k]).index < i)){	k++;      };      if(Var[i] != 0){	new_example[j].index = i;	if(((the_set[pos].example)[k]).index == i){	  new_example[j].att = ((the_set[pos].example)[k]).att;	}	else{	  new_example[j].att = 0;	};	j++;      };      i++;    };        //    length = nonzero;    the_set[pos].length = nonzero;    delete []the_set[pos].example;    the_set[pos].example = new_example;    for(i=0;i<the_set[pos].length;i++){      j = ((the_set[pos].example)[i]).index;      if(0 != Var[j]){	((the_set[pos].example)[i]).att = (((the_set[pos].example)[i]).att - Exp[j])/Var[j];      }      else{	// shouldn't happen!	((the_set[pos].example)[i]).att = 0; //  x - Exp = 0      };    };    if(0 != Var[dim]){      the_set[pos].y = (the_set[pos].y-Exp[dim])/Var[dim];    }    else{      the_set[pos].y -= Exp[dim]; // don't know if to scale ys, so Exp could be 0 or y    };  };  has_scale = 1;};void example_set_c::put_Exp_Var(SVMFLOAT *newExp, SVMFLOAT* newVar){  // precondition: dim is ok  if((newExp == 0) || (newVar == 0)){ return; };  if(Exp==0) Exp = new SVMFLOAT[dim+1];  if(Var==0) Var = new SVMFLOAT[dim+1];  SVMINT i;  for(i=0;i<=dim;i++){    Exp[i] = newExp[i];    Var[i] = newVar[i];  };};void example_set_c::scale(SVMFLOAT *theconst, SVMFLOAT *thefactor,SVMINT scaledim){  if((theconst == 0) || (thefactor == 0)) return;  if(scaledim>dim) set_dim(scaledim);  if(Exp==0) Exp = new SVMFLOAT[dim+1];  if(Var==0) Var = new SVMFLOAT[dim+1];  SVMINT i;  for(i=0;i<scaledim;i++){    Exp[i] = theconst[i];    Var[i] = thefactor[i];  };  for(i=scaledim;i<dim;i++){    Exp[i] = 0;    Var[i] = 0;  };  Exp[dim] = theconst[scaledim];  Var[dim] = thefactor[scaledim];  do_scale();};SVMFLOAT example_set_c::unscale_y(const SVMFLOAT scaled_y){  if((0 == Exp) || (0 == Var)){    return scaled_y;  }  else if(0 == Var[dim]){    return scaled_y+Exp[dim];  }  else{    return (scaled_y*Var[dim]+Exp[dim]);  };};void example_set_c::permute(){  // permute the examples  //  srand((unsigned int)time(0));  svm_example dummy;  SVMINT swap_pos;  SVMINT pos;  for(pos=0;pos<capacity-1;pos++){    swap_pos = (SVMINT)((SVMFLOAT)(pos+1)*rand()/(RAND_MAX+1.0));    dummy = the_set[swap_pos];    the_set[swap_pos] = the_set[pos];    the_set[pos] = dummy;  };  SVMINT i;  SVMINT the_size;  if(all_alphas != 0){    the_size = size();    for(i=0;i<the_size;i++){      all_alphas[i] = get_alpha(i);    };  };  if(all_ys != 0){    the_size = size();    for(i=0;i<the_size;i++){      all_ys[i] = get_y(i);    };  };};void example_set_c::clear_alpha(){

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91在线观看视频| 91丨九色丨蝌蚪富婆spa| 亚洲国产日日夜夜| 亚洲免费观看高清完整版在线| 久久久久久久久久久黄色| 日韩欧美国产午夜精品| 日韩欧美成人激情| 精品久久一二三区| 日韩精品一区二区三区在线观看| 欧美日本一区二区三区四区| 欧美伊人精品成人久久综合97| 色香蕉久久蜜桃| 91福利国产成人精品照片| 色婷婷av一区二区三区之一色屋| 99久久精品国产观看| 91亚洲精品一区二区乱码| aaa欧美日韩| 色乱码一区二区三区88| 欧美性色黄大片| 欧美日韩在线一区二区| 91精品国产入口在线| 精品久久久影院| 久久精品视频在线看| 国产精品色哟哟网站| 亚洲区小说区图片区qvod| 亚洲国产日韩a在线播放性色| 首页国产欧美日韩丝袜| 精品一二线国产| 国产成人免费在线观看| 久久久久久免费毛片精品| 国产一区二区精品久久| 成人在线视频一区二区| 91视视频在线直接观看在线看网页在线看| 色综合天天做天天爱| 欧美久久高跟鞋激| ww亚洲ww在线观看国产| 国产精品丝袜91| 一区二区三区在线观看网站| 日韩精品91亚洲二区在线观看 | 日韩成人一区二区三区在线观看| 图片区小说区国产精品视频| 久久精品99国产精品| 成人午夜看片网址| 欧美日韩视频在线观看一区二区三区| 91精品国产美女浴室洗澡无遮挡| xfplay精品久久| 一区二区在线观看不卡| 美女视频免费一区| av毛片久久久久**hd| 欧美老女人在线| 国产性色一区二区| 又紧又大又爽精品一区二区| 奇米影视一区二区三区小说| 国产 日韩 欧美大片| 欧美视频一区二区三区在线观看 | 国产精品久久久久一区二区三区 | 亚洲成人综合视频| 国产成人综合在线| 666欧美在线视频| 中文字幕乱码亚洲精品一区| 亚洲午夜一区二区| 国产一区二区三区av电影| 欧洲生活片亚洲生活在线观看| 日韩免费在线观看| 亚洲男同1069视频| 国产老妇另类xxxxx| 精品视频一区二区三区免费| 亚洲国产精品国自产拍av| 亚洲第一成年网| 成人久久久精品乱码一区二区三区| 欧美日韩成人在线一区| 一区二区中文视频| 奇米四色…亚洲| 色狠狠桃花综合| 久久精品一区二区三区不卡| 午夜精品视频在线观看| 99麻豆久久久国产精品免费| 日韩精品一区在线| 婷婷综合久久一区二区三区| av一二三不卡影片| 久久久国产精华| 美国十次综合导航| 欧美亚洲愉拍一区二区| 国产精品午夜在线| 韩国三级中文字幕hd久久精品| 欧美吻胸吃奶大尺度电影| 国产精品久久久久久久第一福利| 狠狠色综合日日| 日韩女优电影在线观看| 日精品一区二区| 日本大香伊一区二区三区| 国产精品理论在线观看| 国产91精品一区二区麻豆网站| 日韩一区二区三区视频| 性做久久久久久| 日本道在线观看一区二区| 亚洲欧洲在线观看av| 国产盗摄一区二区| 久久无码av三级| 国产在线精品视频| 亚洲精品一区二区三区影院| 日韩va亚洲va欧美va久久| 欧美在线观看禁18| 亚洲宅男天堂在线观看无病毒| 不卡av在线免费观看| 中文欧美字幕免费| 国产.欧美.日韩| 国产女人水真多18毛片18精品视频| 国产在线麻豆精品观看| 欧美电影免费观看高清完整版在线| 秋霞影院一区二区| 日韩一级黄色大片| 美腿丝袜在线亚洲一区| 欧美一级淫片007| 老司机精品视频在线| 精品国产乱码久久久久久夜甘婷婷| 免费不卡在线视频| 欧美大肚乱孕交hd孕妇| 极品少妇xxxx精品少妇| 精品国产91九色蝌蚪| 国产在线看一区| 国产日本欧美一区二区| 成a人片亚洲日本久久| 成人欧美一区二区三区黑人麻豆| 成人app在线观看| 亚洲精品va在线观看| 欧美亚一区二区| 亚洲成人动漫在线观看| 欧美一区二区三区思思人| 久久国产免费看| 久久久久国色av免费看影院| 国产乱对白刺激视频不卡| 国产精品久久一级| 91国产免费观看| 日韩精品色哟哟| 精品福利av导航| 99久久精品一区| 午夜电影一区二区三区| 久久综合九色综合97婷婷女人 | 日韩欧美成人激情| 国产做a爰片久久毛片| 欧美国产成人在线| 91黄色小视频| 三级不卡在线观看| 日本一区二区三区dvd视频在线| 97精品久久久久中文字幕 | 欧美亚洲日本一区| 开心九九激情九九欧美日韩精美视频电影| 欧美成人艳星乳罩| 99久久精品情趣| 首页国产丝袜综合| 国产日韩亚洲欧美综合| 色呦呦一区二区三区| 久久精品99国产国产精| 亚洲欧洲日本在线| 678五月天丁香亚洲综合网| 国产69精品一区二区亚洲孕妇| 亚洲激情五月婷婷| 精品国精品自拍自在线| 99re成人精品视频| 久久91精品久久久久久秒播| 最近日韩中文字幕| 日韩免费视频线观看| 成人aaaa免费全部观看| 日韩高清国产一区在线| 国产精品免费免费| 日韩片之四级片| 色伊人久久综合中文字幕| 激情欧美一区二区三区在线观看| 日韩美女久久久| 久久亚洲欧美国产精品乐播| 欧美性三三影院| 成人av动漫网站| 国产一区欧美日韩| 午夜av一区二区三区| 日本一区二区三区dvd视频在线| 欧美精品免费视频| av一二三不卡影片| 久久成人免费电影| 99国产精品久久久久久久久久| 蜜桃精品在线观看| 亚洲国产日产av| 亚洲视频狠狠干| 国产清纯在线一区二区www| 欧美二区乱c少妇| 色先锋资源久久综合| 成人理论电影网| 国模少妇一区二区三区| 日本不卡的三区四区五区| 亚洲欧美一区二区久久| 国产拍欧美日韩视频二区| 欧美一级欧美三级在线观看 | 91麻豆精品国产自产在线| 91丝袜美女网| 成人精品国产一区二区4080 | 欧美精品一二三区| 日本韩国一区二区| 91色婷婷久久久久合中文| 国产成人一区二区精品非洲| 国产综合色视频|