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

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

?? symmetricaluncertattributeeval.java

?? 一個數據挖掘系統的源碼
?? JAVA
字號:

/**
 *
 *   AgentAcademy - an open source Data Mining framework for
 *   training intelligent agents
 *
 *   Copyright (C)   2001-2003 AA Consortium.
 *
 *   This library is open source software; you can redistribute it
 *   and/or modify it under the terms of the GNU Lesser General
 *   Public License as published by the Free Software Foundation;
 *   either version 2.0 of the License, or (at your option) any later
 *   version.
 *
 *   This library 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 Lesser General Public
 *   License along with this library; if not, write to the Free
 *   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *   MA  02111-1307 USA
 *
 */

package  org.agentacademy.modules.dataminer.attributeSelection;

import java.util.Enumeration;
import java.util.Vector;

import org.agentacademy.modules.dataminer.core.ContingencyTables;
import org.agentacademy.modules.dataminer.core.Instance;
import org.agentacademy.modules.dataminer.core.Instances;
import org.agentacademy.modules.dataminer.core.Option;
import org.agentacademy.modules.dataminer.core.OptionHandler;
import org.agentacademy.modules.dataminer.core.Utils;
import org.agentacademy.modules.dataminer.filters.DiscretizeFilter;
import org.agentacademy.modules.dataminer.filters.Filter;
import org.apache.log4j.Logger;

/**
 * Class for Evaluating attributes individually by measuring symmetrical
 * uncertainty with respect to the class.
 *
 * Valid options are:<p>
 *
 * -M <br>
 * Treat missing values as a seperate value. <br>
 *
 * @author Mark Hall (mhall@cs.waikato.ac.nz)
 * @version $Revision: 1.3 $
 */
public class SymmetricalUncertAttributeEval
  extends AttributeEvaluator
  implements OptionHandler
{

 public static Logger                log = Logger.getLogger(SymmetricalUncertAttributeEval.class);
  /** The training instances */
  private Instances m_trainInstances;

  /** The class index */
  private int m_classIndex;

  /** The number of attributes */
  private int m_numAttribs;

  /** The number of instances */
  private int m_numInstances;

  /** The number of classes */
  private int m_numClasses;

  /** Treat missing values as a seperate value */
  private boolean m_missing_merge;

  /**
   * Returns a string describing this attribute evaluator
   * @return a description of the evaluator suitable for
   * displaying in the explorer/experimenter gui
   */
  public String globalInfo() {
    return "GainRatioAttributeEval :\n\nEvaluates the worth of an attribute "
      +"by measuring the symmetrical uncertainty with respect to the class. "
      +"\n\n SymmU(Class, Attribute) = 2 * (H(Class) - H(Class | Attribute)) "
      +"/ H(Class) + H(Attribute).\n";
  }

  /**
   * Constructor
   */
  public SymmetricalUncertAttributeEval () {
    resetOptions();
  }


  /**
   * Returns an enumeration describing the available options.
   * @return an enumeration of all the available options.
   **/
  public Enumeration listOptions () {
    Vector newVector = new Vector(1);
    newVector.addElement(new Option("\ttreat missing values as a seperate "
				    + "value.", "M", 0, "-M"));
    return  newVector.elements();
  }


  /**
   * Parses a given list of options.
   *
   * -M <br>
   * Treat missing values as a seperate value. <p>
   *
   * @param options the list of options as an array of strings
   * @exception Exception if an option is not supported
   **/
  public void setOptions (String[] options)
    throws Exception
  {
    resetOptions();
    setMissingMerge(!(Utils.getFlag('M', options)));
  }

  /**
   * Returns the tip text for this property
   * @return tip text for this property suitable for
   * displaying in the explorer/experimenter gui
   */
  public String missingMergeTipText() {
    return "Distribute counts for missing values. Counts are distributed "
      +"across other values in proportion to their frequency. Otherwise, "
      +"missing is treated as a separate value.";
  }

  /**
   * distribute the counts for missing values across observed values
   *
   * @param b true=distribute missing values.
   */
  public void setMissingMerge (boolean b) {
    m_missing_merge = b;
  }


  /**
   * get whether missing values are being distributed or not
   *
   * @return true if missing values are being distributed.
   */
  public boolean getMissingMerge () {
    return  m_missing_merge;
  }


  /**
   * Gets the current settings of WrapperSubsetEval.
   * @return an array of strings suitable for passing to setOptions()
   */
  public String[] getOptions () {
    String[] options = new String[1];
    int current = 0;

    if (!getMissingMerge()) {
      options[current++] = "-M";
    }

    while (current < options.length) {
      options[current++] = "";
    }

    return  options;
  }


  /**
   * Initializes a symmetrical uncertainty attribute evaluator.
   * Discretizes all attributes that are numeric.
   *
   * @param data set of instances serving as training data
   * @exception Exception if the evaluator has not been
   * generated successfully
   */
  public void buildEvaluator (Instances data)
    throws Exception
  {
    if (data.checkForStringAttributes()) {
      throw  new Exception("Can't handle string attributes!");
    }

    m_trainInstances = data;
    m_classIndex = m_trainInstances.classIndex();
    m_numAttribs = m_trainInstances.numAttributes();
    m_numInstances = m_trainInstances.numInstances();
    if (m_trainInstances.attribute(m_classIndex).isNumeric()) {
      throw  new Exception("Class must be nominal!");
    }

    DiscretizeFilter disTransform = new DiscretizeFilter();
    disTransform.setUseBetterEncoding(true);
    disTransform.setInputFormat(m_trainInstances);
    m_trainInstances = Filter.useFilter(m_trainInstances, disTransform);
    m_numClasses = m_trainInstances.attribute(m_classIndex).numValues();
  }


  /**
   * set options to default values
   */
  protected void resetOptions () {
    m_trainInstances = null;
    m_missing_merge = true;
  }


  /**
   * evaluates an individual attribute by measuring the symmetrical
   * uncertainty between it and the class.
   *
   * @param attribute the index of the attribute to be evaluated
   * @exception Exception if the attribute could not be evaluated
   */
  public double evaluateAttribute (int attribute)
    throws Exception
  {
    int i, j, ii, jj;
    int nnj, nni, ni, nj;
    double sum = 0.0;
    ni = m_trainInstances.attribute(attribute).numValues() + 1;
    nj = m_numClasses + 1;
    double[] sumi, sumj;
    Instance inst;
    double temp = 0.0;
    sumi = new double[ni];
    sumj = new double[nj];
    double[][] counts = new double[ni][nj];
    sumi = new double[ni];
    sumj = new double[nj];

    for (i = 0; i < ni; i++) {
      sumi[i] = 0.0;

      for (j = 0; j < nj; j++) {
	sumj[j] = 0.0;
	counts[i][j] = 0.0;
      }
    }

    // Fill the contingency table
    for (i = 0; i < m_numInstances; i++) {
      inst = m_trainInstances.instance(i);

      if (inst.isMissing(attribute)) {
	ii = ni - 1;
      }
      else {
	ii = (int)inst.value(attribute);
      }

      if (inst.isMissing(m_classIndex)) {
	jj = nj - 1;
      }
      else {
	jj = (int)inst.value(m_classIndex);
      }

      counts[ii][jj]++;
    }

    // get the row totals
    for (i = 0; i < ni; i++) {
      sumi[i] = 0.0;

      for (j = 0; j < nj; j++) {
	sumi[i] += counts[i][j];
	sum += counts[i][j];
      }
    }

    // get the column totals
    for (j = 0; j < nj; j++) {
      sumj[j] = 0.0;

      for (i = 0; i < ni; i++) {
	sumj[j] += counts[i][j];
      }
    }

    // distribute missing counts
    if (m_missing_merge &&
	(sumi[ni-1] < m_numInstances) &&
	(sumj[nj-1] < m_numInstances)) {
      double[] i_copy = new double[sumi.length];
      double[] j_copy = new double[sumj.length];
      double[][] counts_copy = new double[sumi.length][sumj.length];

      for (i = 0; i < ni; i++) {
	System.arraycopy(counts[i], 0, counts_copy[i], 0, sumj.length);
      }

      System.arraycopy(sumi, 0, i_copy, 0, sumi.length);
      System.arraycopy(sumj, 0, j_copy, 0, sumj.length);
      double total_missing = (sumi[ni - 1] + sumj[nj - 1]
			      - counts[ni - 1][nj - 1]);

      // do the missing i's
      if (sumi[ni - 1] > 0.0) {
	for (j = 0; j < nj - 1; j++) {
	  if (counts[ni - 1][j] > 0.0) {
	    for (i = 0; i < ni - 1; i++) {
	      temp = ((i_copy[i]/(sum - i_copy[ni - 1])) *
		      counts[ni - 1][j]);
	      counts[i][j] += temp;
	      sumi[i] += temp;
	    }

	    counts[ni - 1][j] = 0.0;
	  }
	}
      }

      sumi[ni - 1] = 0.0;

      // do the missing j's
      if (sumj[nj - 1] > 0.0) {
	for (i = 0; i < ni - 1; i++) {
	  if (counts[i][nj - 1] > 0.0) {
	    for (j = 0; j < nj - 1; j++) {
	      temp = ((j_copy[j]/(sum - j_copy[nj - 1]))*counts[i][nj - 1]);
	      counts[i][j] += temp;
	      sumj[j] += temp;
	    }

	    counts[i][nj - 1] = 0.0;
	  }
	}
      }

      sumj[nj - 1] = 0.0;

      // do the both missing
      if (counts[ni - 1][nj - 1] > 0.0 && total_missing != sum) {
	for (i = 0; i < ni - 1; i++) {
	  for (j = 0; j < nj - 1; j++) {
	    temp = (counts_copy[i][j]/(sum - total_missing)) *
	      counts_copy[ni - 1][nj - 1];
	    counts[i][j] += temp;
	    sumi[i] += temp;
	    sumj[j] += temp;
	  }
	}

	counts[ni - 1][nj - 1] = 0.0;
      }
    }

    return  ContingencyTables.symmetricalUncertainty(counts);
  }


  /**
   * Return a description of the evaluator
   * @return description as a string
   */
  public String toString () {
    StringBuffer text = new StringBuffer();

    if (m_trainInstances == null) {
      text.append("\tSymmetrical Uncertainty evaluator has not been built");
    }
    else {
      text.append("\tSymmetrical Uncertainty Ranking Filter");
      if (!m_missing_merge) {
	text.append("\n\tMissing values treated as seperate");
      }
    }

    text.append("\n");
    return  text.toString();
  }


  // ============
  // Test method.
  // ============
  /**
   * Main method for testing this class.
   *
   * @param argv should contain the following arguments:
   * -t training file
   */
  public static void main (String[] argv) {
    try {
      System.out.println(AttributeSelection.
			 SelectAttributes(new SymmetricalUncertAttributeEval()
					  , argv));
    }
    catch (Exception e) {
      log.error(e.getStackTrace().toString());
      log.error(e.getMessage());
    }
  }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久国产精品人| 久久精品国产久精国产爱| 亚洲777理论| 不卡的av电影| 欧美国产精品专区| 久久爱www久久做| 91丨九色丨黑人外教| 日韩欧美国产wwwww| 亚洲永久精品国产| 不卡的av中国片| 国产偷国产偷精品高清尤物| 日本欧美一区二区三区| 在线看日韩精品电影| 国产性色一区二区| 国产美女在线观看一区| 欧美一级片免费看| 日韩精品午夜视频| 欧美做爰猛烈大尺度电影无法无天| 中文字幕欧美日本乱码一线二线| 日韩电影免费一区| 在线成人高清不卡| 依依成人精品视频| 色综合久久久久久久| 中文字幕中文乱码欧美一区二区| 精品一区二区三区免费毛片爱| 777午夜精品免费视频| 亚洲小说春色综合另类电影| 91老师片黄在线观看| 国产精品高清亚洲| heyzo一本久久综合| 最新高清无码专区| 色吊一区二区三区| 亚洲丶国产丶欧美一区二区三区| 精品视频一区二区三区免费| 亚洲一区中文日韩| 欧美日韩免费高清一区色橹橹| 亚洲精品美腿丝袜| 欧美亚洲愉拍一区二区| 亚洲午夜精品在线| 91精品国产一区二区| 男男视频亚洲欧美| 久久久九九九九| 成人高清免费观看| 亚洲素人一区二区| 欧美系列亚洲系列| 久久se精品一区精品二区| 欧美日韩美女一区二区| 日韩 欧美一区二区三区| 欧美精品一区二区三区在线| 国产成人免费在线观看| 国产精品每日更新在线播放网址| 99久久精品免费精品国产| 亚洲自拍偷拍av| 5566中文字幕一区二区电影| 国内精品写真在线观看| 国产精品短视频| 欧美日韩综合一区| 国产一区二区精品久久| 国产精品午夜春色av| 在线观看国产日韩| 国产在线精品一区二区三区不卡| 国产欧美精品日韩区二区麻豆天美| 成人久久视频在线观看| 一区二区三区在线观看欧美| 7777精品伊人久久久大香线蕉经典版下载| 麻豆成人免费电影| 中文字幕一区二区三区av| 91精品国产91热久久久做人人| 国产一区二区三区综合| 依依成人精品视频| 久久综合色播五月| 在线精品视频免费观看| 国产在线视视频有精品| 亚洲一区二三区| 久久精品一区四区| 欧美日本韩国一区| www.av亚洲| 久久99国产精品尤物| 亚洲三级在线观看| 久久久久免费观看| 555夜色666亚洲国产免| 成人福利视频网站| 国产精一区二区三区| 亚洲va欧美va人人爽| 国产精品高潮久久久久无| 亚洲精品一区二区三区99| 欧美制服丝袜第一页| 成人黄页毛片网站| 精品一区二区三区香蕉蜜桃 | 91美女视频网站| 精品一区二区三区在线观看国产 | 久久机这里只有精品| 亚洲日本va在线观看| 久久久久综合网| 日韩欧美在线123| 欧美性生活影院| 一本色道久久综合精品竹菊| 成人黄色网址在线观看| 国产美女一区二区三区| 久久精品国产网站| 日韩精品乱码av一区二区| 一区二区视频免费在线观看| 中文字幕一区二区三区不卡 | 日韩精品一区在线观看| 欧美三级电影在线观看| 91久久精品一区二区| 成人h动漫精品| 国产91在线观看丝袜| 国产一区二区三区四区五区美女| 日本视频在线一区| 午夜精品久久久久久久久久| 亚洲一线二线三线久久久| 亚洲一区二区在线观看视频| 亚洲欧美激情小说另类| 亚洲免费大片在线观看| 亚洲一区在线视频观看| 亚洲小少妇裸体bbw| 亚洲国产成人porn| 五月天婷婷综合| 日本aⅴ亚洲精品中文乱码| 日韩av在线发布| 国产一区中文字幕| 国产精品自拍av| a在线播放不卡| 色综合久久久久综合| 欧美日韩综合色| 日韩三级在线观看| 国产女人18毛片水真多成人如厕 | 色菇凉天天综合网| 欧美精品日韩一区| 精品久久久久久久久久久久包黑料| 欧美成人精品1314www| 国产亚洲污的网站| 亚洲免费观看高清完整版在线观看熊 | www.欧美亚洲| 欧美天堂亚洲电影院在线播放| 欧美吻胸吃奶大尺度电影 | 日本午夜精品一区二区三区电影| 免费观看一级欧美片| 国产伦精品一区二区三区免费 | 亚洲精品大片www| 午夜精品视频一区| 国产高清在线精品| 欧美自拍丝袜亚洲| 精品国产91亚洲一区二区三区婷婷| 日本一区二区三区四区| 亚洲综合色网站| 久久99精品久久久久久动态图| 高清在线成人网| 欧美精品一二三区| 国产精品丝袜一区| 日韩电影一区二区三区| 不卡在线视频中文字幕| 欧美肥妇bbw| 国产女主播一区| 奇米影视一区二区三区小说| a美女胸又www黄视频久久| 欧美一级国产精品| 亚洲精品国产品国语在线app| 蜜桃av噜噜一区二区三区小说| 成人国产精品免费网站| 欧美大片免费久久精品三p| 亚洲欧美日韩在线| 国产福利视频一区二区三区| 91久久国产最好的精华液| 久久无码av三级| 亚洲成人激情社区| 99久久久免费精品国产一区二区| 日韩欧美在线网站| 亚洲第一综合色| 91视频.com| 国产精品免费网站在线观看| 麻豆91精品视频| 欧美日韩精品欧美日韩精品一 | 国产高清不卡二三区| 日韩一区二区在线播放| 亚洲激情校园春色| 99视频有精品| 中文字幕精品一区二区三区精品| 五月天久久比比资源色| 91久久久免费一区二区| 亚洲色图欧美偷拍| 不卡视频一二三| 国产欧美日产一区| 国产成人免费视频网站高清观看视频| 欧美一区二区二区| 日韩电影在线一区| 5858s免费视频成人| 午夜精品一区二区三区电影天堂 | 精品国产乱码久久久久久1区2区 | 国产婷婷色一区二区三区在线| 免费成人在线视频观看| 在线不卡a资源高清| 亚洲成人一区在线| 欧美日韩亚洲综合一区二区三区| 一区二区三区欧美在线观看| 91网上在线视频| 亚洲狼人国产精品| 色哟哟日韩精品| 亚洲a一区二区|