本文整理汇总了Java中com.rapidminer.tools.math.MathFunctions类的典型用法代码示例。如果您正苦于以下问题:Java MathFunctions类的具体用法?Java MathFunctions怎么用?Java MathFunctions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MathFunctions类属于com.rapidminer.tools.math包,在下文中一共展示了MathFunctions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startCounting
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
/** Calculates the margin. */
@Override
public void startCounting(ExampleSet exampleSet, boolean useExampleWeights) throws OperatorException {
super.startCounting(exampleSet, useExampleWeights);
// compute margin
Iterator<Example> reader = exampleSet.iterator();
this.value = 0.0d;
Attribute labelAttr = exampleSet.getAttributes().getLabel();
Attribute weightAttribute = null;
if (useExampleWeights) {
weightAttribute = exampleSet.getAttributes().getWeight();
}
while (reader.hasNext()) {
Example example = reader.next();
String trueLabel = example.getNominalValue(labelAttr);
double confidence = example.getConfidence(trueLabel);
double weight = 1.0d;
if (weightAttribute != null) {
weight = example.getValue(weightAttribute);
}
this.value -= weight * MathFunctions.ld(confidence);
this.counter += weight;
}
}
示例2: prepareData
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
@Override
protected void prepareData() {
allQuartiles.clear();
this.globalMin = Double.POSITIVE_INFINITY;
this.globalMax = Double.NEGATIVE_INFINITY;
if (columns != null) {
int totalCount = 0;
for (int i = 0; i < this.dataTable.getNumberOfColumns(); i++) {
if (columns[i]) {
totalCount++;
}
}
for (int i = 0; i < this.dataTable.getNumberOfColumns(); i++) {
if (columns[i]) {
Quartile quartile = Quartile.calculateQuartile(this.dataTable, i);
quartile.setColor(getColorProvider(true).getPointColor((double) i / (double) totalCount));
allQuartiles.add(quartile);
this.globalMin = MathFunctions.robustMin(this.globalMin, quartile.getMin());
this.globalMax = MathFunctions.robustMax(this.globalMax, quartile.getMax());
}
}
}
}
示例3: changeColor
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
private void changeColor(double[][] colorMatrix, int matrixX, int matrixY, double color, int radius) {
double maxDistance = radius;
for (int x = matrixX - radius; x < matrixX + radius; x++) {
for (int y = matrixY - radius; y < matrixY + radius; y++) {
if ((x < 0) || (x >= MATRIX_WIDTH) || (y < 0) || (y >= MATRIX_HEIGHT)) {
continue;
}
int xDiff = x - matrixX;
int yDiff = y - matrixY;
double distanceFactor = MathFunctions.robustMax(0,
((maxDistance - Math.sqrt(xDiff * xDiff + yDiff * yDiff)) / maxDistance));
double colorDiff = color - colorMatrix[x][y];
colorMatrix[x][y] = MathFunctions.robustMax(0.0d,
MathFunctions.robustMin(1.0d, colorMatrix[x][y] + distanceFactor * colorDiff));
}
}
}
示例4: calculateWeights
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
@Override
public AttributeWeights calculateWeights(ExampleSet exampleSet) throws OperatorException {
Attributes attributes = exampleSet.getAttributes();
Attribute labelAttribute = attributes.getLabel();
boolean useSquaredCorrelation = getParameterAsBoolean(PARAMETER_SQUARED_CORRELATION);
AttributeWeights weights = new AttributeWeights(exampleSet);
getProgress().setTotal(attributes.size());
int progressCounter = 0;
int exampleSetSize = exampleSet.size();
int exampleCounter = 0;
for (Attribute attribute : attributes) {
double correlation = MathFunctions.correlation(exampleSet, labelAttribute, attribute, useSquaredCorrelation);
weights.setWeight(attribute.getName(), Math.abs(correlation));
progressCounter++;
exampleCounter += exampleSetSize;
if(exampleCounter > PROGRESS_UPDATE_STEPS) {
exampleCounter = 0;
getProgress().setCompleted(progressCounter);
}
}
return weights;
}
示例5: setRange
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
private void setRange(ValueAxis axis) {
Range range = null;
for (int c = 0; c < this.dataTable.getNumberOfColumns(); c++) {
if (this.columns[c]) {
if (range == null) {
range = getRangeForDimension(c);
} else {
Range newRange = getRangeForDimension(c);
if (newRange != null) {
range = new Range(MathFunctions.robustMin(range.getLowerBound(), newRange.getLowerBound()),
MathFunctions.robustMax(range.getUpperBound(), newRange.getUpperBound()));
}
}
}
}
if (range != null) {
axis.setRange(range);
} else {
axis.setAutoRange(true);
}
}
示例6: setYAxisRange
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
private void setYAxisRange(NumberAxis axis) {
Range range = getRangeForName(VALUEAXIS_LABEL);
if (range == null) {
for (int c = 0; c < this.dataTable.getNumberOfColumns(); c++) {
if (this.columns[c] || c == getAxis(0) || c == getAxis(1)) {
if (range == null) {
range = getRangeForDimension(c);
} else {
Range newRange = getRangeForDimension(c);
if (newRange != null) {
range = new Range(MathFunctions.robustMin(range.getLowerBound(), newRange.getLowerBound()),
MathFunctions.robustMax(range.getUpperBound(), newRange.getUpperBound()));
}
}
}
}
}
if (range != null) {
axis.setRange(range);
} else {
axis.setAutoRange(true);
axis.setAutoRangeStickyZero(false);
axis.setAutoRangeIncludesZero(false);
}
}
示例7: startCounting
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
/** Calculates the margin. */
@Override
public void startCounting(ExampleSet exampleSet, boolean useExampleWeights) throws OperatorException {
super.startCounting(exampleSet, useExampleWeights);
// compute margin
Iterator<Example> reader = exampleSet.iterator();
this.value = 0.0d;
Attribute labelAttr = exampleSet.getAttributes().getLabel();
Attribute weightAttribute = null;
if (useExampleWeights)
weightAttribute = exampleSet.getAttributes().getWeight();
while (reader.hasNext()) {
Example example = reader.next();
String trueLabel = example.getNominalValue(labelAttr);
double confidence = example.getConfidence(trueLabel);
double weight = 1.0d;
if (weightAttribute != null)
weight = example.getValue(weightAttribute);
this.value -= weight * MathFunctions.ld(confidence);
this.counter += weight;
}
}
示例8: setRange
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
private void setRange(ValueAxis axis) {
Range range = null;
for (int c = 0; c < this.dataTable.getNumberOfColumns(); c++) {
if (this.columns[c]) {
if (range == null)
range = getRangeForDimension(c);
else {
Range newRange = getRangeForDimension(c);
if (newRange != null)
range = new Range(MathFunctions.robustMin(range.getLowerBound(), newRange.getLowerBound()), MathFunctions.robustMax(range.getUpperBound(), newRange.getUpperBound()));
}
}
}
if (range != null)
axis.setRange(range);
else
axis.setAutoRange(true);
}
示例9: setYAxisRange
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
private void setYAxisRange(NumberAxis axis) {
Range range = getRangeForName(VALUEAXIS_LABEL);
if (range == null) {
for (int c = 0; c < this.dataTable.getNumberOfColumns(); c++) {
if (this.columns[c] || c == getAxis(0) || c == getAxis(1)) {
if (range == null)
range = getRangeForDimension(c);
else {
Range newRange = getRangeForDimension(c);
if (newRange != null)
range = new Range(MathFunctions.robustMin(range.getLowerBound(), newRange.getLowerBound()), MathFunctions.robustMax(range.getUpperBound(), newRange.getUpperBound()));
}
}
}
}
if (range != null)
axis.setRange(range);
else {
axis.setAutoRange(true);
axis.setAutoRangeStickyZero(false);
axis.setAutoRangeIncludesZero(false);
}
}
示例10: prepareData
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
@Override
protected void prepareData() {
allQuartiles.clear();
this.globalMin = Double.POSITIVE_INFINITY;
this.globalMax = Double.NEGATIVE_INFINITY;
if (columns != null) {
int totalCount = 0;
for (int i = 0; i < this.dataTable.getNumberOfColumns(); i++) {
if (columns[i]) {
totalCount++;
}
}
for (int i = 0; i < this.dataTable.getNumberOfColumns(); i++) {
if (columns[i]) {
Quartile quartile = Quartile.calculateQuartile(this.dataTable, i);
quartile.setColor(getColorProvider().getPointColor((double) i / (double) totalCount));
allQuartiles.add(quartile);
this.globalMin = MathFunctions.robustMin(this.globalMin, quartile.getMin());
this.globalMax = MathFunctions.robustMax(this.globalMax, quartile.getMax());
}
}
}
}
示例11: calculateWeights
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
@Override
public AttributeWeights calculateWeights(ExampleSet exampleSet) throws OperatorException {
Attributes attributes = exampleSet.getAttributes();
Attribute labelAttribute = attributes.getLabel();
boolean useSquaredCorrelation = getParameterAsBoolean(PARAMETER_SQUARED_CORRELATION);
AttributeWeights weights = new AttributeWeights(exampleSet);
for (Attribute attribute : attributes) {
double correlation = MathFunctions.correlation(exampleSet, labelAttribute, attribute, useSquaredCorrelation);
weights.setWeight(attribute.getName(), Math.abs(correlation));
}
return weights;
}
示例12: pessimisticErrors
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
public double pessimisticErrors(double numberOfExamples, double errorRate, double confidenceLevel) {
if (errorRate < 1E-6) {
return errorRate + numberOfExamples * (1.0 - Math.exp(Math.log(confidenceLevel) / numberOfExamples));
} else if (errorRate + 0.5 >= numberOfExamples) {
return errorRate + 0.67 * (numberOfExamples - errorRate);
} else {
double coefficient = MathFunctions.normalInverse(1 - confidenceLevel);
coefficient *= coefficient;
double pessimisticRate = (errorRate + 0.5 + coefficient / 2.0d + Math.sqrt(coefficient
* ((errorRate + 0.5) * (1 - (errorRate + 0.5) / numberOfExamples) + coefficient / 4.0d)))
/ (numberOfExamples + coefficient);
return (numberOfExamples * pessimisticRate);
}
}
示例13: pessimisticErrors
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
/**
* Calculates the pessimistic number of errors, using some confidence level.
*
* @param numberOfExamples
* @param errorRate
* @param confidenceLevel
* @return
*/
public double pessimisticErrors(double numberOfExamples, double errorRate, double confidenceLevel) {
if (errorRate < 1E-6) {
return errorRate + numberOfExamples * (1.0 - Math.exp(Math.log(confidenceLevel) / numberOfExamples));
} else if (errorRate + 0.5 >= numberOfExamples) {
return errorRate + 0.67 * (numberOfExamples - errorRate);
} else {
double coefficient = MathFunctions.normalInverse(1 - confidenceLevel);
coefficient *= coefficient;
double pessimisticRate = (errorRate + 0.5 + coefficient / 2.0d + Math.sqrt(coefficient
* ((errorRate + 0.5) * (1 - (errorRate + 0.5) / numberOfExamples) + coefficient / 4.0d)))
/ (numberOfExamples + coefficient);
return numberOfExamples * pessimisticRate;
}
}
示例14: getInverseCovarianceMatrices
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
@Override
protected Matrix[] getInverseCovarianceMatrices(ExampleSet exampleSet, String[] labels) throws UndefinedParameterError,
OperatorException {
double alpha = getParameterAsDouble(PARAMETER_ALPHA);
Matrix[] globalInverseCovariances = super.getInverseCovarianceMatrices(exampleSet, labels);
Matrix[] classInverseCovariances = new Matrix[labels.length];
Attribute labelAttribute = exampleSet.getAttributes().getLabel();
SplittedExampleSet labelSet = SplittedExampleSet.splitByAttribute(exampleSet, exampleSet.getAttributes().getLabel());
int labelIndex = 0;
for (String label : labels) {
this.checkForStop();
// select appropriate subset
for (int i = 0; i < labels.length; i++) {
labelSet.selectSingleSubset(i);
if (labelSet.getExample(0).getNominalValue(labelAttribute).equals(label)) {
break;
}
}
// calculate inverse matrix
Matrix inverse = MathFunctions.invertMatrix(CovarianceMatrix.getCovarianceMatrix(labelSet, this));
classInverseCovariances[labelIndex] = inverse;
labelIndex++;
}
// weighting of the matrices
Matrix[] regularizedMatrices = new Matrix[classInverseCovariances.length];
for (int i = 0; i < labels.length; i++) {
regularizedMatrices[i] = globalInverseCovariances[i].times(alpha).plus(
classInverseCovariances[i].times(1d - alpha));
}
return classInverseCovariances;
}
示例15: getInverseCovarianceMatrices
import com.rapidminer.tools.math.MathFunctions; //导入依赖的package包/类
protected Matrix[] getInverseCovarianceMatrices(ExampleSet exampleSet, String[] labels) throws UndefinedParameterError,
OperatorException {
Matrix[] classInverseCovariances = new Matrix[labels.length];
Matrix inverse = MathFunctions.invertMatrix(CovarianceMatrix.getCovarianceMatrix(exampleSet, this));
for (int i = 0; i < labels.length; i++) {
this.checkForStop();
classInverseCovariances[i] = inverse;
}
return classInverseCovariances;
}