本文整理汇总了Java中weka.filters.unsupervised.attribute.Standardize.setInputFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Standardize.setInputFormat方法的具体用法?Java Standardize.setInputFormat怎么用?Java Standardize.setInputFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weka.filters.unsupervised.attribute.Standardize
的用法示例。
在下文中一共展示了Standardize.setInputFormat方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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()) );
}
}
示例2: 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;
}
示例3: 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);
}
示例4: 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);
}
示例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);
}
示例6: 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);
}
}
示例7: 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);
}
}