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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? rule.java

?? 代碼是一個分類器的實現(xiàn),其中使用了部分weka的源代碼。可以將項目導(dǎo)入eclipse運行
?? JAVA
字號:
/* *    Rule.java *    Copyright (C) 2000 Mark Hall * *    This program is free software; you can redistribute it and/or modify *    it under the terms of the GNU General Public License as published by *    the Free Software Foundation; either version 2 of the License, or *    (at your option) any later version. * *    This program is distributed in the hope that it will be useful, *    but WITHOUT ANY WARRANTY; without even the implied warranty of *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *    GNU General Public License for more details. * *    You should have received a copy of the GNU General Public License *    along with this program; if not, write to the Free Software *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */package weka.classifiers.trees.m5;import weka.core.Instance;import weka.core.Instances;import weka.core.Utils;import java.io.Serializable;/** * Generates a single m5 tree or rule * * @author Mark Hall * @version $Revision: 1.12 $ */public class Rule implements Serializable {  protected static int LEFT = 0;  protected static int RIGHT = 1;  /**   * the instances covered by this rule   */  private Instances  m_instances;  /**   * the class index   */  private int        m_classIndex;  /**   * the number of attributes   */  private int        m_numAttributes;  /**   * the number of instances in the dataset   */  private int        m_numInstances;  /**   * the indexes of the attributes used to split on for this rule   */  private int[]      m_splitAtts;  /**   * the corresponding values of the split points   */  private double[]   m_splitVals;  /**   * the corresponding internal nodes. Used for smoothing rules.   */  private RuleNode[] m_internalNodes;  /**   * the corresponding relational operators (0 = "<=", 1 = ">")   */  private int[]      m_relOps;  /**   * the leaf encapsulating the linear model for this rule   */  private RuleNode   m_ruleModel;  /**   * the top of the m5 tree for this rule   */  protected RuleNode   m_topOfTree;  /**   * the standard deviation of the class for all the instances   */  private double     m_globalStdDev;  /**   * the absolute deviation of the class for all the instances   */  private double     m_globalAbsDev;  /**   * the instances covered by this rule   */  private Instances  m_covered;  /**   * the number of instances covered by this rule   */  private int        m_numCovered;  /**   * the instances not covered by this rule   */  private Instances  m_notCovered;  /**   * use a pruned m5 tree rather than make a rule   */  private boolean    m_useTree;  /**   * use the original m5 smoothing procedure   */  private boolean    m_smoothPredictions;  /**   * Save instances at each node in an M5 tree for visualization purposes.   */  private boolean m_saveInstances;  /**   * Make a regression tree instead of a model tree   */  private boolean m_regressionTree;  /**   * Build unpruned tree/rule   */  private boolean m_useUnpruned;  /**   * The minimum number of instances to allow at a leaf node   */  private double m_minNumInstances;  /**   * Constructor declaration   *   */  public Rule() {    m_useTree = false;    m_smoothPredictions = false;    m_useUnpruned = false;    m_minNumInstances = 4;  }  /**   * Generates a single rule or m5 model tree.   *    * @param data set of instances serving as training data   * @exception Exception if the rule has not been generated   * successfully   */  public void buildClassifier(Instances data) throws Exception {    m_instances = null;    m_topOfTree = null;    m_covered = null;    m_notCovered = null;    m_ruleModel = null;    m_splitAtts = null;    m_splitVals = null;    m_relOps = null;    m_internalNodes = null;    m_instances = data;    m_classIndex = m_instances.classIndex();    m_numAttributes = m_instances.numAttributes();    m_numInstances = m_instances.numInstances();    // first calculate global deviation of class attribute    m_globalStdDev = Rule.stdDev(m_classIndex, m_instances);    m_globalAbsDev = Rule.absDev(m_classIndex, m_instances);    m_topOfTree = new RuleNode(m_globalStdDev, m_globalAbsDev, null);    m_topOfTree.setSaveInstances(m_saveInstances);    m_topOfTree.setRegressionTree(m_regressionTree);    m_topOfTree.setMinNumInstances(m_minNumInstances);    m_topOfTree.buildClassifier(m_instances);    if (!m_useUnpruned) {      m_topOfTree.prune();    } else {      m_topOfTree.installLinearModels();    }    if (m_smoothPredictions) {      m_topOfTree.installSmoothedModels();    }    //m_topOfTree.printAllModels();    m_topOfTree.numLeaves(0);    if (!m_useTree) {           makeRule();      // save space      //      m_topOfTree = null;    }    // save space    m_instances = new Instances(m_instances, 0);      }   /**   * Calculates a prediction for an instance using this rule   * or M5 model tree   *    * @param instance the instance whos class value is to be predicted   * @return the prediction   * @exception Exception if a prediction can't be made.   */  public double classifyInstance(Instance instance) throws Exception {    if (m_useTree) {      return m_topOfTree.classifyInstance(instance);    }     // does the instance pass the rule's conditions?    if (m_splitAtts.length > 0) {      for (int i = 0; i < m_relOps.length; i++) {	if (m_relOps[i] == LEFT)    // left	 {	  if (instance.value(m_splitAtts[i]) > m_splitVals[i]) {	    throw new Exception("Rule does not classify instance");	  } 	} else {	  if (instance.value(m_splitAtts[i]) <= m_splitVals[i]) {	    throw new Exception("Rule does not classify instance");	  } 	}       }     }     // the linear model's prediction for this rule    return m_ruleModel.classifyInstance(instance);  }   /**   * Returns the top of the tree.   */  public RuleNode topOfTree() {    return m_topOfTree;  }  /**   * Make the single best rule from a pruned m5 model tree   *    * @exception Exception if something goes wrong.   */  private void makeRule() throws Exception {    RuleNode[] best_leaf = new RuleNode[1];    double[]   best_cov = new double[1];    RuleNode   temp;    m_notCovered = new Instances(m_instances, 0);    m_covered = new Instances(m_instances, 0);    best_cov[0] = -1;    best_leaf[0] = null;    m_topOfTree.findBestLeaf(best_cov, best_leaf);    temp = best_leaf[0];    if (temp == null) {      throw new Exception("Unable to generate rule!");    }     // save the linear model for this rule    m_ruleModel = temp;    int count = 0;    while (temp.parentNode() != null) {      count++;      temp = temp.parentNode();    }     temp = best_leaf[0];    m_relOps = new int[count];    m_splitAtts = new int[count];    m_splitVals = new double[count];    if (m_smoothPredictions) {      m_internalNodes = new RuleNode[count];    }    // trace back to the root    int i = 0;    while (temp.parentNode() != null) {      m_splitAtts[i] = temp.parentNode().splitAtt();      m_splitVals[i] = temp.parentNode().splitVal();      if (temp.parentNode().leftNode() == temp) {	m_relOps[i] = LEFT;	//	temp.parentNode().m_right = null;      } else {	m_relOps[i] = RIGHT;	//	temp.parentNode().m_left = null;      }      if (m_smoothPredictions) {	m_internalNodes[i] = temp.parentNode();      }      temp = temp.parentNode();      i++;    }     // now assemble the covered and uncovered instances    boolean ok;    for (i = 0; i < m_numInstances; i++) {      ok = true;      for (int j = 0; j < m_relOps.length; j++) {	if (m_relOps[j] == LEFT)	 {	  if (m_instances.instance(i).value(m_splitAtts[j]) 		  > m_splitVals[j]) {	    m_notCovered.add(m_instances.instance(i));	    ok = false;	    break;	  } 	} else {	  if (m_instances.instance(i).value(m_splitAtts[j]) 		  <= m_splitVals[j]) {	    m_notCovered.add(m_instances.instance(i));	    ok = false;	    break;	  } 	}       }       if (ok) {	m_numCovered++;	//	m_covered.add(m_instances.instance(i));      }     }   }   /**   * Return a description of the m5 tree or rule   *    * @return a description of the m5 tree or rule as a String   */  public String toString() {    if (m_useTree) {      return treeToString();    } else {      return ruleToString();    }   }   /**   * Return a description of the m5 tree   *    * @return a description of the m5 tree as a String   */  private String treeToString() {    StringBuffer text = new StringBuffer();    if (m_topOfTree == null) {      return "Tree/Rule has not been built yet!";    }     text.append("M5 "		+ ((m_useUnpruned)		   ? "unpruned "		   : "pruned ")		+ ((m_regressionTree) 		   ? "regression "		   : "model ")		+"tree:\n");    if (m_smoothPredictions == true) {      text.append("(using smoothed linear models)\n");    }     text.append(m_topOfTree.treeToString(0));    text.append(m_topOfTree.printLeafModels());    text.append("\nNumber of Rules : " + m_topOfTree.numberOfLinearModels());    return text.toString();  }   /**   * Return a description of the rule   *    * @return a description of the rule as a String   */  private String ruleToString() {    StringBuffer text = new StringBuffer();    if (m_splitAtts.length > 0) {      text.append("IF\n");      for (int i = m_splitAtts.length - 1; i >= 0; i--) {	text.append("\t" + m_covered.attribute(m_splitAtts[i]).name() + " ");	if (m_relOps[i] == 0) {	  text.append("<= ");	} else {	  text.append("> ");	} 	text.append(Utils.doubleToString(m_splitVals[i], 1, 3) + "\n");      }       text.append("THEN\n");    }     if (m_ruleModel != null) {      try {	text.append(m_ruleModel.printNodeLinearModel());	text.append(" [" + m_numCovered/*m_covered.numInstances()*/);	if (m_globalAbsDev > 0.0) {	  text.append("/"+Utils.doubleToString((100 * 						   m_ruleModel.						   rootMeanSquaredError() / 						   m_globalStdDev), 1, 3) 		      + "%]\n\n");	} else {	  text.append("]\n\n");	}       } catch (Exception e) {	return "Can't print rule";      }     }         //    System.out.println(m_instances);    return text.toString();  }   /**   * Use unpruned tree/rules   *   * @param unpruned true if unpruned tree/rules are to be generated   */  public void setUnpruned(boolean unpruned) {    m_useUnpruned = unpruned;  }  /**   * Get whether unpruned tree/rules are being generated   *   * @return true if unpruned tree/rules are to be generated   */  public boolean getUnpruned() {    return m_useUnpruned;  }  /**   * Use an m5 tree rather than generate rules   *    * @param u true if m5 tree is to be used   */  public void setUseTree(boolean u) {    m_useTree = u;  }   /**   * get whether an m5 tree is being used rather than rules   *    * @return true if an m5 tree is being used.   */  public boolean getUseTree() {    return m_useTree;  }   /**   * Smooth predictions   *    * @param s true if smoothing is to be used   */  public void setSmoothing(boolean s) {    m_smoothPredictions = s;  }   /**   * Get whether or not smoothing has been turned on   *    * @return true if smoothing is being used   */  public boolean getSmoothing() {    return m_smoothPredictions;  }   /**   * Get the instances not covered by this rule   *    * @return the instances not covered   */  public Instances notCoveredInstances() {    return m_notCovered;  } //    /**//     * Get the instances covered by this rule//     * //     * @return the instances covered by this rule//     *///    public Instances coveredInstances() {//      return m_covered;//    }   /**   * Returns the standard deviation value of the supplied attribute index.   *   * @param attr an attribute index   * @param inst the instances   * @return the standard deviation value   */  protected static final double stdDev(int attr, Instances inst) {    int i,count=0;    double sd,va,sum=0.0,sqrSum=0.0,value;        for(i = 0; i <= inst.numInstances() - 1; i++) {      count++;      value = inst.instance(i).value(attr);      sum +=  value;      sqrSum += value * value;    }        if(count > 1) {      va = (sqrSum - sum * sum / count) / count;      va = Math.abs(va);      sd = Math.sqrt(va);    } else {      sd = 0.0;    }    return sd;  }  /**   * Returns the absolute deviation value of the supplied attribute index.   *   * @param attr an attribute index   * @param inst the instances   * @return the absolute deviation value   */  protected static final double absDev(int attr, Instances inst) {    int i;    double average=0.0,absdiff=0.0,absDev;        for(i = 0; i <= inst.numInstances()-1; i++) {      average  += inst.instance(i).value(attr);    }    if(inst.numInstances() > 1) {      average /= (double)inst.numInstances();      for(i=0; i <= inst.numInstances()-1; i++) {	absdiff += Math.abs(inst.instance(i).value(attr) - average);      }      absDev = absdiff / (double)inst.numInstances();    } else {      absDev = 0.0;    }       return absDev;  }  /**   * Sets whether instances at each node in an M5 tree should be saved   * for visualization purposes. Default is to save memory.   *   * @param save a <code>boolean</code> value   */  protected void setSaveInstances(boolean save) {    m_saveInstances = save;  }  /**   * Get the value of regressionTree.   *   * @return Value of regressionTree.   */  public boolean getRegressionTree() {        return m_regressionTree;  }    /**   * Set the value of regressionTree.   *   * @param newregressionTree Value to assign to regressionTree.   */  public void setRegressionTree(boolean newregressionTree) {        m_regressionTree = newregressionTree;  }  /**   * Set the minumum number of instances to allow at a leaf node   *   * @param minNum the minimum number of instances   */  public void setMinNumInstances(double minNum) {    m_minNumInstances = minNum;  }  /**   * Get the minimum number of instances to allow at a leaf node   *   * @return a <code>double</code> value   */  public double getMinNumInstances() {    return m_minNumInstances;  }  public RuleNode getM5RootNode() {    return m_topOfTree;  }}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品免费aⅴ片在线观看| 欧美精选一区二区| 欧美大胆一级视频| 久久99久国产精品黄毛片色诱| 91精品久久久久久久久99蜜臂| 日本亚洲天堂网| 精品国产乱码久久久久久免费| 日本亚洲天堂网| 久久久99免费| 色噜噜狠狠色综合欧洲selulu| 亚洲妇女屁股眼交7| 7777女厕盗摄久久久| 视频一区在线视频| 精品国产不卡一区二区三区| 国产成人综合在线| 亚洲色图欧洲色图婷婷| 欧美日韩成人一区| 国产在线播精品第三| 国产精品高清亚洲| 欧美人妇做爰xxxⅹ性高电影| 精品一区二区三区免费| 欧美国产欧美综合| 欧美日韩国产不卡| 国产麻豆成人传媒免费观看| 亚洲人亚洲人成电影网站色| 4438x亚洲最大成人网| 国产精品一区专区| 亚洲高清免费一级二级三级| 久久久久久久久久久久久久久99| 成人黄色综合网站| 日韩高清欧美激情| 国产女主播在线一区二区| 欧洲国内综合视频| 国产成人h网站| 日韩电影免费在线看| 欧美国产日本韩| 91精品国产品国语在线不卡| 成人h版在线观看| 久久精品国产第一区二区三区| 亚洲视频1区2区| 国产亚洲一区二区三区在线观看| 欧美日韩在线电影| 99vv1com这只有精品| 国产做a爰片久久毛片| 一区二区欧美国产| 国产精品久久久久一区| 精品女同一区二区| 欧美日韩中文字幕一区二区| 成人性视频免费网站| 美女www一区二区| 一区二区三区国产| 国产精品动漫网站| 欧美一区二区黄色| 在线一区二区观看| 成人av电影在线| 国产成人在线观看免费网站| 麻豆成人久久精品二区三区红 | 日韩精品中午字幕| 在线精品亚洲一区二区不卡| 成人免费毛片a| 韩国三级电影一区二区| 免费看日韩精品| 亚洲3atv精品一区二区三区| 一区二区成人在线观看| 最新国产成人在线观看| 国产日韩精品一区二区三区| 久久久久青草大香线综合精品| 欧美一区二区性放荡片| 欧美日韩国产天堂| 欧美久久久一区| 欧美在线观看你懂的| 91久久国产最好的精华液| 91蜜桃视频在线| 91毛片在线观看| 91免费版pro下载短视频| caoporen国产精品视频| 不卡的看片网站| 99免费精品视频| 91在线视频播放地址| 91福利精品第一导航| 一本大道久久精品懂色aⅴ| 一本久道中文字幕精品亚洲嫩| 91免费看`日韩一区二区| 色综合天天综合网国产成人综合天 | 国产91精品一区二区麻豆亚洲| 狠狠色综合播放一区二区| 国内精品第一页| 成人毛片视频在线观看| www.亚洲在线| 欧美综合亚洲图片综合区| 欧美日韩aaaaaa| 精品国精品自拍自在线| 国产欧美一区二区精品仙草咪| 国产精品久久久久久久久久免费看| 中文字幕在线免费不卡| 一区二区三区在线高清| 午夜免费久久看| 国产永久精品大片wwwapp| 成人永久看片免费视频天堂| 91蜜桃免费观看视频| 欧美老肥妇做.爰bbww| 欧美成人艳星乳罩| 国产精品九色蝌蚪自拍| 亚洲一区二区中文在线| 免费观看日韩av| 岛国一区二区在线观看| 欧美日韩一区精品| 日韩精品在线一区二区| 国产女人18毛片水真多成人如厕 | 欧美精品丝袜中出| 精品欧美一区二区三区精品久久| 国产色产综合色产在线视频| 亚洲精品中文字幕乱码三区| 日本大胆欧美人术艺术动态| 国产成人免费视频网站| 欧美三级韩国三级日本三斤 | 欧美日韩免费一区二区三区视频| 欧美白人最猛性xxxxx69交| 国产精品日产欧美久久久久| 亚洲二区在线观看| 国产精品综合久久| 欧美午夜精品久久久久久超碰| 日韩欧美国产wwwww| 自拍偷拍亚洲激情| 蜜桃91丨九色丨蝌蚪91桃色| 色综合久久久久久久久久久| 欧美一区二区成人6969| **网站欧美大片在线观看| 日韩av一区二区三区四区| 高清日韩电视剧大全免费| 制服丝袜国产精品| 亚洲视频每日更新| 国产高清在线观看免费不卡| 在线播放日韩导航| 亚洲视频香蕉人妖| 国产乱妇无码大片在线观看| 欧美美女bb生活片| 亚洲三级免费电影| 成人禁用看黄a在线| 日韩美女视频在线| 天天综合网天天综合色| 91福利在线观看| 中文一区二区完整视频在线观看| 免费成人在线播放| 欧美精品丝袜久久久中文字幕| 亚洲图片另类小说| 成人avav影音| 久久精品无码一区二区三区| 男女性色大片免费观看一区二区| 91在线精品秘密一区二区| 中文字幕乱码亚洲精品一区| 国内精品在线播放| 精品久久久久久亚洲综合网| 丝瓜av网站精品一区二区| 欧美主播一区二区三区美女| 亚洲欧美日本在线| 91丨porny丨在线| 中文字幕日韩一区二区| 成人18精品视频| 国产精品色哟哟网站| 国产成人亚洲综合a∨婷婷图片| 精品国产自在久精品国产| 麻豆精品国产91久久久久久| 日韩精品专区在线| 激情另类小说区图片区视频区| 精品国内二区三区| 国产麻豆精品95视频| 国产欧美精品一区二区三区四区| 国产成人精品一区二区三区网站观看| 久久综合九色综合97_久久久| 国产一区二区影院| 国产视频一区二区在线| 国产999精品久久| 国产精品高潮久久久久无| 成人网在线播放| 亚洲手机成人高清视频| 91黄色免费观看| 五月天激情综合网| 日韩一级二级三级精品视频| 久久99精品久久久久久国产越南 | 国产乱码精品一区二区三区忘忧草| 亚洲精品一区在线观看| 国产99久久久国产精品潘金网站| 中文字幕不卡一区| 在线亚洲一区观看| 日本aⅴ亚洲精品中文乱码| 精品久久久久一区二区国产| 国产99久久久久| 尤物av一区二区| 日韩欧美在线影院| 国产99久久久久| 一区2区3区在线看| 欧美大胆人体bbbb| 99久久婷婷国产综合精品电影| 亚洲一区二区三区国产| 欧美tickling挠脚心丨vk| 国产一区二区三区蝌蚪| 亚洲视频 欧洲视频| 制服丝袜av成人在线看| 成人毛片老司机大片|