本文整理汇总了Java中weka.filters.supervised.instance.Resample类的典型用法代码示例。如果您正苦于以下问题:Java Resample类的具体用法?Java Resample怎么用?Java Resample使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Resample类属于weka.filters.supervised.instance包,在下文中一共展示了Resample类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getEvalResultbyResampling
import weka.filters.supervised.instance.Resample; //导入依赖的package包/类
/***
* <p>To get 10-fold cross validation in one single arff in <b>path</b></p>
* <p>Use C4.5 and <b>Resampling</b> to classify the dataset.</p>
* @param path dataset path
* @throws Exception
*/
public static void getEvalResultbyResampling(String path, int index) throws Exception{
Instances ins = DataSource.read(path);
int numAttr = ins.numAttributes();
ins.setClassIndex(numAttr - 1);
Resample resample = new Resample();
resample.setInputFormat(ins);
/** classifiers setting*/
J48 j48 = new J48();
// j48.setConfidenceFactor(0.4f);
j48.buildClassifier(ins);
FilteredClassifier fc = new FilteredClassifier();
fc.setClassifier(j48);
fc.setFilter(resample);
Evaluation eval = new Evaluation(ins);
eval.crossValidateModel(fc, ins, 10, new Random(1));
// System.out.printf(" %4.3f %4.3f %4.3f", eval.precision(0), eval.recall(0), eval.fMeasure(0));
// System.out.printf(" %4.3f %4.3f %4.3f", eval.precision(1), eval.recall(1), eval.fMeasure(1));
// System.out.printf(" %4.3f \n\n", (1-eval.errorRate()));
results[index][0] = eval.precision(0);
results[index][1] = eval.recall(0);
results[index][2] = eval.fMeasure(0);
results[index][3] = eval.precision(1);
results[index][4] = eval.recall(1);
results[index][5] = eval.fMeasure(1);
results[index][6] = 1-eval.errorRate();
}
开发者ID:Gu-Youngfeng,项目名称:CraTer,代码行数:40,代码来源:ImbalanceProcessingAve.java
示例2: _getTrainingFromParams
import weka.filters.supervised.instance.Resample; //导入依赖的package包/类
public Instances _getTrainingFromParams(String params)
{
Resample filter = newFilter();
filter.setInvertSelection(false);
setFilterParams(filter, params);
return getInstances(getTraining(), filter);
}
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:8,代码来源:RandomSubSampling.java
示例3: _getTestingFromParams
import weka.filters.supervised.instance.Resample; //导入依赖的package包/类
public Instances _getTestingFromParams(String params)
{
//Get the instances filtered (Not we use the training data here)
Resample filter = newFilter();
filter.setInvertSelection(true);
setFilterParams(filter, params);
return getInstances(getTraining(), filter);
}
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:10,代码来源:RandomSubSampling.java
示例4: newFilter
import weka.filters.supervised.instance.Resample; //导入依赖的package包/类
protected final Resample newFilter(){
Resample filter = new Resample();
try{
filter.setInputFormat(getTraining());
}catch(Exception e){
filter = new RegressionResample();
}
return filter;
}
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:10,代码来源:RandomSubSampling.java
示例5: setFilterParams
import weka.filters.supervised.instance.Resample; //导入依赖的package包/类
private void setFilterParams(Resample filter, String paramStr)
{
Properties params = Util.parsePropertyString(paramStr);
filter.setNoReplacement(true);
filter.setRandomSeed(Integer.parseInt(params.getProperty("seed", "0")));
filter.setSampleSizePercent(Double.parseDouble(params.getProperty("percent", "70")));
filter.setBiasToUniformClass(Double.parseDouble(params.getProperty("base", "0")));
}
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:9,代码来源:RandomSubSampling.java
示例6: getInstancesFromParamsForSubClass
import weka.filters.supervised.instance.Resample; //导入依赖的package包/类
private Instances getInstancesFromParamsForSubClass(String params, boolean invert)
{
Resample filter = newFilter();
filter.setInvertSelection(false);
int level = setFilterParams(filter, params);
Instances instances = getTraining();
for(int i = 0; i <= level-1; i++)
instances = getInstances(instances, filter);
filter.setInvertSelection(invert);
return getInstances(instances, filter);
}
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:14,代码来源:MultiLevel.java
示例7: setFilterParams
import weka.filters.supervised.instance.Resample; //导入依赖的package包/类
private int setFilterParams(Resample filter, String paramStr)
{
Properties params = Util.parsePropertyString(paramStr);
filter.setNoReplacement(true);
if(!"{SEED}".equals(params.getProperty("levelSeed")))
filter.setRandomSeed(Integer.parseInt(params.getProperty("levelSeed", "0")));
filter.setSampleSizePercent(Double.parseDouble(params.getProperty("levelPercent", "70")));
filter.setBiasToUniformClass(Double.parseDouble(params.getProperty("levelBias", "0")));
int level = Integer.parseInt(params.getProperty("level", "-1"));
if(level < 0)
throw new RuntimeException("Invalid level '" + level+ "'");
return level;
}
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:14,代码来源:MultiLevel.java
示例8: getInstancesFromParamsForSubClass
import weka.filters.supervised.instance.Resample; //导入依赖的package包/类
private Instances getInstancesFromParamsForSubClass(String params, boolean invert)
{
Resample filter = newFilter();
filter.setInvertSelection(invert);
setFilterParams(filter, params);
return getInstances(getTraining(), filter);
}
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:9,代码来源:TerminationHoldout.java
示例9: setFilterParams
import weka.filters.supervised.instance.Resample; //导入依赖的package包/类
private void setFilterParams(Resample filter, String paramStr)
{
Properties params = Util.parsePropertyString(paramStr);
filter.setNoReplacement(true);
if(!"{SEED}".equals(params.getProperty("terminationSeed")))
filter.setRandomSeed(Integer.parseInt(params.getProperty("terminationSeed", "0")));
filter.setSampleSizePercent(Double.parseDouble(params.getProperty("terminationPercent", "30")));
filter.setBiasToUniformClass(Double.parseDouble(params.getProperty("terminationBias", "0")));
}
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:11,代码来源:TerminationHoldout.java
示例10: downsample
import weka.filters.supervised.instance.Resample; //导入依赖的package包/类
private Instances downsample(Instances stringsReplacedData, double percent) throws Exception {
Instances reduced;
Resample sampler = new Resample();
sampler.setRandomSeed(1);
//do not change distribution
sampler.setBiasToUniformClass(0);
sampler.setSampleSizePercent(percent);
sampler.setInputFormat(stringsReplacedData);
reduced = Filter.useFilter(stringsReplacedData, sampler);
return reduced;
}
开发者ID:ag-gipp,项目名称:mathosphere,代码行数:12,代码来源:WekaLearner.java
示例11: dumbResample
import weka.filters.supervised.instance.Resample; //导入依赖的package包/类
private Instances dumbResample(Instances reduced) throws Exception {
Resample resampleFilter = new Resample();
resampleFilter.setRandomSeed(1);
resampleFilter.setBiasToUniformClass(1);
resampleFilter.setInputFormat(reduced);
return Filter.useFilter(reduced, resampleFilter);
}
开发者ID:ag-gipp,项目名称:mathosphere,代码行数:8,代码来源:WekaLearner.java
注:本文中的weka.filters.supervised.instance.Resample类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论