@Test public void testQuantile() { test(Loss.quantile(0.5), "CPU", CPU.formula, CPU.data, 89.6677); test(Loss.quantile(0.5), "2dplanes", Planes.formula, Planes.data, 1.1347); test(Loss.quantile(0.5), "abalone", Abalone.formula, Abalone.train, 2.2999); test(Loss.quantile(0.5), "ailerons", Ailerons.formula, Ailerons.data, 0.0002); test(Loss.quantile(0.5), "bank32nh", Bank32nh.formula, Bank32nh.data, 0.0912); test(Loss.quantile(0.5), "autoMPG", AutoMPG.formula, AutoMPG.data, 3.1389); test(Loss.quantile(0.5), "cal_housing", CalHousing.formula, CalHousing.data, 66772.6697); test(Loss.quantile(0.5), "puma8nh", Puma8NH.formula, Puma8NH.data, 3.2495); test(Loss.quantile(0.5), "kin8nm", Kin8nm.formula, Kin8nm.data, 0.1814); }
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 = b; for (int i = 0; i < ntrees; i++) { base += shrinkage * trees[i].predict(xj); prediction[i][j] = base; } } return prediction; }
GradientTreeBoost 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 = b; for (int i = 0; i < ntrees; i++) { base += shrinkage * trees[i].predict(xj); prediction[i][j] = base; } } return prediction; } }
GradientTreeBoost 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 = b; for (int i = 0; i < ntrees; i++) { base += shrinkage * trees[i].predict(xj); prediction[i][j] = base; } } return prediction; } GradientTreeBoost(Formula formula, RegressionTree[] trees, double b, double shrinkage, double[] importance); }
GradientTreeBoost 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 = b; for (int i = 0; i < ntrees; i++) { base += shrinkage * trees[i].predict(xj); prediction[i][j] = base; } } return prediction; } GradientTreeBoost(Formula formula, RegressionTree[] trees, double b, double shrinkage, double[] importance); static GradientTreeBoost fit(Formula formula, DataFrame data); static GradientTreeBoost fit(Formula formula, DataFrame data, Properties prop); static GradientTreeBoost fit(Formula formula, DataFrame data, Loss loss, int ntrees, int maxDepth, int maxNodes, int nodeSize, double shrinkage, double subsample); @Override Formula formula(); @Override StructType schema(); double[] importance(); int size(); @Override RegressionTree[] trees(); void trim(int ntrees); @Override double predict(Tuple x); double[][] test(DataFrame data); }
GradientTreeBoost 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 = b; for (int i = 0; i < ntrees; i++) { base += shrinkage * trees[i].predict(xj); prediction[i][j] = base; } } return prediction; } GradientTreeBoost(Formula formula, RegressionTree[] trees, double b, double shrinkage, double[] importance); static GradientTreeBoost fit(Formula formula, DataFrame data); static GradientTreeBoost fit(Formula formula, DataFrame data, Properties prop); static GradientTreeBoost fit(Formula formula, DataFrame data, Loss loss, int ntrees, int maxDepth, int maxNodes, int nodeSize, double shrinkage, double subsample); @Override Formula formula(); @Override StructType schema(); double[] importance(); int size(); @Override RegressionTree[] trees(); void trim(int ntrees); @Override double predict(Tuple x); double[][] test(DataFrame data);  }