@Test public void testAll() { test("CPU", CPU.formula, CPU.data, 75.0190); test("2dplanes", Planes.formula, Planes.data, 1.3574); test("abalone", Abalone.formula, Abalone.train, 2.1932); test("ailerons", Ailerons.formula, Ailerons.data, 0.0002); test("bank32nh", Bank32nh.formula, Bank32nh.data, 0.0978); test("autoMPG", AutoMPG.formula, AutoMPG.data, 3.5632); test("cal_housing", CalHousing.formula, CalHousing.data, 58552.3225); test("puma8nh", Puma8NH.formula, Puma8NH.data, 3.3149); test("kin8nm", Kin8nm.formula, Kin8nm.data, 0.1704); }
public double[][] test(DataFrame data) { DataFrame x = formula.x(data); int n = x.nrows(); int ntrees = trees.length; double[][] prediction = new double[ntrees][n]; for (int j = 0; j < n; j++) { Tuple xj = x.get(j); double base = 0; for (int i = 0; i < ntrees; i++) { base = base + trees[i].predict(xj); prediction[i][j] = base / (i+1); } } return prediction; }
RandomForest implements Regression<Tuple>, DataFrameRegression, TreeSHAP { public double[][] test(DataFrame data) { DataFrame x = formula.x(data); int n = x.nrows(); int ntrees = trees.length; double[][] prediction = new double[ntrees][n]; for (int j = 0; j < n; j++) { Tuple xj = x.get(j); double base = 0; for (int i = 0; i < ntrees; i++) { base = base + trees[i].predict(xj); prediction[i][j] = base / (i+1); } } return prediction; } }
RandomForest implements Regression<Tuple>, DataFrameRegression, TreeSHAP { public double[][] test(DataFrame data) { DataFrame x = formula.x(data); int n = x.nrows(); int ntrees = trees.length; double[][] prediction = new double[ntrees][n]; for (int j = 0; j < n; j++) { Tuple xj = x.get(j); double base = 0; for (int i = 0; i < ntrees; i++) { base = base + trees[i].predict(xj); prediction[i][j] = base / (i+1); } } return prediction; } RandomForest(Formula formula, RegressionTree[] trees, double error, double[] importance); }
RandomForest implements Regression<Tuple>, DataFrameRegression, TreeSHAP { public double[][] test(DataFrame data) { DataFrame x = formula.x(data); int n = x.nrows(); int ntrees = trees.length; double[][] prediction = new double[ntrees][n]; for (int j = 0; j < n; j++) { Tuple xj = x.get(j); double base = 0; for (int i = 0; i < ntrees; i++) { base = base + trees[i].predict(xj); prediction[i][j] = base / (i+1); } } return prediction; } RandomForest(Formula formula, RegressionTree[] trees, double error, double[] importance); static RandomForest fit(Formula formula, DataFrame data); static RandomForest fit(Formula formula, DataFrame data, Properties prop); static RandomForest fit(Formula formula, DataFrame data, int ntrees, int mtry, int maxDepth, int maxNodes, int nodeSize, double subsample); static RandomForest fit(Formula formula, DataFrame data, int ntrees, int mtry, int maxDepth, int maxNodes, int nodeSize, double subsample, LongStream seeds); RandomForest merge(RandomForest other); @Override Formula formula(); @Override StructType schema(); double error(); double[] importance(); int size(); @Override RegressionTree[] trees(); void trim(int ntrees); @Override double predict(Tuple x); double[][] test(DataFrame data); }
RandomForest implements Regression<Tuple>, DataFrameRegression, TreeSHAP { public double[][] test(DataFrame data) { DataFrame x = formula.x(data); int n = x.nrows(); int ntrees = trees.length; double[][] prediction = new double[ntrees][n]; for (int j = 0; j < n; j++) { Tuple xj = x.get(j); double base = 0; for (int i = 0; i < ntrees; i++) { base = base + trees[i].predict(xj); prediction[i][j] = base / (i+1); } } return prediction; } RandomForest(Formula formula, RegressionTree[] trees, double error, double[] importance); static RandomForest fit(Formula formula, DataFrame data); static RandomForest fit(Formula formula, DataFrame data, Properties prop); static RandomForest fit(Formula formula, DataFrame data, int ntrees, int mtry, int maxDepth, int maxNodes, int nodeSize, double subsample); static RandomForest fit(Formula formula, DataFrame data, int ntrees, int mtry, int maxDepth, int maxNodes, int nodeSize, double subsample, LongStream seeds); RandomForest merge(RandomForest other); @Override Formula formula(); @Override StructType schema(); double error(); double[] importance(); int size(); @Override RegressionTree[] trees(); void trim(int ntrees); @Override double predict(Tuple x); double[][] test(DataFrame data);  }