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

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

?? principalcomponents.java

?? 一個數據挖掘系統的源碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:

/**
 *
 *   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.Attribute;
import org.agentacademy.modules.dataminer.core.FastVector;
import org.agentacademy.modules.dataminer.core.Instance;
import org.agentacademy.modules.dataminer.core.Instances;
import org.agentacademy.modules.dataminer.core.Matrix;
import org.agentacademy.modules.dataminer.core.Option;
import org.agentacademy.modules.dataminer.core.OptionHandler;
import org.agentacademy.modules.dataminer.core.SparseInstance;
import org.agentacademy.modules.dataminer.core.Utils;
import org.agentacademy.modules.dataminer.filters.AttributeFilter;
import org.agentacademy.modules.dataminer.filters.Filter;
import org.agentacademy.modules.dataminer.filters.NominalToBinaryFilter;
import org.agentacademy.modules.dataminer.filters.NormalizationFilter;
import org.agentacademy.modules.dataminer.filters.ReplaceMissingValuesFilter;

import org.apache.log4j.Logger;

/**
 * Class for performing principal components analysis/transformation.
 *
 * @author Mark Hall (mhall@cs.waikato.ac.nz)
 * @author Gabi Schmidberger (gabi@cs.waikato.ac.nz)
 * @version $Revision: 1.3 $
 */
public class PrincipalComponents extends AttributeEvaluator
  implements AttributeTransformer, OptionHandler {

 public static Logger                log = Logger.getLogger(PrincipalComponents.class);
  /** The data to transform analyse/transform */
  private Instances m_trainInstances;

  /** Keep a copy for the class attribute (if set) */
  private Instances m_trainCopy;

  /** The header for the transformed data format */
  private Instances m_transformedFormat;

  /** The header for data transformed back to the original space */
  private Instances m_originalSpaceFormat;

  /** Data has a class set */
  private boolean m_hasClass;

  /** Class index */
  private int m_classIndex;

  /** Number of attributes */
  private int m_numAttribs;

  /** Number of instances */
  private int m_numInstances;

  /** Correlation matrix for the original data */
  private double [][] m_correlation;

  /** Will hold the unordered linear transformations of the (normalized)
      original data */
  private double [][] m_eigenvectors;

  /** Eigenvalues for the corresponding eigenvectors */
  private double [] m_eigenvalues = null;

  /** Sorted eigenvalues */
  private int [] m_sortedEigens;

  /** sum of the eigenvalues */
  private double m_sumOfEigenValues = 0.0;

  /** Filters for original data */
  private ReplaceMissingValuesFilter m_replaceMissingFilter;
  private NormalizationFilter m_normalizeFilter;
  private NominalToBinaryFilter m_nominalToBinFilter;
  private AttributeFilter m_attributeFilter;

  /** used to remove the class column if a class column is set */
  private AttributeFilter m_attribFilter;

  /** The number of attributes in the pc transformed data */
  private int m_outputNumAtts = -1;

  /** normalize the input data? */
  private boolean m_normalize = true;

  /** the amount of varaince to cover in the original data when
      retaining the best n PC's */
  private double m_coverVariance = 0.95;

  /** transform the data through the pc space and back to the original
      space ? */
  private boolean m_transBackToOriginal = false;

  /** holds the transposed eigenvectors for converting back to the
      original space */
  private double [][] m_eTranspose;

  /**
   * Returns a string describing this attribute transformer
   * @return a description of the evaluator suitable for
   * displaying in the explorer/experimenter gui
   */
  public String globalInfo() {
    return "Performs a principal components analysis and transformation of "
      +"the data. Use in conjunction with a Ranker search. Dimensionality "
      +"reduction is accomplished by choosing enough eigenvectors to "
      +"account for some percentage of the variance in the original data---"
      +"default 0.95 (95%). Attribute noise can be filtered by transforming "
      +"to the PC space, eliminating some of the worst eigenvectors, and "
      +"then transforming back to the original space.";
  }

  /**
   * Returns an enumeration describing the available options. <p>
   *
   * -N <classifier>
   * Don't normalize the input data. <p>
   *
   * @return an enumeration of all the available options.
   **/
  public Enumeration listOptions () {
    Vector newVector = new Vector(3);
    newVector.addElement(new Option("\tDon't normalize input data."
				    , "D", 0, "-D"));

    newVector.addElement(new Option("\tRetain enough PC attributes to account "
				    +"\n\tfor this proportion of variance in "
				    +"the original data. (default = 0.95)",
				    "R",1,"-R"));

    newVector.addElement(new Option("\tTransform through the PC space and "
				    +"\n\tback to the original space."
				    , "O", 0, "-O"));
    return  newVector.elements();
  }

  /**
   * Parses a given list of options.
   *
   * Valid options are:<p>
   * -N <classifier>
   * Don't normalize the input data. <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();
    String optionString;

    optionString = Utils.getOption('R', options);
    if (optionString.length() != 0) {
      Double temp;
      temp = Double.valueOf(optionString);
      setVarianceCovered(temp.doubleValue());
    }
    setNormalize(!Utils.getFlag('D', options));

    setTransformBackToOriginal(Utils.getFlag('O', options));
  }

  /**
   * Reset to defaults
   */
  private void resetOptions() {
    m_coverVariance = 0.95;
    m_normalize = true;
    m_sumOfEigenValues = 0.0;
    m_transBackToOriginal = false;
  }

  /**
   * Returns the tip text for this property
   * @return tip text for this property suitable for
   * displaying in the explorer/experimenter gui
   */
  public String normalizeTipText() {
    return "Normalize input data.";
  }

  /**
   * Set whether input data will be normalized.
   * @param n true if input data is to be normalized
   */
  public void setNormalize(boolean n) {
    m_normalize = n;
  }

  /**
   * Gets whether or not input data is to be normalized
   * @return true if input data is to be normalized
   */
  public boolean getNormalize() {
    return m_normalize;
  }

  /**
   * Returns the tip text for this property
   * @return tip text for this property suitable for
   * displaying in the explorer/experimenter gui
   */
  public String varianceCoveredTipText() {
    return "Retain enough PC attributes to account for this proportion of "
      +"variance.";
  }

  /**
   * Sets the amount of variance to account for when retaining
   * principal components
   * @param vc the proportion of total variance to account for
   */
  public void setVarianceCovered(double vc) {
    m_coverVariance = vc;
  }

  /**
   * Gets the proportion of total variance to account for when
   * retaining principal components
   * @return the proportion of variance to account for
   */
  public double getVarianceCovered() {
    return m_coverVariance;
  }

  /**
   * Returns the tip text for this property
   * @return tip text for this property suitable for
   * displaying in the explorer/experimenter gui
   */
  public String transformBackToOriginalTipText() {
    return "Transform through the PC space and back to the original space. "
      +"If only the best n PCs are retained (by setting varianceCovered < 1) "
      +"then this option will give a dataset in the original space but with "
      +"less attribute noise.";
  }

  /**
   * Sets whether the data should be transformed back to the original
   * space
   * @param b true if the data should be transformed back to the
   * original space
   */
  public void setTransformBackToOriginal(boolean b) {
    m_transBackToOriginal = b;
  }

  /**
   * Gets whether the data is to be transformed back to the original
   * space.
   * @return true if the data is to be transformed back to the original space
   */
  public boolean getTransformBackToOriginal() {
    return m_transBackToOriginal;
  }

  /**
   * Gets the current settings of PrincipalComponents
   *
   * @return an array of strings suitable for passing to setOptions()
   */
  public String[] getOptions () {

    String[] options = new String[4];
    int current = 0;

    if (!getNormalize()) {
      options[current++] = "-D";
    }

    options[current++] = "-R"; options[current++] = ""+getVarianceCovered();

    if (getTransformBackToOriginal()) {
      options[current++] = "-O";
    }

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

    return  options;
  }

  /**
   * Initializes principal components and performs the analysis
   * @param data the instances to analyse/transform
   * @exception Exception if analysis fails
   */
  public void buildEvaluator(Instances data) throws Exception {
    buildAttributeConstructor(data);
  }

  private void buildAttributeConstructor (Instances data) throws Exception {
    m_eigenvalues = null;
    m_outputNumAtts = -1;
    m_attributeFilter = null;
    m_nominalToBinFilter = null;
    m_sumOfEigenValues = 0.0;

    if (data.checkForStringAttributes()) {
      throw  new Exception("Can't handle string attributes!");
    }
    m_trainInstances = data;

    // make a copy of the training data so that we can get the class
    // column to append to the transformed data (if necessary)
    m_trainCopy = new Instances(m_trainInstances);

    m_replaceMissingFilter = new ReplaceMissingValuesFilter();
    m_replaceMissingFilter.setInputFormat(m_trainInstances);
    m_trainInstances = Filter.useFilter(m_trainInstances,
					m_replaceMissingFilter);

    if (m_normalize) {
      m_normalizeFilter = new NormalizationFilter();
      m_normalizeFilter.setInputFormat(m_trainInstances);
      m_trainInstances = Filter.useFilter(m_trainInstances, m_normalizeFilter);
    }

    m_nominalToBinFilter = new NominalToBinaryFilter();
    m_nominalToBinFilter.setInputFormat(m_trainInstances);
    m_trainInstances = Filter.useFilter(m_trainInstances,
					m_nominalToBinFilter);

    // delete any attributes with only one distinct value or are all missing
    Vector deleteCols = new Vector();
    for (int i=0;i<m_trainInstances.numAttributes();i++) {
      if (m_trainInstances.numDistinctValues(i) <=1) {
	deleteCols.addElement(new Integer(i));
      }
    }

    if (m_trainInstances.classIndex() >=0) {
      // get rid of the class column
      m_hasClass = true;
      m_classIndex = m_trainInstances.classIndex();
      deleteCols.addElement(new Integer(m_classIndex));
    }

    // remove columns from the data if necessary
    if (deleteCols.size() > 0) {
      m_attributeFilter = new AttributeFilter();
      int [] todelete = new int [deleteCols.size()];
      for (int i=0;i<deleteCols.size();i++) {
	todelete[i] = ((Integer)(deleteCols.elementAt(i))).intValue();
      }
      m_attributeFilter.setAttributeIndicesArray(todelete);
      m_attributeFilter.setInvertSelection(false);
      m_attributeFilter.setInputFormat(m_trainInstances);
      m_trainInstances = Filter.useFilter(m_trainInstances, m_attributeFilter);
    }

    m_numInstances = m_trainInstances.numInstances();
    m_numAttribs = m_trainInstances.numAttributes();

    fillCorrelation();

    double [] d = new double[m_numAttribs];
    double [][] v = new double[m_numAttribs][m_numAttribs];


    Matrix corr = new Matrix(m_correlation);
    corr.eigenvalueDecomposition(v, d);
    //if (debug) {
    //  Matrix V = new Matrix(v);
    //  boolean b = corr.testEigen(V, d, true);
    //  if (!b)
    //	System.out.println("Problem with eigenvektors!!!");
    //  else
    //	System.out.println("***** everything's fine !!!");
    //  }

    m_eigenvectors = (double [][])v.clone();
    m_eigenvalues = (double [])d.clone();

    // any eigenvalues less than 0 are not worth anything --- change to 0
    for (int i = 0; i < m_eigenvalues.length; i++) {
      if (m_eigenvalues[i] < 0) {
	m_eigenvalues[i] = 0.0;
      }
    }
    m_sortedEigens = Utils.sort(m_eigenvalues);
    m_sumOfEigenValues = Utils.sum(m_eigenvalues);

    m_transformedFormat = setOutputFormat();
    if (m_transBackToOriginal) {
      m_originalSpaceFormat = setOutputFormatOriginal();

      // new ordered eigenvector matrix
      int numVectors = (m_transformedFormat.classIndex() < 0)
	? m_transformedFormat.numAttributes()

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日产国产欧美视频一区精品| 91视频免费播放| 成人高清视频在线| 欧美精选一区二区| 国产精品每日更新在线播放网址| 爽爽淫人综合网网站| 色拍拍在线精品视频8848| 久久久久久影视| 麻豆成人91精品二区三区| 日本道色综合久久| 国产精品国产三级国产普通话99 | 精品一区二区日韩| 欧美吞精做爰啪啪高潮| 亚洲乱码中文字幕| 成人高清视频免费观看| 欧美极品另类videosde| 国产自产v一区二区三区c| 91精品国产乱| 亚洲国产日韩综合久久精品| 99精品视频中文字幕| 中国av一区二区三区| 国产剧情av麻豆香蕉精品| 日韩视频国产视频| 水野朝阳av一区二区三区| 欧美唯美清纯偷拍| 午夜久久福利影院| 欧美性三三影院| 五月天激情综合网| 欧美高清你懂得| 亚洲国产精品精华液网站| 欧美三级一区二区| 一区二区三区在线视频免费观看| av综合在线播放| 成人免费视频在线观看| a在线欧美一区| 亚洲精品高清视频在线观看| 91香蕉视频mp4| 亚洲一线二线三线视频| 欧美色倩网站大全免费| 亚洲国产一区二区a毛片| 欧美日韩视频第一区| 亚洲大片免费看| 欧美电影在线免费观看| 看国产成人h片视频| 久久久不卡网国产精品一区| 国产成人av电影在线| 亚洲免费观看高清| 欧美日韩精品一区二区三区四区 | 中文字幕成人av| av福利精品导航| 亚洲小少妇裸体bbw| 日韩一区二区免费在线电影| 国产综合色视频| 日韩理论片网站| 91麻豆精品国产91久久久使用方法 | 日韩福利电影在线观看| 精品少妇一区二区三区视频免付费| 久久激情五月激情| 国产精品视频第一区| 欧美日韩视频在线一区二区| 狠狠色丁香久久婷婷综合_中| 国产嫩草影院久久久久| 欧美日韩一区二区三区四区 | 成人看片黄a免费看在线| 亚洲视频一区在线观看| 欧美一区二区三区小说| 成人激情动漫在线观看| 亚洲成人免费电影| 国产亚洲欧美激情| 欧美日韩黄视频| 懂色av中文字幕一区二区三区| 亚洲高清一区二区三区| 亚洲国产成人一区二区三区| 欧美日韩午夜精品| jlzzjlzz欧美大全| 久久99久久久欧美国产| 一区二区三区四区激情| 精品欧美黑人一区二区三区| 91黄色免费看| 国产成人久久精品77777最新版本| 亚洲影院久久精品| 国产精品色在线| 日韩欧美三级在线| 欧美视频第二页| 99久久伊人精品| 国产乱码精品一区二区三区av| 亚洲国产美国国产综合一区二区| 久久亚洲精品小早川怜子| 欧美日韩激情一区二区三区| 91免费观看在线| 国产suv精品一区二区6| 久久精品国产99国产精品| 亚洲午夜免费电影| 亚洲人妖av一区二区| 国产日韩精品久久久| 日韩精品中文字幕一区| 欧美男生操女生| 欧美日韩色一区| 91国产成人在线| 一本大道av伊人久久综合| 粉嫩欧美一区二区三区高清影视| 久久成人免费网| 免费欧美在线视频| 婷婷成人激情在线网| 亚洲国产综合91精品麻豆| 一区二区三区国产精品| 最近中文字幕一区二区三区| 中文字幕一区二区三区色视频| 国产亚洲制服色| 精品国产一区二区国模嫣然| 日韩一级黄色大片| 欧美一区二视频| 在线播放91灌醉迷j高跟美女| 欧美日韩国产在线观看| 在线亚洲+欧美+日本专区| 欧洲av在线精品| 欧美军同video69gay| 91精品国产一区二区三区蜜臀 | 91蜜桃免费观看视频| 99久久免费精品高清特色大片| 99re在线精品| 欧美三级欧美一级| 555夜色666亚洲国产免| 欧美一级在线视频| 精品1区2区在线观看| 国产欧美一区二区精品性色超碰| 国产日韩精品一区二区三区在线| 中文字幕电影一区| 亚洲一区日韩精品中文字幕| 亚洲大片一区二区三区| 久久黄色级2电影| 成人激情视频网站| 欧美亚洲国产一卡| 日韩精品一区二区三区视频播放 | 亚洲美女免费在线| 水野朝阳av一区二区三区| 麻豆精品视频在线观看免费| 国产乱码精品一区二区三区五月婷| 国产成人免费视频网站高清观看视频| 成人黄色av电影| 欧洲色大大久久| 欧美va在线播放| 亚洲欧洲一区二区在线播放| 午夜在线成人av| 国产乱码精品一区二区三区忘忧草| 99视频一区二区| 欧美日韩国产成人在线91| 久久女同精品一区二区| 国产精品久久三区| 婷婷国产v国产偷v亚洲高清| 国产a久久麻豆| 欧美精选一区二区| 国产精品灌醉下药二区| 偷偷要91色婷婷| 成人激情文学综合网| 91精品欧美久久久久久动漫| 国产精品天干天干在线综合| 偷窥国产亚洲免费视频| 成人一区二区三区中文字幕| 欧美婷婷六月丁香综合色| 国产欧美日韩麻豆91| 午夜视频一区二区| 成人av手机在线观看| 精品国产1区二区| 亚洲精品成人悠悠色影视| 激情伊人五月天久久综合| 色激情天天射综合网| 日本一区二区三区久久久久久久久不| 一区二区免费在线| 成人美女视频在线观看| 精品国产精品一区二区夜夜嗨| 亚洲乱码中文字幕| 丁香婷婷综合网| 精品国产伦一区二区三区观看方式 | 欧美成人综合网站| 亚洲成人自拍偷拍| 99re视频这里只有精品| 国产午夜亚洲精品午夜鲁丝片| 日韩精品五月天| 欧美在线免费视屏| 亚洲男人的天堂av| 国产二区国产一区在线观看| 日韩欧美一级二级三级久久久| 亚洲国产日韩a在线播放性色| 91日韩精品一区| 国产精品国产三级国产普通话三级| 国产精品羞羞答答xxdd| 欧美成人伊人久久综合网| 美国毛片一区二区三区| 69p69国产精品| 免费观看成人鲁鲁鲁鲁鲁视频| 欧美性欧美巨大黑白大战| 一区二区免费看| 99re亚洲国产精品| 亚洲精品久久久蜜桃| 91一区在线观看| 一区二区在线观看免费视频播放| 不卡大黄网站免费看| 国产精品家庭影院| 色欲综合视频天天天|