本文整理汇总了Java中com.rapidminer.example.set.MappedExampleSet类的典型用法代码示例。如果您正苦于以下问题:Java MappedExampleSet类的具体用法?Java MappedExampleSet怎么用?Java MappedExampleSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MappedExampleSet类属于com.rapidminer.example.set包,在下文中一共展示了MappedExampleSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: estimatePerformance
import com.rapidminer.example.set.MappedExampleSet; //导入依赖的package包/类
@Override
public void estimatePerformance(ExampleSet inputSet) throws OperatorException {
number = getParameterAsInt(PARAMETER_NUMBER_OF_VALIDATIONS);
// start bootstrapping loop
RandomGenerator random = RandomGenerator.getRandomGenerator(this);
for (iteration = 0; iteration < number; iteration++) {
int[] mapping = createMapping(inputSet,
(int) Math.round(inputSet.size() * getParameterAsDouble(PARAMETER_SAMPLE_RATIO)), 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: estimatePerformance
import com.rapidminer.example.set.MappedExampleSet; //导入依赖的package包/类
@Override
public void estimatePerformance(ExampleSet inputSet) throws OperatorException {
number = getParameterAsInt(PARAMETER_NUMBER_OF_VALIDATIONS);
double sampleRatio = getParameterAsDouble(PARAMETER_SAMPLE_RATIO);
// start bootstrapping loop
RandomGenerator random = RandomGenerator.getRandomGenerator(this);
for (iteration = 0; iteration < number; iteration++) {
int[] mapping = createMapping(inputSet, (int) Math.round(inputSet.size() * sampleRatio), random);
MappedExampleSet trainingSet = new MappedExampleSet(inputSet, mapping, true);
learn(trainingSet);
MappedExampleSet inverseExampleSet = new MappedExampleSet(inputSet, mapping, false);
evaluate(inverseExampleSet);
inApplyLoop();
}
// end loop
}
示例3: estimatePerformance
import com.rapidminer.example.set.MappedExampleSet; //导入依赖的package包/类
@Override
public void estimatePerformance(ExampleSet inputSet) throws OperatorException {
number = getParameterAsInt(PARAMETER_NUMBER_OF_VALIDATIONS);
// start bootstrapping loop
RandomGenerator random = RandomGenerator.getRandomGenerator(this);
for (iteration = 0; iteration < number; iteration++) {
int[] mapping = createMapping(inputSet, (int)Math.round(inputSet.size() * getParameterAsDouble(PARAMETER_SAMPLE_RATIO)), 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
}
示例4: 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
}
示例5: 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);
}
示例6: 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();
}
示例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++) {
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);
}
示例8: apply
import com.rapidminer.example.set.MappedExampleSet; //导入依赖的package包/类
@Override
public ExampleSet apply(ExampleSet exampleSet) throws OperatorException {
RandomGenerator random = RandomGenerator.getRandomGenerator(this);
int[] mapping = createMapping(exampleSet,
(int) Math.round(exampleSet.size() * getParameterAsDouble(PARAMETER_SAMPLE_RATIO)), random);
MappedExampleSet bootstrappedExampleSet = new MappedExampleSet(exampleSet, mapping, true);
return bootstrappedExampleSet;
}
示例9: createMapping
import com.rapidminer.example.set.MappedExampleSet; //导入依赖的package包/类
@Override
public int[] createMapping(ExampleSet exampleSet, int size, Random random) throws OperatorException {
if (exampleSet.getAttributes().getWeight() == null) {
throw new UserError(this, 113, Attributes.WEIGHT_NAME);
}
return MappedExampleSet.createWeightedBootstrappingMapping(exampleSet, size, random);
}
示例10: 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;
}
示例11: 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();
}
}
示例12: 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);
}
示例13: 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;
}
示例14: downsample
import com.rapidminer.example.set.MappedExampleSet; //导入依赖的package包/类
/**
* Takes the first {@code #newSize} rows of the given example set and returns a new one with
* only the first n rows
*/
private static ExampleSet downsample(ExampleSet exampleSet, int newSize) {
int[] mapping = new int[newSize];
for (int i = 0; i < newSize; i++) {
mapping[i] = i;
}
return new MappedExampleSet(exampleSet, mapping);
}
示例15: 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);
}