本文整理汇总了Java中weka.core.Utils.doubleToString方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.doubleToString方法的具体用法?Java Utils.doubleToString怎么用?Java Utils.doubleToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weka.core.Utils
的用法示例。
在下文中一共展示了Utils.doubleToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import weka.core.Utils; //导入方法依赖的package包/类
/** Display a representation of this estimator */
@Override
public String toString() {
String result = m_NumValues + " Normal Kernels. \nStandardDev = "
+ Utils.doubleToString(m_StandardDev, 6, 4) + " Precision = "
+ m_Precision;
if (m_NumValues == 0) {
result += " \nMean = 0";
} else {
result += " \nMeans =";
for (int i = 0; i < m_NumValues; i++) {
result += " " + m_Values[i];
}
if (!m_AllWeightsOne) {
result += "\nWeights = ";
for (int i = 0; i < m_NumValues; i++) {
result += " " + m_Weights[i];
}
}
}
return result + "\n";
}
示例2: toCumulativeMarginDistributionString
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Output the cumulative margin distribution as a string suitable for input
* for gnuplot or similar package.
*
* @return the cumulative margin distribution
* @throws Exception if the class attribute is nominal
*/
public String toCumulativeMarginDistributionString() throws Exception {
if (!m_ClassIsNominal) {
throw new Exception("Class must be nominal for margin distributions");
}
String result = "";
double cumulativeCount = 0;
double margin;
for (int i = 0; i <= k_MarginResolution; i++) {
if (m_MarginCounts[i] != 0) {
cumulativeCount += m_MarginCounts[i];
margin = i * 2.0 / k_MarginResolution - 1.0;
result =
result + Utils.doubleToString(margin, 7, 3) + ' '
+ Utils.doubleToString(cumulativeCount * 100 / m_WithClass, 7, 3)
+ '\n';
} else if (i == 0) {
result =
Utils.doubleToString(-1.0, 7, 3) + ' '
+ Utils.doubleToString(0, 7, 3) + '\n';
}
}
return result;
}
示例3: doubleToString
import weka.core.Utils; //导入方法依赖的package包/类
/**
* returns the given number as string rounded to the given number of decimals.
* additional necessary 0's are added.
*
* @param d the number to format
* @param prec the number of decimals after the point
* @return the formatted number
*/
protected String doubleToString(double d, int prec) {
String result;
int currentPrec;
int i;
result = Utils.doubleToString(d, prec);
// decimal point?
if (result.indexOf(".") == -1) {
result += ".";
}
// precision so far?
currentPrec = result.length() - result.indexOf(".") - 1;
for (i = currentPrec; i < prec; i++) {
result += "0";
}
return result;
}
示例4: toString
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Returns a string summarising the stats so far.
*
* @return the summary string
*/
public String toString() {
return
"Count " + Utils.doubleToString(count, 8) + '\n'
+ "Min " + Utils.doubleToString(min, 8) + '\n'
+ "Max " + Utils.doubleToString(max, 8) + '\n'
+ "Sum " + Utils.doubleToString(sum, 8) + '\n'
+ "SumSq " + Utils.doubleToString(sumSq, 8) + '\n'
+ "Mean " + Utils.doubleToString(mean, 8) + '\n'
+ "StdDev " + Utils.doubleToString(stdDev, 8) + '\n';
}
示例5: leafString
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Outputs a leaf.
*
* @return the leaf as string
* @throws Exception if generation fails
*/
protected String leafString() throws Exception {
double sum = 0, maxCount = 0;
int maxIndex = 0;
double classMean = 0;
double avgError = 0;
if (m_ClassDistribution != null) {
if (m_Info.classAttribute().isNominal()) {
sum = Utils.sum(m_ClassDistribution);
maxIndex = Utils.maxIndex(m_ClassDistribution);
maxCount = m_ClassDistribution[maxIndex];
} else {
classMean = m_ClassDistribution[0];
if (m_Distribution[1] > 0) {
avgError = m_Distribution[0] / m_Distribution[1];
}
}
}
if (m_Info.classAttribute().isNumeric()) {
return " : " + Utils.doubleToString(classMean, 2) + " ("
+ Utils.doubleToString(m_Distribution[1], 2) + "/"
+ Utils.doubleToString(avgError, 2) + ")";
}
return " : " + m_Info.classAttribute().value(maxIndex) + " ("
+ Utils.doubleToString(sum, 2) + "/"
+ Utils.doubleToString(sum - maxCount, 2) + ")";
}
示例6: drawHeatMap
import weka.core.Utils; //导入方法依赖的package包/类
private void drawHeatMap(Graphics2D chartGraphics, double[][] data) {
// Calculate the available size for the heatmap.
int noYCells = data.length;
int noXCells = data[0].length;
// double dataMin = min(data);
// double dataMax = max(data);
BufferedImage heatMapImage =
new BufferedImage(heatMapSize.width, heatMapSize.height,
BufferedImage.TYPE_INT_ARGB);
Graphics2D heatMapGraphics = heatMapImage.createGraphics();
heatMapGraphics.setFont(getAxisValuesFont());
FontMetrics tempMetrics = heatMapGraphics.getFontMetrics();
for (int x = 0; x < noXCells; x++) {
for (int y = 0; y < noYCells; y++) {
// Set colour depending on zValues.
heatMapGraphics
.setColor(getCellColour(data[y][x], lowValue, highValue));
int cellX = x * cellSize.width;
int cellY = y * cellSize.height;
heatMapGraphics.fillRect(cellX, cellY, cellSize.width, cellSize.height);
String cellVal = Utils.doubleToString(data[y][x], 2);
heatMapGraphics.setColor(Color.white);
heatMapGraphics.drawString(cellVal, cellX, cellY
+ (cellSize.height / 2) + (yAxisValuesAscent / 2));
}
}
// Draw the heat map onto the chart.
chartGraphics.drawImage(heatMapImage, heatMapTL.x, heatMapTL.y,
heatMapSize.width, heatMapSize.height, null);
}
示例7: toString
import weka.core.Utils; //导入方法依赖的package包/类
/** Display a representation of this estimator */
@Override
public String toString() {
if (m_Covariance == null) {
calculateCovariance();
}
String result = "NN Conditional Estimator. " + m_CondValues.size()
+ " data points. Mean = " + Utils.doubleToString(m_ValueMean, 4, 2)
+ " Conditional mean = " + Utils.doubleToString(m_CondMean, 4, 2);
result += " Covariance Matrix: \n" + m_Covariance;
return result;
}
示例8: toString
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Returns description of the bias-variance decomposition results.
*
* @return the bias-variance decomposition results as a string
*/
public String toString() {
String result = "\nBias-Variance Decomposition Segmentation, Cross Validation\n" +
"with subsampling.\n";
if (getClassifier() == null) {
return "Invalid setup";
}
result += "\nClassifier : " + getClassifier().getClass().getName();
if (getClassifier() instanceof OptionHandler) {
result += Utils.joinOptions(((OptionHandler)m_Classifier).getOptions());
}
result += "\nData File : " + getDataFileName();
result += "\nClass Index : ";
if (getClassIndex() == 0) {
result += "last";
} else {
result += getClassIndex();
}
result += "\nIterations : " + getClassifyIterations();
result += "\np : " + getP();
result += "\nTraining Size : " + getTrainSize();
result += "\nSeed : " + getSeed();
result += "\n\nDefinition : " +"Kohavi and Wolpert";
result += "\nError :" + Utils.doubleToString(getError(), 4);
result += "\nBias^2 :" + Utils.doubleToString(getKWBias(), 4);
result += "\nVariance :" + Utils.doubleToString(getKWVariance(), 4);
result += "\nSigma^2 :" + Utils.doubleToString(getKWSigma(), 4);
result += "\n\nDefinition : " +"Webb";
result += "\nError :" + Utils.doubleToString(getError(), 4);
result += "\nBias :" + Utils.doubleToString(getWBias(), 4);
result += "\nVariance :" + Utils.doubleToString(getWVariance(), 4);
return result;
}
示例9: toString
import weka.core.Utils; //导入方法依赖的package包/类
/** Display a representation of this estimator */
public String toString() {
if (m_CovarianceInverse == null) {
return "No covariance inverse\n";
}
return "Mahalanovis Distribution. Mean = "
+ Utils.doubleToString(m_ValueMean, 4, 2)
+ " ConditionalOffset = "
+ Utils.doubleToString(m_ConstDelta, 4, 2) + "\n"
+ "Covariance Matrix: Determinant = " + m_Determinant
+ " Inverse:\n" + m_CovarianceInverse;
}
示例10: toString
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Display a representation of this estimator
*/
@Override
public String toString() {
return "Normal Distribution. Mean = " + Utils.doubleToString(m_Mean, 4)
+ " StandardDev = " + Utils.doubleToString(m_StandardDev, 4)
+ " WeightSum = " + Utils.doubleToString(m_SumOfWeights, 4)
+ " Precision = " + m_Precision + "\n";
}
示例11: toString
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Returns description of the bias-variance decomposition results.
*
* @return the bias-variance decomposition results as a string
*/
public String toString() {
String result = "\nBias-Variance Decomposition\n";
if (getClassifier() == null) {
return "Invalid setup";
}
result += "\nClassifier : " + getClassifier().getClass().getName();
if (getClassifier() instanceof OptionHandler) {
result += Utils.joinOptions(((OptionHandler)m_Classifier).getOptions());
}
result += "\nData File : " + getDataFileName();
result += "\nClass Index : ";
if (getClassIndex() == 0) {
result += "last";
} else {
result += getClassIndex();
}
result += "\nTraining Pool: " + getTrainPoolSize();
result += "\nIterations : " + getTrainIterations();
result += "\nSeed : " + getSeed();
result += "\nError : " + Utils.doubleToString(getError(), 6, 4);
result += "\nSigma^2 : " + Utils.doubleToString(getSigma(), 6, 4);
result += "\nBias^2 : " + Utils.doubleToString(getBias(), 6, 4);
result += "\nVariance : " + Utils.doubleToString(getVariance(), 6, 4);
return result + "\n";
}
示例12: toString
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Returns statistics on the paired comparison.
*
* @return the t-test statistics as a string
*/
public String toString() {
return "Analysis for " + Utils.doubleToString(count, 0)
+ " points:\n"
+ " "
+ " Column 1"
+ " Column 2"
+ " Difference\n"
+ "Minimums "
+ Utils.doubleToString(xStats.min, 17, 4)
+ Utils.doubleToString(yStats.min, 17, 4)
+ Utils.doubleToString(differencesStats.min, 17, 4) + '\n'
+ "Maximums "
+ Utils.doubleToString(xStats.max, 17, 4)
+ Utils.doubleToString(yStats.max, 17, 4)
+ Utils.doubleToString(differencesStats.max, 17, 4) + '\n'
+ "Sums "
+ Utils.doubleToString(xStats.sum, 17, 4)
+ Utils.doubleToString(yStats.sum, 17, 4)
+ Utils.doubleToString(differencesStats.sum, 17, 4) + '\n'
+ "SumSquares "
+ Utils.doubleToString(xStats.sumSq, 17, 4)
+ Utils.doubleToString(yStats.sumSq, 17, 4)
+ Utils.doubleToString(differencesStats.sumSq, 17, 4) + '\n'
+ "Means "
+ Utils.doubleToString(xStats.mean, 17, 4)
+ Utils.doubleToString(yStats.mean, 17, 4)
+ Utils.doubleToString(differencesStats.mean, 17, 4) + '\n'
+ "SDs "
+ Utils.doubleToString(xStats.stdDev, 17, 4)
+ Utils.doubleToString(yStats.stdDev, 17, 4)
+ Utils.doubleToString(differencesStats.stdDev, 17, 4) + '\n'
+ "Prob(differences) "
+ Utils.doubleToString(differencesProbability, 4)
+ " (sigflag " + differencesSignificance + ")\n"
+ "Correlation "
+ Utils.doubleToString(correlation,4) + "\n";
}
示例13: toStringMetric
import weka.core.Utils; //导入方法依赖的package包/类
public String toStringMetric(int premiseSupport, int consequenceSupport,
int totalSupport, int totalTransactions) {
return m_stringVal + ":(" + Utils.doubleToString(compute(premiseSupport, consequenceSupport,
totalSupport, totalTransactions), 2) + ")";
}
示例14: setNumeric
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Sets the legend to be for a numeric variable
*/
protected void setNumeric() {
m_isNumeric = true;
/*
* m_maxC = mxC; m_minC = mnC;
*/
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
double value;
for (int i = 0; i < m_Instances.numInstances(); i++) {
if (!m_Instances.instance(i).isMissing(m_cIndex)) {
value = m_Instances.instance(i).value(m_cIndex);
if (value < min) {
min = value;
}
if (value > max) {
max = value;
}
}
}
// handle case where all values are missing
if (min == Double.POSITIVE_INFINITY) {
min = max = 0.0;
}
m_minC = min;
m_maxC = max;
int whole = (int) Math.abs(m_maxC);
double decimal = Math.abs(m_maxC) - whole;
int nondecimal;
nondecimal = (whole > 0) ? (int) (Math.log(whole) / Math.log(10)) : 1;
m_precisionC = (decimal > 0) ? (int) Math
.abs(((Math.log(Math.abs(m_maxC)) / Math.log(10)))) + 2 : 1;
if (m_precisionC > VisualizeUtils.MAX_PRECISION) {
m_precisionC = 1;
}
String maxStringC = Utils.doubleToString(m_maxC, nondecimal + 1
+ m_precisionC, m_precisionC);
if (m_labelMetrics != null) {
m_HorizontalPad = m_labelMetrics.stringWidth(maxStringC);
}
whole = (int) Math.abs(m_minC);
decimal = Math.abs(m_minC) - whole;
nondecimal = (whole > 0) ? (int) (Math.log(whole) / Math.log(10)) : 1;
m_precisionC = (decimal > 0) ? (int) Math
.abs(((Math.log(Math.abs(m_minC)) / Math.log(10)))) + 2 : 1;
if (m_precisionC > VisualizeUtils.MAX_PRECISION) {
m_precisionC = 1;
}
maxStringC = Utils.doubleToString(m_minC, nondecimal + 1 + m_precisionC,
m_precisionC);
if (m_labelMetrics != null) {
if (m_labelMetrics.stringWidth(maxStringC) > m_HorizontalPad) {
m_HorizontalPad = m_labelMetrics.stringWidth(maxStringC);
}
}
setOn(true);
this.repaint();
}
示例15: toString
import weka.core.Utils; //导入方法依赖的package包/类
/**
* Prints this antecedent
*
* @return a textual description of this antecedent
*/
@Override
public String toString() {
String symbol = ((int) value == 0) ? " <= " : " >= ";
return (att.name() + symbol + Utils.doubleToString(splitPoint, 6));
}