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

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

?? principalcomponents.java

?? 一個數據挖掘系統的源碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
	: m_transformedFormat.numAttributes() - 1;

      double [][] orderedVectors =
	new double [m_eigenvectors.length][numVectors + 1];

      // try converting back to the original space
      for (int i = m_numAttribs - 1; i > (m_numAttribs - numVectors - 1); i--) {
	for (int j = 0; j < m_numAttribs; j++) {
	  orderedVectors[j][m_numAttribs - i] =
	    m_eigenvectors[j][m_sortedEigens[i]];
	}
      }

      // transpose the matrix
      int nr = orderedVectors.length;
      int nc = orderedVectors[0].length;
      m_eTranspose =
	new double [nc][nr];
      for (int i = 0; i < nc; i++) {
	for (int j = 0; j < nr; j++) {
	  m_eTranspose[i][j] = orderedVectors[j][i];
	}
      }
    }
  }

  /**
   * Returns just the header for the transformed data (ie. an empty
   * set of instances. This is so that AttributeSelection can
   * determine the structure of the transformed data without actually
   * having to get all the transformed data through getTransformedData().
   * @return the header of the transformed data.
   * @exception Exception if the header of the transformed data can't
   * be determined.
   */
  public Instances transformedHeader() throws Exception {
    if (m_eigenvalues == null) {
      throw new Exception("Principal components hasn't been built yet");
    }
    if (m_transBackToOriginal) {
      return m_originalSpaceFormat;
    } else {
      return m_transformedFormat;
    }
  }

  /**
   * Gets the transformed training data.
   * @return the transformed training data
   * @exception Exception if transformed data can't be returned
   */
  public Instances transformedData() throws Exception {
    if (m_eigenvalues == null) {
      throw new Exception("Principal components hasn't been built yet");
    }

    Instances output;

    if (m_transBackToOriginal) {
      output = new Instances(m_originalSpaceFormat);
    } else {
      output = new Instances(m_transformedFormat);
    }
    for (int i=0;i<m_trainCopy.numInstances();i++) {
      Instance converted = convertInstance(m_trainCopy.instance(i));
      output.add(converted);
    }

    return output;
  }

  /**
   * Evaluates the merit of a transformed attribute. This is defined
   * to be 1 minus the cumulative variance explained. Merit can't
   * be meaningfully evaluated if the data is to be transformed back
   * to the original space.
   * @param att the attribute to be evaluated
   * @return the merit of a transformed attribute
   * @exception Exception if attribute can't be evaluated
   */
  public double evaluateAttribute(int att) throws Exception {
    if (m_eigenvalues == null) {
      throw new Exception("Principal components hasn't been built yet!");
    }

    if (m_transBackToOriginal) {
      return 1.0; // can't evaluate back in the original space!
    }

    // return 1-cumulative variance explained for this transformed att
    double cumulative = 0.0;
    for (int i = m_numAttribs - 1; i >= m_numAttribs - att - 1; i--) {
      cumulative += m_eigenvalues[m_sortedEigens[i]];
    }

    return 1.0 - cumulative / m_sumOfEigenValues;
  }

  /**
   * Fill the correlation matrix
   */
  private void fillCorrelation() {
    m_correlation = new double[m_numAttribs][m_numAttribs];
    double [] att1 = new double [m_numInstances];
    double [] att2 = new double [m_numInstances];
    double corr;

    for (int i = 0; i < m_numAttribs; i++) {
      for (int j = 0; j < m_numAttribs; j++) {
	if (i == j) {
	  m_correlation[i][j] = 1.0;
	} else {
	  for (int k = 0; k < m_numInstances; k++) {
	    att1[k] = m_trainInstances.instance(k).value(i);
	    att2[k] = m_trainInstances.instance(k).value(j);
	  }
	  corr = Utils.correlation(att1,att2,m_numInstances);
	  m_correlation[i][j] = corr;
	  m_correlation[i][j] = corr;
	}
      }
    }
  }

  /**
   * Return a summary of the analysis
   * @return a summary of the analysis.
   */
  private String principalComponentsSummary() {
    StringBuffer result = new StringBuffer();
    double cumulative = 0.0;
    Instances output = null;
    int numVectors=0;

    try {
      output = setOutputFormat();
      numVectors = (output.classIndex() < 0)
	? output.numAttributes()
	: output.numAttributes()-1;
    } catch (Exception ex) {
    }
    //tomorrow
    result.append("Correlation matrix\n"+matrixToString(m_correlation)
		  +"\n\n");
    result.append("eigenvalue\tproportion\tcumulative\n");
    for (int i = m_numAttribs - 1; i > (m_numAttribs - numVectors - 1); i--) {
      cumulative+=m_eigenvalues[m_sortedEigens[i]];
      result.append(Utils.doubleToString(m_eigenvalues[m_sortedEigens[i]],9,5)
		    +"\t"+Utils.
		    doubleToString((m_eigenvalues[m_sortedEigens[i]] /
				    m_sumOfEigenValues),
				     9,5)
		    +"\t"+Utils.doubleToString((cumulative /
						m_sumOfEigenValues),9,5)
		    +"\t"+output.attribute(m_numAttribs - i - 1).name()+"\n");
    }

    result.append("\nEigenvectors\n");
    for (int j = 1;j <= numVectors;j++) {
      result.append(" V"+j+'\t');
    }
    result.append("\n");
    for (int j = 0; j < m_numAttribs; j++) {

      for (int i = m_numAttribs - 1; i > (m_numAttribs - numVectors - 1); i--) {
	result.append(Utils.
		      doubleToString(m_eigenvectors[j][m_sortedEigens[i]],7,4)
		      +"\t");
      }
      result.append(m_trainInstances.attribute(j).name()+'\n');
    }

    if (m_transBackToOriginal) {
      result.append("\nPC space transformed back to original space.\n"
		    +"(Note: can't evaluate attributes in the original "
		    +"space)\n");
    }
    return result.toString();
  }

  /**
   * Returns a description of this attribute transformer
   * @return a String describing this attribute transformer
   */
  public String toString() {
    if (m_eigenvalues == null) {
      return "Principal components hasn't been built yet!";
    } else {
      return "\tPrincipal Components Attribute Transformer\n\n"
	+principalComponentsSummary();
    }
  }

  /**
   * Return a matrix as a String
   * @param matrix that is decribed as a string
   * @return a String describing a matrix
   */
  private String matrixToString(double [][] matrix) {
    StringBuffer result = new StringBuffer();
    int last = matrix.length - 1;

    for (int i = 0; i <= last; i++) {
      for (int j = 0; j <= last; j++) {
	result.append(Utils.doubleToString(matrix[i][j],6,2)+" ");
	if (j == last) {
	  result.append('\n');
	}
      }
    }
    return result.toString();
  }

  /**
   * Convert a pc transformed instance back to the original space
   */
  private Instance convertInstanceToOriginal(Instance inst)
    throws Exception {
    double[] newVals;

    if (m_hasClass) {
      newVals = new double[m_numAttribs+1];
    } else {
      newVals = new double[m_numAttribs];
    }

    if (m_hasClass) {
      // class is always appended as the last attribute
      newVals[m_numAttribs] = inst.value(inst.numAttributes());
    }

    for (int i = 1; i < m_eTranspose[0].length; i++) {
      double tempval = 0.0;
      for (int j=1;j<m_eTranspose.length;j++) {
	tempval += (m_eTranspose[j][i] *
		    inst.value(j));
       }
      newVals[i - 1] = tempval;
    }

    if (inst instanceof SparseInstance) {
      return new SparseInstance(inst.weight(), newVals);
    } else {
      return new Instance(inst.weight(), newVals);
    }
  }

  /**
   * Transform an instance in original (unormalized) format. Convert back
   * to the original space if requested.
   * @param instance an instance in the original (unormalized) format
   * @return a transformed instance
   * @exception Exception if instance cant be transformed
   */
  public Instance convertInstance(Instance instance) throws Exception {

    if (m_eigenvalues == null) {
      throw new Exception("convertInstance: Principal components not "
			  +"built yet");
    }

    double[] newVals = new double[m_outputNumAtts];
    Instance tempInst = (Instance)instance.copy();
    if (!instance.equalHeaders(m_trainCopy.instance(0))) {
      throw new Exception("Can't convert instance: header's don't match: "
			  +"PrincipalComponents");
    }

    m_replaceMissingFilter.input(tempInst);
    m_replaceMissingFilter.batchFinished();
    tempInst = m_replaceMissingFilter.output();

    if (m_normalize) {
      m_normalizeFilter.input(tempInst);
      m_normalizeFilter.batchFinished();
      tempInst = m_normalizeFilter.output();
    }

    m_nominalToBinFilter.input(tempInst);
    m_nominalToBinFilter.batchFinished();
    tempInst = m_nominalToBinFilter.output();

    if (m_attributeFilter != null) {
      m_attributeFilter.input(tempInst);
      m_attributeFilter.batchFinished();
      tempInst = m_attributeFilter.output();
    }

    if (m_hasClass) {
       newVals[m_outputNumAtts - 1] = instance.value(instance.classIndex());
    }

    double cumulative = 0;
    for (int i = m_numAttribs - 1; i >= 0; i--) {
      double tempval = 0.0;
      for (int j = 0; j < m_numAttribs; j++) {
	tempval += (m_eigenvectors[j][m_sortedEigens[i]] *
		    tempInst.value(j));
       }
      newVals[m_numAttribs - i] = tempval;
      cumulative+=m_eigenvalues[m_sortedEigens[i]];
      if ((cumulative / m_sumOfEigenValues) >= m_coverVariance) {
	break;
      }
    }

    if (!m_transBackToOriginal) {
      if (instance instanceof SparseInstance) {
      return new SparseInstance(instance.weight(), newVals);
      } else {
	return new Instance(instance.weight(), newVals);
      }
    } else {
      if (instance instanceof SparseInstance) {
	return convertInstanceToOriginal(new SparseInstance(instance.weight(),
							    newVals));
      } else {
	return convertInstanceToOriginal(new Instance(instance.weight(),
						      newVals));
      }
    }
  }

  /**
   * Set up the header for the PC->original space dataset
   */
  private Instances setOutputFormatOriginal() throws Exception {
    FastVector attributes = new FastVector();

    for (int i = 0; i < m_numAttribs; i++) {
      String att = m_trainInstances.attribute(i).name();
      attributes.addElement(new Attribute(att));
    }

    if (m_hasClass) {
      attributes.addElement(m_trainCopy.classAttribute().copy());
    }

    Instances outputFormat =
      new Instances(m_trainCopy.relationName()+"->PC->original space",
		    attributes, 0);

    // set the class to be the last attribute if necessary
    if (m_hasClass) {
      outputFormat.setClassIndex(outputFormat.numAttributes()-1);
    }

    return outputFormat;
  }

  /**
   * Set the format for the transformed data
   * @return a set of empty Instances (header only) in the new format
   * @exception Exception if the output format can't be set
   */
  private Instances setOutputFormat() throws Exception {
    if (m_eigenvalues == null) {
      return null;
    }

    double cumulative = 0.0;
    FastVector attributes = new FastVector();
     for (int i = m_numAttribs - 1; i >= 0; i--) {
       StringBuffer attName = new StringBuffer();
       for (int j = 0; j < m_numAttribs; j++) {
	 attName.append(Utils.
			doubleToString(m_eigenvectors[j][m_sortedEigens[i]],
				       5,3)
			+m_trainInstances.attribute(j).name());
	 if (j != m_numAttribs - 1) {
	   if (m_eigenvectors[j+1][m_sortedEigens[i]] >= 0) {
	     attName.append("+");
	   }
	 }
       }
       attributes.addElement(new Attribute(attName.toString()));
       cumulative+=m_eigenvalues[m_sortedEigens[i]];

       if ((cumulative / m_sumOfEigenValues) >= m_coverVariance) {
	 break;
       }
     }

     if (m_hasClass) {
       attributes.addElement(m_trainCopy.classAttribute().copy());
     }

     Instances outputFormat =
       new Instances(m_trainInstances.relationName()+"_principal components",
		     attributes, 0);

     // set the class to be the last attribute if necessary
     if (m_hasClass) {
       outputFormat.setClassIndex(outputFormat.numAttributes()-1);
     }

     m_outputNumAtts = outputFormat.numAttributes();
     return outputFormat;
  }


  /**
   * Main method for testing this class
   * @param argv should contain the command line arguments to the
   * evaluator/transformer (see AttributeSelection)
   */
  public static void main(String [] argv) {
    try {
      System.out.println(AttributeSelection.
			 SelectAttributes(new PrincipalComponents(), argv));
    }
    catch (Exception e) {
      log.error(e.getStackTrace().toString());
      log.error(e.getMessage());
    }
  }

}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成国产人片在线观看| 国产精品 欧美精品| 极品少妇一区二区| 91麻豆免费观看| xnxx国产精品| 婷婷成人综合网| 99国内精品久久| 国产婷婷精品av在线| 老司机免费视频一区二区| 在线免费观看日本一区| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 国产精品久久久久一区二区三区| 午夜精品福利视频网站| 色久优优欧美色久优优| 中文字幕一区二区三| 国产精品99久久久久久久女警| 在线精品国精品国产尤物884a| 91精品国产色综合久久不卡蜜臀 | 欧美mv日韩mv国产网站app| 亚洲日本欧美天堂| 国产精品一区二区久久精品爱涩 | 粉嫩高潮美女一区二区三区| 欧美四级电影在线观看| 国产精品每日更新在线播放网址| 午夜精品福利一区二区蜜股av | 国产精品免费av| 国产资源在线一区| 欧美日韩国产综合久久| 日韩在线播放一区二区| 91小视频在线观看| 国产精品美女久久久久aⅴ| 日产国产欧美视频一区精品| 欧美最新大片在线看| 亚洲精品高清视频在线观看| 成人激情图片网| 久久无码av三级| 久草精品在线观看| 欧美日韩亚洲另类| 亚洲一区二区黄色| 91免费观看视频在线| 亚洲欧美在线另类| www.视频一区| 日韩美女精品在线| 91丝袜美女网| 亚洲丝袜另类动漫二区| 99久久婷婷国产精品综合| 欧美国产在线观看| av电影天堂一区二区在线观看| 国产日韩三级在线| av一二三不卡影片| 一区二区三区美女| 91精品国产高清一区二区三区蜜臀| 亚洲天堂福利av| 欧美精品丝袜久久久中文字幕| 午夜亚洲国产au精品一区二区| 欧美精品在线观看播放| 日本不卡中文字幕| 欧美精品一区二区三区高清aⅴ | 在线视频亚洲一区| 一区二区三区四区高清精品免费观看| 成人爱爱电影网址| 亚洲图片你懂的| 91久久精品网| 奇米影视一区二区三区| 这里只有精品99re| 久久成人免费电影| 国产精品福利电影一区二区三区四区| 99视频精品在线| 日韩精品国产欧美| 欧美高清激情brazzers| 免费人成精品欧美精品| 日韩欧美一二区| 成人黄色电影在线| 亚洲成人1区2区| 国产婷婷精品av在线| 一本到高清视频免费精品| 日精品一区二区三区| wwwwww.欧美系列| 色婷婷综合五月| 蜜臀av一区二区| 亚洲欧洲在线观看av| 在线电影一区二区三区| 国产成+人+日韩+欧美+亚洲| 洋洋av久久久久久久一区| 欧美成人国产一区二区| 99re亚洲国产精品| 日韩电影在线看| 中文字幕欧美一| 欧美成人vps| 91福利国产精品| 国产美女一区二区| 亚洲一二三四区不卡| 久久老女人爱爱| 在线精品视频一区二区| 日韩欧美国产麻豆| 国产三区在线成人av| 欧美日韩日日夜夜| 国产成人亚洲综合色影视| 日韩中文字幕区一区有砖一区| 中文字幕在线一区免费| 久久久久国色av免费看影院| 欧美精品v日韩精品v韩国精品v| 大陆成人av片| 久久超碰97中文字幕| 日本va欧美va精品发布| 一区二区三区四区av| 欧美激情一区在线观看| 7878成人国产在线观看| 日本精品一区二区三区四区的功能| 韩国视频一区二区| 日本在线不卡视频一二三区| 亚洲美女视频在线观看| 亚洲欧洲精品成人久久奇米网| 26uuu精品一区二区三区四区在线| 欧美日韩精品一区二区三区四区| jizzjizzjizz欧美| 床上的激情91.| 国产91丝袜在线播放九色| 精品一区二区成人精品| 午夜成人免费视频| 亚洲欧美日韩在线| 亚洲免费在线视频一区 二区| 国产欧美一区二区精品仙草咪| 日韩一级完整毛片| 日韩一区二区三| 欧美一级久久久| 91精品国产欧美一区二区18 | 欧美一级夜夜爽| 6080日韩午夜伦伦午夜伦| 91蜜桃网址入口| 不卡视频一二三| 在线观看av一区| 欧美日韩国产高清一区二区三区 | 6080日韩午夜伦伦午夜伦| 在线日韩av片| 欧美日韩一级二级三级| 9191成人精品久久| 欧美一区二区三区的| 欧美日本韩国一区| 欧美亚洲自拍偷拍| 欧美久久久久久久久| 欧美日韩的一区二区| 欧美一级夜夜爽| 精品成人佐山爱一区二区| 精品嫩草影院久久| 久久久精品一品道一区| 国产精品剧情在线亚洲| 亚洲精品一二三| 日韩精品亚洲专区| 久久国产欧美日韩精品| 国产69精品久久久久毛片| 99re热视频精品| 91精品欧美综合在线观看最新| 日韩欧美电影在线| 国产日韩av一区| 亚洲色图20p| 中文字幕一区二区三区精华液 | 一区二区三区毛片| 五月婷婷激情综合| 久久国产人妖系列| 不卡的av网站| 91.com视频| 国产精品国产三级国产普通话三级| 国产精品成人网| 午夜精品久久久久影视| 国产一区91精品张津瑜| 91亚洲大成网污www| 日韩一级片网站| 亚洲欧洲日本在线| 日本系列欧美系列| 不卡的av网站| 欧美一级二级在线观看| 欧美激情一区三区| ●精品国产综合乱码久久久久| 亚洲精品第一国产综合野| 免费观看在线综合| 99久久精品国产精品久久| 日韩免费性生活视频播放| 欧美成人vr18sexvr| 一区二区三区精品久久久| 国产美女精品在线| 欧美巨大另类极品videosbest| 欧美国产成人在线| 日韩avvvv在线播放| 色婷婷综合五月| 国产精品三级久久久久三级| 天天亚洲美女在线视频| 不卡在线视频中文字幕| 欧美v亚洲v综合ⅴ国产v| 亚洲精品综合在线| 成人黄色在线网站| 久久久久国产成人精品亚洲午夜| 亚洲成年人影院| 国产suv一区二区三区88区| 欧美一区二区视频观看视频| 国产精品成人网| 国产美女娇喘av呻吟久久| 久久久精品中文字幕麻豆发布| 奇米影视一区二区三区| 精品精品国产高清a毛片牛牛|