本文整理汇总了Java中com.rapidminer.example.set.MappedExampleSet.createBootstrappingMapping方法的典型用法代码示例。如果您正苦于以下问题:Java MappedExampleSet.createBootstrappingMapping方法的具体用法?Java MappedExampleSet.createBootstrappingMapping怎么用?Java MappedExampleSet.createBootstrappingMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rapidminer.example.set.MappedExampleSet
的用法示例。
在下文中一共展示了MappedExampleSet.createBootstrappingMapping方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: estimatePerformance
import com.rapidminer.example.set.MappedExampleSet; //导入方法依赖的package包/类
@Override
public void estimatePerformance(ExampleSet inputSet) throws OperatorException {
number = getParameterAsInt(PARAMETER_NUMBER_OF_VALIDATIONS);
int size = (int) Math.round(inputSet.size() * getParameterAsDouble(PARAMETER_SAMPLE_RATIO));
// start bootstrapping loop
RandomGenerator random = RandomGenerator.getRandomGenerator(this);
for (iteration = 0; iteration < number; iteration++) {
int[] mapping = null;
if (getParameterAsBoolean(PARAMETER_USE_WEIGHTS) && inputSet.getAttributes().getWeight() != null) {
mapping = MappedExampleSet.createWeightedBootstrappingMapping(inputSet, size, random);
} else {
mapping = MappedExampleSet.createBootstrappingMapping(inputSet, size, random);
}
MappedExampleSet trainingSet = new MappedExampleSet((ExampleSet)inputSet.clone(), mapping, true);
learn(trainingSet);
MappedExampleSet inverseExampleSet = new MappedExampleSet((ExampleSet)inputSet.clone(), mapping, false);
evaluate(inverseExampleSet);
inApplyLoop();
}
// end loop
}
示例2: apply
import com.rapidminer.example.set.MappedExampleSet; //导入方法依赖的package包/类
@Override
public ExampleSet apply(ExampleSet exampleSet) throws OperatorException {
RandomGenerator random = RandomGenerator.getRandomGenerator(this);
int size = exampleSet.size();
switch (getParameterAsInt(PARAMETER_SAMPLE)) {
case SAMPLE_ABSOLUTE:
size = getParameterAsInt(PARAMETER_SAMPLE_SIZE);
break;
case SAMPLE_RELATIVE:
size = (int) Math.round(exampleSet.size() * getParameterAsDouble(PARAMETER_SAMPLE_RATIO));
break;
}
int[] mapping = null;
if (getParameterAsBoolean(PARAMETER_USE_WEIGHTS) && exampleSet.getAttributes().getWeight() != null) {
mapping = MappedExampleSet.createWeightedBootstrappingMapping(exampleSet, size, random);
} else {
mapping = MappedExampleSet.createBootstrappingMapping(exampleSet, size, random);
}
return new MappedExampleSet(exampleSet, mapping, true);
}
示例3: estimatePerformance
import com.rapidminer.example.set.MappedExampleSet; //导入方法依赖的package包/类
@Override
public void estimatePerformance(ExampleSet inputSet) throws OperatorException {
number = getParameterAsInt(PARAMETER_NUMBER_OF_VALIDATIONS);
int size = (int) Math.round(inputSet.size() * getParameterAsDouble(PARAMETER_SAMPLE_RATIO));
// start bootstrapping loop
RandomGenerator random = RandomGenerator.getRandomGenerator(this);
getProgress().setTotal(number);
getProgress().setCheckForStop(false);
for (iteration = 0; iteration < number; iteration++) {
int[] mapping = null;
if (getParameterAsBoolean(PARAMETER_USE_WEIGHTS) && inputSet.getAttributes().getWeight() != null) {
mapping = MappedExampleSet.createWeightedBootstrappingMapping(inputSet, size, random);
} else {
mapping = MappedExampleSet.createBootstrappingMapping(inputSet, size, random);
}
MappedExampleSet trainingSet = new MappedExampleSet((ExampleSet) inputSet.clone(), mapping, true);
learn(trainingSet);
MappedExampleSet inverseExampleSet = new MappedExampleSet((ExampleSet) inputSet.clone(), mapping, false);
evaluate(inverseExampleSet);
inApplyLoop();
getProgress().step();
}
// end loop
getProgress().complete();
}
示例4: learn
import com.rapidminer.example.set.MappedExampleSet; //导入方法依赖的package包/类
@Override
public Model learn(ExampleSet inputSet) throws OperatorException {
int iterations = getParameterAsInt(PARAMETER_ITERATIONS);
double subsetRatio = getParameterAsDouble(PARAMETER_USE_SUBSET_FOR_TRAINING);
Model[] models = new Model[iterations];
// get cost matrix
double[][] costMatrix = getParameterAsMatrix(PARAMETER_COST_MATRIX);
// perform bagging operation
if (getParameterAsBoolean(PARAMETER_SAMPLING_WITH_REPLACEMENT)) {
// sampling with replacement
Random randomGenerator = RandomGenerator.getRandomGenerator(this);
int size = (int) (inputSet.size() * subsetRatio);
for (int i = 0; i < iterations; i++) {
ExampleSet exampleSet = (ExampleSet) inputSet.clone();
int[] mapping = MappedExampleSet.createBootstrappingMapping(exampleSet, size, randomGenerator);
MappedExampleSet currentSampleSet = new MappedExampleSet(exampleSet, mapping);
models[i] = applyInnerLearner(currentSampleSet);
inApplyLoop();
}
} else {
// sampling without replacement
for (int i = 0; i < iterations; i++) {
SplittedExampleSet splitted = new SplittedExampleSet((ExampleSet) inputSet.clone(), subsetRatio,
SplittedExampleSet.SHUFFLED_SAMPLING,
getParameterAsBoolean(RandomGenerator.PARAMETER_USE_LOCAL_RANDOM_SEED),
getParameterAsInt(RandomGenerator.PARAMETER_LOCAL_RANDOM_SEED));
splitted.selectSingleSubset(0);
models[i] = applyInnerLearner(splitted);
inApplyLoop();
}
}
return new MetaCostModel(inputSet, models, costMatrix);
}
示例5: apply
import com.rapidminer.example.set.MappedExampleSet; //导入方法依赖的package包/类
@Override
public ExampleSet apply(ExampleSet exampleSet) throws OperatorException {
int size = exampleSet.size();
// cannot bootstrap without any examples
if (size < 1) {
throw new UserError(this, 117);
}
RandomGenerator random = RandomGenerator.getRandomGenerator(this);
switch (getParameterAsInt(PARAMETER_SAMPLE)) {
case SAMPLE_ABSOLUTE:
size = getParameterAsInt(PARAMETER_SAMPLE_SIZE);
break;
case SAMPLE_RELATIVE:
size = (int) Math.round(exampleSet.size() * getParameterAsDouble(PARAMETER_SAMPLE_RATIO));
break;
}
int[] mapping = null;
if (getParameterAsBoolean(PARAMETER_USE_WEIGHTS) && exampleSet.getAttributes().getWeight() != null) {
mapping = MappedExampleSet.createWeightedBootstrappingMapping(exampleSet, size, random);
} else {
mapping = MappedExampleSet.createBootstrappingMapping(exampleSet, size, random);
}
// create and materialize example set
ExampleSet mappedExampleSet = new MappedExampleSet(exampleSet, mapping, true);
if (getCompatibilityLevel().isAbove(VERSION_6_4_0)) {
int type = DataRowFactory.TYPE_DOUBLE_ARRAY;
if (exampleSet.size() > 0) {
type = exampleSet.getExampleTable().getDataRow(0).getType();
}
mappedExampleSet = MaterializeDataInMemory.materializeExampleSet(mappedExampleSet, type);
}
return mappedExampleSet;
}
示例6: estimatePerformance
import com.rapidminer.example.set.MappedExampleSet; //导入方法依赖的package包/类
@Override
public void estimatePerformance(ExampleSet inputSet) throws OperatorException {
boolean useWeights = getParameterAsBoolean(PARAMETER_USE_WEIGHTS);
number = getParameterAsInt(PARAMETER_NUMBER_OF_VALIDATIONS);
int size = (int) Math.round(inputSet.size() * getParameterAsDouble(PARAMETER_SAMPLE_RATIO));
// start bootstrapping loop
RandomGenerator random = RandomGenerator.getRandomGenerator(this);
if (modelOutput.isConnected()) {
getProgress().setTotal(number + 1);
} else {
getProgress().setTotal(number);
}
getProgress().setCheckForStop(false);
for (iteration = 0; iteration < number; iteration++) {
int[] mapping = null;
if (useWeights && inputSet.getAttributes().getWeight() != null) {
mapping = MappedExampleSet.createWeightedBootstrappingMapping(inputSet, size, random);
} else {
mapping = MappedExampleSet.createBootstrappingMapping(inputSet, size, random);
}
MappedExampleSet trainingSet = new MappedExampleSet(inputSet, mapping, true);
learn(trainingSet);
MappedExampleSet inverseExampleSet = new MappedExampleSet(inputSet, mapping, false);
evaluate(inverseExampleSet);
inApplyLoop();
getProgress().step();
}
}
示例7: learn
import com.rapidminer.example.set.MappedExampleSet; //导入方法依赖的package包/类
@Override
public Model learn(ExampleSet inputSet) throws OperatorException {
int iterations = getParameterAsInt(PARAMETER_ITERATIONS);
double subsetRatio = getParameterAsDouble(PARAMETER_USE_SUBSET_FOR_TRAINING);
Model[] models = new Model[iterations];
// get cost matrix
double[][] costMatrix = getParameterAsMatrix(PARAMETER_COST_MATRIX);
// perform bagging operation
if (getParameterAsBoolean(PARAMETER_SAMPLING_WITH_REPLACEMENT)) {
// sampling with replacement
Random randomGenerator = RandomGenerator.getRandomGenerator(this);
int size = (int) (inputSet.size() * subsetRatio);
for (int i = 0; i < iterations; i++) {
int[] mapping = MappedExampleSet.createBootstrappingMapping(inputSet, size, randomGenerator);
MappedExampleSet currentSampleSet = new MappedExampleSet(inputSet, mapping);
models[i] = applyInnerLearner(currentSampleSet);
inApplyLoop();
}
} else {
// sampling without replacement
boolean useLocalRandomSeed = getParameterAsBoolean(RandomGenerator.PARAMETER_USE_LOCAL_RANDOM_SEED);
int localRandomSeed = getParameterAsInt(RandomGenerator.PARAMETER_LOCAL_RANDOM_SEED);
for (int i = 0; i < iterations; i++) {
SplittedExampleSet splitted = new SplittedExampleSet(inputSet, subsetRatio,
SplittedExampleSet.SHUFFLED_SAMPLING, useLocalRandomSeed, localRandomSeed);
splitted.selectSingleSubset(0);
models[i] = applyInnerLearner(splitted);
inApplyLoop();
}
}
return new MetaCostModel(inputSet, models, costMatrix);
}
示例8: apply
import com.rapidminer.example.set.MappedExampleSet; //导入方法依赖的package包/类
@Override
public ExampleSet apply(ExampleSet exampleSet) throws OperatorException {
// cannot bootstrap without any examples
Tools.isNonEmpty(exampleSet);
int size = exampleSet.size();
RandomGenerator random = RandomGenerator.getRandomGenerator(this);
switch (getParameterAsInt(PARAMETER_SAMPLE)) {
case SAMPLE_ABSOLUTE:
size = getParameterAsInt(PARAMETER_SAMPLE_SIZE);
break;
case SAMPLE_RELATIVE:
size = (int) Math.round(exampleSet.size() * getParameterAsDouble(PARAMETER_SAMPLE_RATIO));
break;
}
int[] mapping = null;
if (getParameterAsBoolean(PARAMETER_USE_WEIGHTS) && exampleSet.getAttributes().getWeight() != null) {
mapping = MappedExampleSet.createWeightedBootstrappingMapping(exampleSet, size, random);
} else {
mapping = MappedExampleSet.createBootstrappingMapping(exampleSet, size, random);
}
// create and materialize example set
ExampleSet mappedExampleSet = new MappedExampleSet(exampleSet, mapping, true);
if (getCompatibilityLevel().isAbove(VERSION_6_4_0)) {
int type = DataRowFactory.TYPE_DOUBLE_ARRAY;
if (exampleSet.size() > 0) {
type = exampleSet.getExampleTable().getDataRow(0).getType();
}
mappedExampleSet = MaterializeDataInMemory.materializeExampleSet(mappedExampleSet, type);
}
return mappedExampleSet;
}
示例9: learn
import com.rapidminer.example.set.MappedExampleSet; //导入方法依赖的package包/类
public Model learn(ExampleSet inputSet) throws OperatorException {
int iterations = getParameterAsInt(PARAMETER_ITERATIONS);
double subsetRatio = getParameterAsDouble(PARAMETER_USE_SUBSET_FOR_TRAINING);
Model[] models = new Model[iterations];
//get cost matrix
double[][] costMatrix = getParameterAsMatrix(PARAMETER_COST_MATRIX);
//perform bagging operation
if (getParameterAsBoolean(PARAMETER_SAMPLING_WITH_REPLACEMENT)) {
//sampling with replacement
Random randomGenerator = RandomGenerator.getRandomGenerator(this);
int size = (int)(inputSet.size()*subsetRatio);
for (int i = 0; i < iterations; i++) {
ExampleSet exampleSet = (ExampleSet)inputSet.clone();
int[] mapping = MappedExampleSet.createBootstrappingMapping(exampleSet, size, randomGenerator);
MappedExampleSet currentSampleSet = new MappedExampleSet(exampleSet, mapping);
models[i] = applyInnerLearner(currentSampleSet);
inApplyLoop();
}
} else {
//sampling without replacement
for (int i = 0; i < iterations; i++) {
SplittedExampleSet splitted = new SplittedExampleSet((ExampleSet)inputSet.clone(), subsetRatio, SplittedExampleSet.SHUFFLED_SAMPLING, getParameterAsBoolean(RandomGenerator.PARAMETER_USE_LOCAL_RANDOM_SEED), getParameterAsInt(RandomGenerator.PARAMETER_LOCAL_RANDOM_SEED));
splitted.selectSingleSubset(0);
models[i] = applyInnerLearner(splitted);
inApplyLoop();
}
}
return new MetaCostModel(inputSet, models, costMatrix);
}
示例10: createMapping
import com.rapidminer.example.set.MappedExampleSet; //导入方法依赖的package包/类
@Override
public int[] createMapping(ExampleSet exampleSet, int size, Random random) throws OperatorException {
return MappedExampleSet.createBootstrappingMapping(exampleSet, size, random);
}
示例11: createMapping
import com.rapidminer.example.set.MappedExampleSet; //导入方法依赖的package包/类
@Override
public int[] createMapping(ExampleSet exampleSet, int size, Random random) throws OperatorException {
return MappedExampleSet.createBootstrappingMapping(exampleSet, size, random);
}