Skip to content

Instantly share code, notes, and snippets.

@MiraLak MiraLak/PredictActivity.java Secret
Created May 31, 2015

Embed
What would you like to do?
Actitacker Spark Cassandra
public static String predict(JavaSparkContext sc) {
//load the defined model
DecisionTreeModel model = DecisionTreeModel.load(sc.sc(), "actitracker");
Vector feature = computeFeature(sc);
double prediction = model.predict(feature);
String result = "No activity predicted";
switch ((int) prediction) {
case 0:
result = "Walking";
break;
case 1:
result = "Jogging";
break;
case 2:
result = "Standing";
break;
case 3:
result = "Sitting";
break;
case 4:
result = "Upstairs";
break;
case 5:
result = "Downstairs";
break;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.