本文整理匯總了Java中com.rapidminer.example.table.NominalMapping.getPositiveString方法的典型用法代碼示例。如果您正苦於以下問題:Java NominalMapping.getPositiveString方法的具體用法?Java NominalMapping.getPositiveString怎麽用?Java NominalMapping.getPositiveString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.rapidminer.example.table.NominalMapping
的用法示例。
在下文中一共展示了NominalMapping.getPositiveString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: learn
import com.rapidminer.example.table.NominalMapping; //導入方法依賴的package包/類
@Override
public Model learn(ExampleSet exampleSet) throws OperatorException {
Kernel kernel = getKernel();
kernel.init(exampleSet);
double initLearnRate = getParameterAsDouble(PARAMETER_LEARNING_RATE);
NominalMapping labelMapping = exampleSet.getAttributes().getLabel().getMapping();
String classNeg = labelMapping.getNegativeString();
String classPos = labelMapping.getPositiveString();
double classValueNeg = labelMapping.getNegativeIndex();
int numberOfAttributes = exampleSet.getAttributes().size();
HyperplaneModel model = new HyperplaneModel(exampleSet, classNeg, classPos, kernel);
model.init(new double[numberOfAttributes], 0);
for (int round = 0; round <= getParameterAsInt(PARAMETER_ROUNDS); round++) {
double learnRate = getLearnRate(round, getParameterAsInt(PARAMETER_ROUNDS), initLearnRate);
Attributes attributes = exampleSet.getAttributes();
for (Example example : exampleSet) {
double prediction = model.predict(example);
if (prediction != example.getLabel()) {
double direction = (example.getLabel() == classValueNeg) ? -1 : 1;
// adapting intercept
model.setIntercept(model.getIntercept() + learnRate * direction);
// adapting coefficients
double coefficients[] = model.getCoefficients();
int i = 0;
for (Attribute attribute : attributes) {
coefficients[i] += learnRate * direction * example.getValue(attribute);
i++;
}
}
}
}
return model;
}
示例2: learn
import com.rapidminer.example.table.NominalMapping; //導入方法依賴的package包/類
@Override
public Model learn(ExampleSet exampleSet) throws OperatorException {
Kernel kernel = getKernel();
double initLearnRate = getParameterAsDouble(PARAMETER_LEARNING_RATE);
NominalMapping labelMapping = exampleSet.getAttributes().getLabel().getMapping();
String classNeg = labelMapping.getNegativeString();
String classPos = labelMapping.getPositiveString();
double classValueNeg = labelMapping.getNegativeIndex();
int numberOfAttributes = exampleSet.getAttributes().size();
HyperplaneModel model = new HyperplaneModel(exampleSet, classNeg, classPos, kernel);
model.init(new double[numberOfAttributes], 0);
int rounds = getParameterAsInt(PARAMETER_ROUNDS);
for (int round = 0; round <= rounds; round++) {
double learnRate = getLearnRate(round, rounds, initLearnRate);
Attributes attributes = exampleSet.getAttributes();
for (Example example : exampleSet) {
double prediction = model.predict(example);
if (prediction != example.getLabel()) {
double direction = (example.getLabel() == classValueNeg) ? -1 : 1;
// adapting intercept
model.setIntercept(model.getIntercept() + learnRate * direction);
// adapting coefficients
double coefficients[] = model.getCoefficients();
int i = 0;
for (Attribute attribute : attributes) {
coefficients[i] += learnRate * direction * example.getValue(attribute);
i++;
}
}
}
}
return model;
}
示例3: learn
import com.rapidminer.example.table.NominalMapping; //導入方法依賴的package包/類
public Model learn(ExampleSet exampleSet) throws OperatorException {
Kernel kernel = getKernel();
kernel.init(exampleSet);
double initLearnRate = getParameterAsDouble(PARAMETER_LEARNING_RATE);
NominalMapping labelMapping = exampleSet.getAttributes().getLabel().getMapping();
String classNeg = labelMapping.getNegativeString();
String classPos = labelMapping.getPositiveString();
double classValueNeg = labelMapping.getNegativeIndex();
int numberOfAttributes = exampleSet.getAttributes().size();
HyperplaneModel model = new HyperplaneModel(exampleSet, classNeg, classPos, kernel);
model.init(new double[numberOfAttributes], 0);
for (int round = 0; round <= getParameterAsInt(PARAMETER_ROUNDS); round++) {
double learnRate = getLearnRate(round, getParameterAsInt(PARAMETER_ROUNDS), initLearnRate);
Attributes attributes = exampleSet.getAttributes();
for (Example example: exampleSet) {
double prediction = model.predict(example);
if (prediction != example.getLabel()) {
double direction = (example.getLabel() == classValueNeg)? -1 : 1;
// adapting intercept
model.setIntercept(model.getIntercept() + learnRate * direction);
// adapting coefficients
double coefficients[] = model.getCoefficients();
int i = 0;
for (Attribute attribute: attributes) {
coefficients[i] += learnRate * direction * example.getValue(attribute);
i++;
}
}
}
}
return model;
}
示例4: doWork
import com.rapidminer.example.table.NominalMapping; //導入方法依賴的package包/類
@Override
public void doWork() throws OperatorException {
// sanity checks
ExampleSet exampleSet = exampleSetInput.getData(ExampleSet.class);
// checking preconditions
Attribute label = exampleSet.getAttributes().getLabel();
if (label == null) {
throw new UserError(this, 105);
}
if (!label.isNominal()) {
throw new UserError(this, 101, label, "threshold finding");
}
exampleSet.recalculateAttributeStatistics(label);
NominalMapping mapping = label.getMapping();
if (mapping.size() != 2) {
throw new UserError(this, 118, new Object[] { label, Integer.valueOf(mapping.getValues().size()),
Integer.valueOf(2) });
}
if (exampleSet.getAttributes().getPredictedLabel() == null) {
throw new UserError(this, 107);
}
boolean useExplictLabels = getParameterAsBoolean(PARAMETER_DEFINE_LABELS);
double secondCost = getParameterAsDouble(PARAMETER_MISCLASSIFICATION_COSTS_SECOND);
double firstCost = getParameterAsDouble(PARAMETER_MISCLASSIFICATION_COSTS_FIRST);
if (useExplictLabels) {
String firstLabel = getParameterAsString(PARAMETER_FIRST_LABEL);
String secondLabel = getParameterAsString(PARAMETER_SECOND_LABEL);
if (mapping.getIndex(firstLabel) == -1) {
throw new UserError(this, 143, firstLabel, label.getName());
}
if (mapping.getIndex(secondLabel) == -1) {
throw new UserError(this, 143, secondLabel, label.getName());
}
// if explicit order differs from order in data: internally swap costs.
if (mapping.getIndex(firstLabel) > mapping.getIndex(secondLabel)) {
double temp = firstCost;
firstCost = secondCost;
secondCost = temp;
}
}
// check whether the confidence attributes are available
if (exampleSet.getAttributes().getConfidence(mapping.getPositiveString()) == null) {
throw new UserError(this, 113, Attributes.CONFIDENCE_NAME + "_" + mapping.getPositiveString());
}
if (exampleSet.getAttributes().getConfidence(mapping.getNegativeString()) == null) {
throw new UserError(this, 113, Attributes.CONFIDENCE_NAME + "_" + mapping.getNegativeString());
}
// create ROC data
ROCDataGenerator rocDataGenerator = new ROCDataGenerator(firstCost, secondCost);
ROCData rocData = rocDataGenerator.createROCData(exampleSet, getParameterAsBoolean(PARAMETER_USE_EXAMPLE_WEIGHTS),
ROCBias.getROCBiasParameter(this));
// create plotter
if (getParameterAsBoolean(PARAMETER_SHOW_ROC_PLOT)) {
rocDataGenerator.createROCPlotDialog(rocData, true, true);
}
// create and return output
exampleSetOutput.deliver(exampleSet);
thresholdOutput.deliver(new Threshold(rocDataGenerator.getBestThreshold(), mapping.getNegativeString(), mapping
.getPositiveString()));
}
示例5: doWork
import com.rapidminer.example.table.NominalMapping; //導入方法依賴的package包/類
@Override
public void doWork() throws OperatorException {
// sanity checks
ExampleSet exampleSet = exampleSetInput.getData(ExampleSet.class);
// checking preconditions
Tools.hasNominalLabels(exampleSet, getOperatorClassName());
Attribute label = exampleSet.getAttributes().getLabel();
exampleSet.recalculateAttributeStatistics(label);
NominalMapping mapping = label.getMapping();
if (mapping.size() != 2) {
throw new UserError(this, 118, label, Integer.valueOf(mapping.getValues().size()), Integer.valueOf(2));
}
if (exampleSet.getAttributes().getPredictedLabel() == null) {
throw new UserError(this, 107);
}
boolean useExplictLabels = getParameterAsBoolean(PARAMETER_DEFINE_LABELS);
double secondCost = getParameterAsDouble(PARAMETER_MISCLASSIFICATION_COSTS_SECOND);
double firstCost = getParameterAsDouble(PARAMETER_MISCLASSIFICATION_COSTS_FIRST);
if (useExplictLabels) {
String firstLabel = getParameterAsString(PARAMETER_FIRST_LABEL);
String secondLabel = getParameterAsString(PARAMETER_SECOND_LABEL);
if (mapping.getIndex(firstLabel) == -1) {
throw new UserError(this, 143, firstLabel, label.getName());
}
if (mapping.getIndex(secondLabel) == -1) {
throw new UserError(this, 143, secondLabel, label.getName());
}
// if explicit order differs from order in data: internally swap costs.
if (mapping.getIndex(firstLabel) > mapping.getIndex(secondLabel)) {
double temp = firstCost;
firstCost = secondCost;
secondCost = temp;
}
}
// check whether the confidence attributes are available
if (exampleSet.getAttributes().getConfidence(mapping.getPositiveString()) == null) {
throw new UserError(this, 113, Attributes.CONFIDENCE_NAME + "_" + mapping.getPositiveString());
}
if (exampleSet.getAttributes().getConfidence(mapping.getNegativeString()) == null) {
throw new UserError(this, 113, Attributes.CONFIDENCE_NAME + "_" + mapping.getNegativeString());
}
// create ROC data
ROCDataGenerator rocDataGenerator = new ROCDataGenerator(firstCost, secondCost);
ROCData rocData = rocDataGenerator.createROCData(exampleSet, getParameterAsBoolean(PARAMETER_USE_EXAMPLE_WEIGHTS),
ROCBias.getROCBiasParameter(this));
// create plotter
if (getParameterAsBoolean(PARAMETER_SHOW_ROC_PLOT)) {
rocDataGenerator.createROCPlotDialog(rocData, true, true);
}
// create and return output
exampleSetOutput.deliver(exampleSet);
thresholdOutput.deliver(new Threshold(rocDataGenerator.getBestThreshold(), mapping.getNegativeString(), mapping
.getPositiveString()));
}