• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Standardize类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IndexingException类代码示例发布时间:2022-05-22
下一篇:
Java Request类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap