@Test public void testPredict() { Vector weights = new DenseVector(new double[] {2.0, 3.0}); assertFalse(new LogisticRegressionModel(weights, 1.0).isKeepingRawLabels()); assertEquals(0.1, new LogisticRegressionModel(weights, 1.0).withThreshold(0.1).threshold(), 0); assertTrue(!new LogisticRegressionModel(weights, 1.0).toString().isEmpty()); assertTrue(!new LogisticRegressionModel(weights, 1.0).toString(true).isEmpty()); assertTrue(!new LogisticRegressionModel(weights, 1.0).toString(false).isEmpty()); verifyPredict(new LogisticRegressionModel(weights, 1.0).withRawLabels(true)); verifyPredict(new LogisticRegressionModel(null, 1.0).withRawLabels(true).withWeights(weights)); verifyPredict(new LogisticRegressionModel(weights, 1.0).withRawLabels(true).withThreshold(0.5)); verifyPredict(new LogisticRegressionModel(weights, 0.0).withRawLabels(true).withIntercept(1.0)); }
@Override public Double predict(Vector input) { final double res = sigmoid(input.dot(weights) + intercept); if (isKeepingRawLabels) return res; else return res - threshold > 0 ? 1.0 : 0; }
LogisticRegressionModel implements IgniteModel<Vector, Double>, Exportable<LogisticRegressionModel>, Serializable { @Override public Double predict(Vector input) { final double res = sigmoid(input.dot(weights) + intercept); if (isKeepingRawLabels) return res; else return res - threshold > 0 ? 1.0 : 0; } }
LogisticRegressionModel implements IgniteModel<Vector, Double>, Exportable<LogisticRegressionModel>, Serializable { @Override public Double predict(Vector input) { final double res = sigmoid(input.dot(weights) + intercept); if (isKeepingRawLabels) return res; else return res - threshold > 0 ? 1.0 : 0; } LogisticRegressionModel(Vector weights, double intercept); }
LogisticRegressionModel implements IgniteModel<Vector, Double>, Exportable<LogisticRegressionModel>, Serializable { @Override public Double predict(Vector input) { final double res = sigmoid(input.dot(weights) + intercept); if (isKeepingRawLabels) return res; else return res - threshold > 0 ? 1.0 : 0; } LogisticRegressionModel(Vector weights, double intercept); LogisticRegressionModel withRawLabels(boolean isKeepingRawLabels); LogisticRegressionModel withThreshold(double threshold); LogisticRegressionModel withWeights(Vector weights); LogisticRegressionModel withIntercept(double intercept); boolean isKeepingRawLabels(); double threshold(); Vector weights(); double intercept(); @Override Double predict(Vector input); @Override void saveModel(Exporter<LogisticRegressionModel, P> exporter, P path); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override String toString(boolean pretty); }
LogisticRegressionModel implements IgniteModel<Vector, Double>, Exportable<LogisticRegressionModel>, Serializable { @Override public Double predict(Vector input) { final double res = sigmoid(input.dot(weights) + intercept); if (isKeepingRawLabels) return res; else return res - threshold > 0 ? 1.0 : 0; } LogisticRegressionModel(Vector weights, double intercept); LogisticRegressionModel withRawLabels(boolean isKeepingRawLabels); LogisticRegressionModel withThreshold(double threshold); LogisticRegressionModel withWeights(Vector weights); LogisticRegressionModel withIntercept(double intercept); boolean isKeepingRawLabels(); double threshold(); Vector weights(); double intercept(); @Override Double predict(Vector input); @Override void saveModel(Exporter<LogisticRegressionModel, P> exporter, P path); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override String toString(boolean pretty);  }