当前位置: 首页>>代码示例>>Java>>正文


Java Standardize类代码示例

本文整理汇总了Java中weka.filters.unsupervised.attribute.Standardize的典型用法代码示例。如果您正苦于以下问题:Java Standardize类的具体用法?Java Standardize怎么用?Java Standardize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Standardize类属于weka.filters.unsupervised.attribute包,在下文中一共展示了Standardize类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: preProcessData

import weka.filters.unsupervised.attribute.Standardize; //导入依赖的package包/类
/**
 * 
 * @param data the data to transform
 * @param shouldImpute impute the data?
 * @param shouldStandardize standardize the numeric attributes?
 * @param shouldBinarize binarize the attributes?
 * @return the transformed data
 * @throws Exception
 */
public static Instances preProcessData(Instances data, boolean shouldImpute, 
		boolean shouldStandardize, boolean shouldBinarize) throws Exception {
    if( shouldImpute ) {
    	Filter impute = new ReplaceMissingValues();
    	impute.setInputFormat(data);
		data = Filter.useFilter(data, impute);
    }
	if( shouldStandardize ) {
		Filter standardize = new Standardize();
		standardize.setInputFormat(data);
		data = Filter.useFilter(data, standardize);
	}
	if( shouldBinarize ) {
		Filter binarize = new NominalToBinary();
		binarize.setInputFormat(data);
    	// make resulting binary attrs nominal, not numeric
		binarize.setOptions(new String[] { "-N" } );
    	data = Filter.useFilter(data, binarize);
	}
	return data;
}
 
开发者ID:christopher-beckham,项目名称:weka-pyscript,代码行数:31,代码来源:Utility.java

示例2: testStandardise

import weka.filters.unsupervised.attribute.Standardize; //导入依赖的package包/类
/**
 * See if the standardise filter example behaves in the
 * exact same way as the one in WEKA.
 * @throws Exception
 */
@Test
public void testStandardise() throws Exception {
	DataSource ds = new DataSource("datasets/iris.arff");
	Instances data = ds.getDataSet();
	data.setClassIndex( data.numAttributes() - 1 );
	PyScriptFilter filter = new PyScriptFilter();
	filter.setPythonFile(new File("scripts/standardise.py"));
	filter.setInputFormat(data);
	
	Instances pyscriptData = Filter.useFilter(data, filter);
	
	Standardize filter2 = new Standardize();
	filter2.setInputFormat(data);
	
	Instances defaultStdData = Filter.useFilter(data, filter2);
	
	// test instances
	for(int x = 0; x < data.numInstances(); x++) {
		assertTrue( pyscriptData.get(x).toString().equals(defaultStdData.get(x).toString()) );
	}
}
 
开发者ID:christopher-beckham,项目名称:weka-pyscript,代码行数:27,代码来源:PyScriptFilterTest.java

示例3: createStandardizationFilter

import weka.filters.unsupervised.attribute.Standardize; //导入依赖的package包/类
/**
 * Standardizes the given data
 * 
 * @param isTrainingSet
 *            the Instances to be standardized
 * @return the standardized Instances
 */
public Standardize createStandardizationFilter(Instances isTrainingSet) {

	//Instances isTrainingSet_stand = null;

	Standardize filter = new Standardize();
	try {
		filter.setInputFormat(isTrainingSet); // initializing the filter
												// once with training set
		//isTrainingSet_stand = Filter.useFilter(isTrainingSet, filter);

	} catch (Exception e) {
		
		e.printStackTrace();
	}

	return filter;
}
 
开发者ID:socialsensor,项目名称:computational-verification,代码行数:25,代码来源:DataHandler.java

示例4: featureNormalize

import weka.filters.unsupervised.attribute.Standardize; //导入依赖的package包/类
public static Instances featureNormalize(Instances X, Standardize standartize) {
  Instances nX = null;
  try {

    nX = Filter.useFilter(X, standartize);    

  } catch (Exception e) {
    log.error("featureNormalize: caught exception ", e);
  }
  return nX;
}
 
开发者ID:LARG,项目名称:TacTex,代码行数:12,代码来源:RegressionUtils.java

示例5: fillCorrelation

import weka.filters.unsupervised.attribute.Standardize; //导入依赖的package包/类
/**
 * Fill the correlation matrix
 */
private void fillCorrelation() throws Exception {
  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++) {
      for (int k = 0; k < m_numInstances; k++) {
        att1[k] = m_trainInstances.instance(k).value(i);
        att2[k] = m_trainInstances.instance(k).value(j);
      }
      if (i == j) {
        m_correlation[i][j] = 1.0;
          // store the standard deviation
        m_stdDevs[i] = Math.sqrt(Utils.variance(att1));
      } else {
        corr = Utils.correlation(att1,att2,m_numInstances);
        m_correlation[i][j] = corr;
        m_correlation[j][i] = corr;
      }
    }
  }
  
  // now standardize the input data
  m_standardizeFilter = new Standardize();
  m_standardizeFilter.setInputFormat(m_trainInstances);
  m_trainInstances = Filter.useFilter(m_trainInstances, m_standardizeFilter);
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:33,代码来源:PrincipalComponents.java

示例6: fillCorrelation

import weka.filters.unsupervised.attribute.Standardize; //导入依赖的package包/类
/**
 * Fill the correlation matrix
 */
private void fillCorrelation() throws Exception {
  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++) {
      for (int k = 0; k < m_numInstances; k++) {
        att1[k] = m_trainInstances.instance(k).value(i);
        att2[k] = m_trainInstances.instance(k).value(j);
      }
      if (i == j) {
        m_correlation[i][j] = 1.0;
        // store the standard deviation
        m_stdDevs[i] = Math.sqrt(Utils.variance(att1));
      } else {
        corr = Utils.correlation(att1, att2, m_numInstances);
        m_correlation[i][j] = corr;
        m_correlation[j][i] = corr;
      }
    }
  }

  // now standardize the input data
  m_standardizeFilter = new Standardize();
  m_standardizeFilter.setInputFormat(m_trainInstances);
  m_trainInstances = Filter.useFilter(m_trainInstances, m_standardizeFilter);
}
 
开发者ID:umple,项目名称:umple,代码行数:33,代码来源:PrincipalComponents.java

示例7: fillCorrelation

import weka.filters.unsupervised.attribute.Standardize; //导入依赖的package包/类
/**
 * Fill the correlation matrix
 */
private void fillCorrelation() throws Exception {
  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++) {
      for (int k = 0; k < m_numInstances; k++) {
        att1[k] = m_trainInstances.instance(k).value(i);
        att2[k] = m_trainInstances.instance(k).value(j);
      }
      if (i == j) {
        m_correlation[i][j] = 1.0;
          // store the standard deviation
          m_stdDevs[i] = Math.sqrt(Utils.variance(att1));
      } else {
        corr = Utils.correlation(att1,att2,m_numInstances);
        m_correlation[i][j] = corr;
        m_correlation[j][i] = corr;
      }
    }
  }
  
  // now standardize the input data
  m_standardizeFilter = new Standardize();
  m_standardizeFilter.setInputFormat(m_trainInstances);
  m_trainInstances = Filter.useFilter(m_trainInstances, m_standardizeFilter);
}
 
开发者ID:williamClanton,项目名称:jbossBA,代码行数:33,代码来源:PrincipalComponents.java

示例8: standardizeData

import weka.filters.unsupervised.attribute.Standardize; //导入依赖的package包/类
public Instances standardizeData(Instances isTrainingSet, int classIndex,  Standardize filter) {
	Instances isTrainingSet_stand = null;
	
	try {
		isTrainingSet_stand = Filter.useFilter(isTrainingSet, filter);
		isTrainingSet_stand.setClassIndex(classIndex);
	} catch (Exception e) {
		System.out.println("Data Standardization cannot be performed! Please check your data!");
		e.printStackTrace();
	}
	
	return isTrainingSet_stand;
}
 
开发者ID:socialsensor,项目名称:computational-verification,代码行数:14,代码来源:DataHandler.java

示例9: WekaLinRegData

import weka.filters.unsupervised.attribute.Standardize; //导入依赖的package包/类
public WekaLinRegData(Standardize standardize, LinearRegression linearRegression, int timeslot) {
  this.standardize = standardize;      
  this.linearRegression = linearRegression;
  this.timeslot = timeslot;      
}
 
开发者ID:LARG,项目名称:TacTex,代码行数:6,代码来源:RegressionUtils.java

示例10: getStandardize

import weka.filters.unsupervised.attribute.Standardize; //导入依赖的package包/类
public Standardize getStandardize() {
  return standardize;
}
 
开发者ID:LARG,项目名称:TacTex,代码行数:4,代码来源:RegressionUtils.java

示例11: buildClassifier

import weka.filters.unsupervised.attribute.Standardize; //导入依赖的package包/类
/**
 * Builds the classifier
 * 
 * @param instances the training data
 * @throws Exception if the classifier could not be built successfully
 */
@Override
public void buildClassifier(Instances instances) throws Exception {

  // can classifier handle the data?
  getCapabilities().testWithFail(instances);

  // remove instances with missing class
  instances = new Instances(instances);
  instances.deleteWithMissingClass();

  // only class? -> build ZeroR model
  if (instances.numAttributes() == 1) {
    System.err
      .println("Cannot build model (only class attribute present in data!), "
        + "using ZeroR model instead!");
    m_ZeroR = new weka.classifiers.rules.ZeroR();
    m_ZeroR.buildClassifier(instances);
    return;
  } else {
    m_ZeroR = null;
  }

  m_standardize = new Standardize();
  m_standardize.setInputFormat(instances);
  instances = Filter.useFilter(instances, m_standardize);

  SimpleKMeans sk = new SimpleKMeans();
  sk.setNumClusters(m_numClusters);
  sk.setSeed(m_clusteringSeed);
  MakeDensityBasedClusterer dc = new MakeDensityBasedClusterer();
  dc.setClusterer(sk);
  dc.setMinStdDev(m_minStdDev);
  m_basisFilter = new ClusterMembership();
  m_basisFilter.setDensityBasedClusterer(dc);
  m_basisFilter.setInputFormat(instances);
  Instances transformed = Filter.useFilter(instances, m_basisFilter);

  if (instances.classAttribute().isNominal()) {
    m_linear = null;
    m_logistic = new Logistic();
    m_logistic.setRidge(m_ridge);
    m_logistic.setMaxIts(m_maxIts);
    m_logistic.buildClassifier(transformed);
  } else {
    m_logistic = null;
    m_linear = new LinearRegression();
    m_linear.setAttributeSelectionMethod(new SelectedTag(
      LinearRegression.SELECTION_NONE, LinearRegression.TAGS_SELECTION));
    m_linear.setRidge(m_ridge);
    m_linear.buildClassifier(transformed);
  }
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:59,代码来源:RBFNetwork.java

示例12: buildClassifier

import weka.filters.unsupervised.attribute.Standardize; //导入依赖的package包/类
/**
 * Builds the classifier
 *
 * @param instances the training data
 * @throws Exception if the classifier could not be built successfully
 */
public void buildClassifier(Instances instances) throws Exception {

  // can classifier handle the data?
  getCapabilities().testWithFail(instances);

  // remove instances with missing class
  instances = new Instances(instances);
  instances.deleteWithMissingClass();
  
  // only class? -> build ZeroR model
  if (instances.numAttributes() == 1) {
    System.err.println(
 "Cannot build model (only class attribute present in data!), "
 + "using ZeroR model instead!");
    m_ZeroR = new weka.classifiers.rules.ZeroR();
    m_ZeroR.buildClassifier(instances);
    return;
  }
  else {
    m_ZeroR = null;
  }
  
  m_standardize = new Standardize();
  m_standardize.setInputFormat(instances);
  instances = Filter.useFilter(instances, m_standardize);

  SimpleKMeans sk = new SimpleKMeans();
  sk.setNumClusters(m_numClusters);
  sk.setSeed(m_clusteringSeed);
  MakeDensityBasedClusterer dc = new MakeDensityBasedClusterer();
  dc.setClusterer(sk);
  dc.setMinStdDev(m_minStdDev);
  m_basisFilter = new ClusterMembership();
  m_basisFilter.setDensityBasedClusterer(dc);
  m_basisFilter.setInputFormat(instances);
  Instances transformed = Filter.useFilter(instances, m_basisFilter);

  if (instances.classAttribute().isNominal()) {
    m_linear = null;
    m_logistic = new Logistic();
    m_logistic.setRidge(m_ridge);
    m_logistic.setMaxIts(m_maxIts);
    m_logistic.buildClassifier(transformed);
  } else {
    m_logistic = null;
    m_linear = new LinearRegression();
    m_linear.setAttributeSelectionMethod(new SelectedTag(LinearRegression.SELECTION_NONE,
					   LinearRegression.TAGS_SELECTION));
    m_linear.setRidge(m_ridge);
    m_linear.buildClassifier(transformed);
  }
}
 
开发者ID:williamClanton,项目名称:jbossBA,代码行数:59,代码来源:RBFNetwork.java


注:本文中的weka.filters.unsupervised.attribute.Standardize类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。