Last active
September 15, 2017 14:39
-
-
Save bbejeck/baa2022c8c79540178710664fa245ca0 to your computer and use it in GitHub Desktop.
Showing the Prediction Process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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