Skip to content

Instantly share code, notes, and snippets.

@bbejeck
Last active September 15, 2017 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbejeck/baa2022c8c79540178710664fa245ca0 to your computer and use it in GitHub Desktop.
Save bbejeck/baa2022c8c79540178710664fa245ca0 to your computer and use it in GitHub Desktop.
Showing the Prediction Process
public static String predict(DataRegression dataRegression) {
try (OnlineLogisticRegression logisticRegression = new OnlineLogisticRegression()) {
FlightData flightData = new FlightData(dataRegression.data);
logisticRegression.readFields(new DataInputStream(new ByteArrayInputStream(dataRegression.coefficients)));
double prediction = logisticRegression.classifyScalar(flightData.vector);
String arrivalPrediction = prediction > 0.5 ? "on-time" : "late";
return String.format("%s predicted to be %s", new Flight(dataRegression.data), arrivalPrediction);
} catch (Exception e) {
LOG.error("Problems with predicting " + dataRegression.data, e);
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment