Skip to content

Instantly share code, notes, and snippets.

@MiraLak
Created May 31, 2015 16:47
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 MiraLak/a130849a9fa7a1916d55 to your computer and use it in GitHub Desktop.
Save MiraLak/a130849a9fa7a1916d55 to your computer and use it in GitHub Desktop.
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