Codota Logo
DecisionTree.predict
Code IndexAdd Codota to your IDE (free)

How to use
predict
method
in
smile.classification.DecisionTree

Best Java code snippets using smile.classification.DecisionTree.predict (Showing top 12 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: tech.tablesaw/tablesaw-smile

  @Override
  int predictFromModel(double[] data) {
    return classifierModel.predict(data);
  }
}
origin: tech.tablesaw/tablesaw-smile

public int predict(double[] data) {
  return classifierModel.predict(data);
}
origin: com.github.haifengl/smile-core

@Override
public int predict(double[] x) {
  double[] y = new double[k];
  for (int i = 0; i < trees.length; i++) {
    y[trees[i].predict(x)] += alpha[i];
  }
    
  return Math.whichMax(y);
}

origin: com.github.haifengl/smile-core

@Override
public int predict(double[] x) {
  int[] y = new int[k];
  
  for (Tree tree : trees) {
    y[tree.tree.predict(x)]++;
  }
  
  return Math.whichMax(y);
}

origin: com.github.haifengl/smile-core

@Override
public int predict(double[] x, double[] posteriori) {
  if (posteriori.length != k) {
    throw new IllegalArgumentException(String.format("Invalid posteriori vector size: %d, expected: %d", posteriori.length, k));
  }
  Arrays.fill(posteriori, 0.0);
  int[] y = new int[k];
  double[] pos = new double[k];
  for (Tree tree : trees) {
    y[tree.tree.predict(x, pos)]++;
    for (int i = 0; i < k; i++) {
      posteriori[i] += tree.weight * pos[i];
    }
  }
  Math.unitize1(posteriori);
  return Math.whichMax(y);
}    

origin: com.github.haifengl/smile-core

/**
 * Predicts the class label of an instance and also calculate a posteriori
 * probabilities. Not supported.
 */
@Override
public int predict(double[] x, double[] posteriori) {
  Arrays.fill(posteriori, 0.0);
  for (int i = 0; i < trees.length; i++) {
    posteriori[trees[i].predict(x)] += alpha[i];
  }
  double sum = Math.sum(posteriori);
  for (int i = 0; i < k; i++) {
    posteriori[i] /= sum;
  }
  return Math.whichMax(posteriori);
}

origin: com.github.haifengl/smile-core

/**
 * Test the model on a validation dataset.
 * 
 * @param x the test data set.
 * @param y the test data labels.
 * @param measures the performance measures of classification.
 * @return performance measures with first 1, 2, ..., decision trees.
 */
public double[][] test(double[][] x, int[] y, ClassificationMeasure[] measures) {
  int T = trees.size();
  int m = measures.length;
  double[][] results = new double[T][m];
  int n = x.length;
  int[] label = new int[n];
  double[][] prediction = new double[n][k];
  for (int i = 0; i < T; i++) {
    for (int j = 0; j < n; j++) {
      prediction[j][trees.get(i).tree.predict(x[j])]++;
      label[j] = Math.whichMax(prediction[j]);
    }
    for (int j = 0; j < m; j++) {
      results[i][j] = measures[j].measure(y, label);
    }
  }
  return results;
}
origin: com.github.haifengl/smile-core

for (int i = 0; i < T; i++) {
  for (int j = 0; j < n; j++) {
    prediction[j] += alpha[i] * trees[i].predict(x[j]);
    label[j] = prediction[j] > 0 ? 1 : 0;
for (int i = 0; i < T; i++) {
  for (int j = 0; j < n; j++) {
    prediction[j][trees[i].predict(x[j])] += alpha[i];
    label[j] = Math.whichMax(prediction[j]);
origin: com.github.haifengl/smile-core

/**
 * Test the model on a validation dataset.
 * 
 * @param x the test data set.
 * @param y the test data response values.
 * @return accuracies with first 1, 2, ..., decision trees.
 */
public double[] test(double[][] x, int[] y) {
  int T = trees.size();
  double[] accuracy = new double[T];
  int n = x.length;
  int[] label = new int[n];
  int[][] prediction = new int[n][k];
  Accuracy measure = new Accuracy();
  
  for (int i = 0; i < T; i++) {
    for (int j = 0; j < n; j++) {
      prediction[j][trees.get(i).tree.predict(x[j])]++;
      label[j] = Math.whichMax(prediction[j]);
    }
    accuracy[i] = measure.measure(y, label);
  }
  return accuracy;
}

origin: com.github.haifengl/smile-core

for (int i = 0; i < T; i++) {
  for (int j = 0; j < n; j++) {
    prediction[j] += alpha[i] * trees[i].predict(x[j]);
    label[j] = prediction[j] > 0 ? 1 : 0;
for (int i = 0; i < T; i++) {
  for (int j = 0; j < n; j++) {
    prediction[j][trees[i].predict(x[j])] += alpha[i];
    label[j] = Math.whichMax(prediction[j]);
origin: com.github.haifengl/smile-core

if (samples[i] == 0) {
  oob++;
  int p = tree.predict(x[i]);
  if (p == y[i]) correct++;
  synchronized (prediction[i]) {
origin: com.github.haifengl/smile-core

err[i] = trees[t].predict(x[i]) != y[i];
smile.classificationDecisionTreepredict

Javadoc

Predicts the class label of an instance and also calculate a posteriori probabilities. The posteriori estimation is based on sample distribution in the leaf node. It is not accurate at all when be used in a single tree. It is mainly used by RandomForest in an ensemble way.

Popular methods of DecisionTree

  • <init>
    Constructor. Learns a classification tree with (most) given number of leaves. All attributes are ass
  • importance
    Returns the variable importance. Every time a split of a node is made on variable the (GINI, informa
  • maxDepth

Popular in Java

  • Updating database using SQL prepared statement
  • setContentView (Activity)
  • getSystemService (Context)
  • getSharedPreferences (Context)
  • PrintStream (java.io)
    A PrintStream adds functionality to another output stream, namely the ability to print representatio
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • BoxLayout (javax.swing)
  • JButton (javax.swing)
  • JList (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now