Java Code Examples for weka.core.Utils#doubleToString()

The following examples show how to use weka.core.Utils#doubleToString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KernelEstimator.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
/** 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";
}
 
Example 2
Source File: ResultVectorTableModel.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the value for the JTable for a given position.
 * @param row The row of the value
 * @param column The column of the value
 * @return value
 * */
public Object getValueAt(int row, int column) {
    DataObject dataObject = (DataObject) resultVector.elementAt(row);

    switch (column) {
        case 0:
            return dataObject.getKey();
        case 1:
            return dataObject;
        case 2:
            return ((dataObject.getCoreDistance() == DataObject.UNDEFINED) ?
                    "UNDEFINED" :
                    Utils.doubleToString(dataObject.getCoreDistance(), 3, 5));
        case 3:
            return ((dataObject.getReachabilityDistance() == DataObject.UNDEFINED) ?
                    "UNDEFINED" :
                    Utils.doubleToString(dataObject.getReachabilityDistance(), 3, 5));
        default:
            return "";
    }
}
 
Example 3
Source File: MDD.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets a string describing the classifier.
 *
 * @return a string describing the classifer built.
 */
public String toString() {

  String result = "Modified Logistic Regression";
  if (m_Par == null) {
    return result + ": No model built yet.";
  }

  result += "\nCoefficients...\n"
    + "Variable      Coeff.\n";
  for (int j = 0, idx=0; j < m_Par.length/2; j++, idx++) {

    result += m_Attributes.attribute(idx).name();
    result += " "+Utils.doubleToString(m_Par[j*2], 12, 4); 
    result += " "+Utils.doubleToString(m_Par[j*2+1], 12, 4)+"\n";
  }

  return result;
}
 
Example 4
Source File: DiscreteEstimatorBayes.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
/**
  * Display a representation of this estimator
  * 
  * @return a string representation of the estimator
  */
 public String toString() {
   String result = "Discrete Estimator. Counts = ";

   if (m_SumOfCounts > 1) {
     for (int i = 0; i < m_Counts.length; i++) {
result += " " + Utils.doubleToString(m_Counts[i], 2);
     } 

     result += "  (Total = " + Utils.doubleToString(m_SumOfCounts, 2) 
	+ ")\n";
   } else {
     for (int i = 0; i < m_Counts.length; i++) {
result += " " + m_Counts[i];
     } 

     result += "  (Total = " + m_SumOfCounts + ")\n";
   } 

   return result;
 }
 
Example 5
Source File: KKConditionalEstimator.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Display a representation of this estimator
 */
public String toString() {

  String result = "KK Conditional Estimator. " 
    + m_NumValues + " Normal Kernels:\n"
    + "StandardDev = " + Utils.doubleToString(m_StandardDev,4,2) 
    + "  \nMeans =";
  for(int i = 0; i < m_NumValues; i++) {
    result += " (" + m_Values[i] + ", " + m_CondValues[i] + ")";
    if (!m_AllWeightsOne) {
 result += "w=" + m_Weights[i];
    }
  }
  return result;
}
 
Example 6
Source File: BIRCHCluster.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the upper and lower boundary for the radius of the clusters.
 *
 * @return the string containing the upper and lower boundary for
 * the radius  of the clusters, separated by ..
 */
protected String getRadiuses() {
  String fromTo = "" 
                  + Utils.doubleToString(getMinRadius(), 2) + ".."
                  + Utils.doubleToString(getMaxRadius(), 2);
  return fromTo;
}
 
Example 7
Source File: Test.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gives a string representation of the test, starting from the comparison
 * symbol.
 *
 * @return a string representing the test
 */   
private String testComparisonString() {
  Attribute att = m_Dataset.attribute(m_AttIndex);
  if (att.isNumeric()) {
    return ((m_Not ? ">= " : "< ") + Utils.doubleToString(m_Split,3));
  }
  else {
    if (att.numValues() != 2) 
      return ((m_Not ? "!= " : "= ") + att.value((int)m_Split));
    else return ("= " 
                 + (m_Not ?
    att.value((int)m_Split == 0 ? 1 : 0) : att.value((int)m_Split)));
  }
}
 
Example 8
Source File: MILR.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets a string describing the classifier.
 *
 * @return a string describing the classifer built.
 */
public String toString() {

  String result = "Modified Logistic Regression";
  if (m_Par == null) {
    return result + ": No model built yet.";
  }

  result += "\nMean type: " + getAlgorithmType().getSelectedTag().getReadable() + "\n";
  result += "\nCoefficients...\n"
    + "Variable      Coeff.\n";
  for (int j = 1, idx=0; j < m_Par.length; j++, idx++) {
    result += m_Attributes.attribute(idx).name();
    result += " "+Utils.doubleToString(m_Par[j], 12, 4); 
    result += "\n";
  }

  result += "Intercept:";
  result += " "+Utils.doubleToString(m_Par[0], 10, 4); 
  result += "\n";

  result += "\nOdds Ratios...\n"
    + "Variable         O.R.\n";
  for (int j = 1, idx=0; j < m_Par.length; j++, idx++) {
    result += " " + m_Attributes.attribute(idx).name(); 
    double ORc = Math.exp(m_Par[j]);
    result += " " + ((ORc > 1e10) ?  "" + ORc : Utils.doubleToString(ORc, 12, 4));
  }
  result += "\n";
  return result;
}
 
Example 9
Source File: BVDecomposeSegCVSub.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 10
Source File: BVDecompose.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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";
}
 
Example 11
Source File: RandomTree.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
  if (m_ClassDistribution != null) {
    sum = Utils.sum(m_ClassDistribution);
    maxIndex = Utils.maxIndex(m_ClassDistribution);
    maxCount = m_ClassDistribution[maxIndex];
  }
  return " : " + m_Info.classAttribute().value(maxIndex) + " ("
      + Utils.doubleToString(sum, 2) + "/"
      + Utils.doubleToString(sum - maxCount, 2) + ")";
}
 
Example 12
Source File: CVParameterSelection.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Create the options array to pass to the classifier. The parameter
  * values and positions are taken from m_ClassifierOptions and
  * m_CVParams.
  *
  * @return the options array
  */
 protected String [] createOptions() {
   
   String [] options = new String [m_ClassifierOptions.length 
			   + 2 * m_CVParams.size()];
   int start = 0, end = options.length;

   // Add the cross-validation parameters and their values
   for (int i = 0; i < m_CVParams.size(); i++) {
     CVParameter cvParam = (CVParameter)m_CVParams.elementAt(i);
     double paramValue = cvParam.m_ParamValue;
     if (cvParam.m_RoundParam) {
       //	paramValue = (double)((int) (paramValue + 0.5));
       paramValue = Math.rint(paramValue);
     }
     boolean isInt = ((paramValue - (int)paramValue) == 0);
     
     if (cvParam.m_AddAtEnd) {
       options[--end] = "" + ((cvParam.m_RoundParam || isInt) ? 
           Utils.doubleToString(paramValue,4) : cvParam.m_ParamValue);
//Utils.doubleToString(paramValue,4);
options[--end] = "-" + cvParam.m_ParamChar;
     } else {
options[start++] = "-" + cvParam.m_ParamChar;
options[start++] = "" + ((cvParam.m_RoundParam || isInt) ? 
           Utils.doubleToString(paramValue,4) : cvParam.m_ParamValue);
//+ Utils.doubleToString(paramValue,4);
     }
   }
   // Add the static parameters
   System.arraycopy(m_ClassifierOptions, 0,
	     options, start,
	     m_ClassifierOptions.length);

   return options;
 }
 
Example 13
Source File: MahalanobisEstimator.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/** 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;
}
 
Example 14
Source File: NormalEstimator.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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";
}
 
Example 15
Source File: DefaultAssociationRule.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
public String toXML(int premiseSupport, int consequenceSupport,
    int totalSupport, int totalTransactions) {
  String result = "<CRITERE name=\"" + m_stringVal + "\" value=\" " +
    Utils.doubleToString(compute(premiseSupport, consequenceSupport,
      totalSupport, totalTransactions), 2) + "\"/>";
  
  return result;
}
 
Example 16
Source File: REPTree.java    From tsml with GNU General Public License v3.0 4 votes vote down vote up
/**
    * Outputs description of a leaf node.
    * 
    * @param parent the parent of the node
    * @return the description of the node
    * @throws Exception if generation fails
    */
   protected String leafString(Tree parent) throws Exception {
   
     if (m_Info.classAttribute().isNumeric()) {
double classMean;
if (m_ClassProbs == null) {
  classMean = parent.m_ClassProbs[0];
} else {
  classMean = m_ClassProbs[0];
}
StringBuffer buffer = new StringBuffer();
buffer.append(" : " + Utils.doubleToString(classMean, 2));
double avgError = 0;
if (m_Distribution[1] > 0) {
  avgError = m_Distribution[0] / m_Distribution[1];
}
buffer.append(" (" +
	      Utils.doubleToString(m_Distribution[1], 2) + "/" +
	      Utils.doubleToString(avgError, 2) 
	      + ")");
avgError = 0;
if (m_HoldOutDist[0] > 0) {
  avgError = m_HoldOutError / m_HoldOutDist[0];
}
buffer.append(" [" +
	      Utils.doubleToString(m_HoldOutDist[0], 2) + "/" +
	      Utils.doubleToString(avgError, 2) 
	      + "]");
return buffer.toString();
     } else { 
int maxIndex;
if (m_ClassProbs == null) {
  maxIndex = Utils.maxIndex(parent.m_ClassProbs);
} else {
  maxIndex = Utils.maxIndex(m_ClassProbs);
}
return " : " + m_Info.classAttribute().value(maxIndex) + 
  " (" + Utils.doubleToString(Utils.sum(m_Distribution), 2) + 
  "/" + 
  Utils.doubleToString((Utils.sum(m_Distribution) - 
			m_Distribution[maxIndex]), 2) + ")" +
  " [" + Utils.doubleToString(Utils.sum(m_HoldOutDist), 2) + "/" + 
  Utils.doubleToString((Utils.sum(m_HoldOutDist) - 
			m_HoldOutDist[maxIndex]), 2) + "]";
     }
   }
 
Example 17
Source File: DefaultAssociationRule.java    From tsml with GNU General Public License v3.0 4 votes vote down vote up
public String toStringMetric(int premiseSupport, int consequenceSupport,
    int totalSupport, int totalTransactions) {
  return m_stringVal + ":(" + Utils.doubleToString(compute(premiseSupport, consequenceSupport,
      totalSupport, totalTransactions), 2) + ")";
}
 
Example 18
Source File: PoissonEstimator.java    From tsml with GNU General Public License v3.0 4 votes vote down vote up
/** Display a representation of this estimator */
public String toString() {
  
  return "Poisson Lambda = " + Utils.doubleToString(m_Lambda, 4, 2) + "\n";
}
 
Example 19
Source File: ConjunctiveRule.java    From tsml with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Prints this antecedent
 *
 * @return a textual description of this antecedent
 */
public String toString() {
  String symbol = Utils.eq(value, 0.0) ? " <= " : " > ";
  return (att.name() + symbol + Utils.doubleToString(splitPoint, 6));
}
 
Example 20
Source File: JRip.java    From tsml with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Prints this antecedent
 *
 * @return a textual description of this antecedent
 */
public String toString() {
  String symbol = ((int)value == 0) ? " <= " : " >= ";
  return (att.name() + symbol + Utils.doubleToString(splitPoint, 6));
}