Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Mean and Variance
import org.apache.spark.mllib.stat.MultivariateStatisticalSummary;
import org.apache.spark.mllib.stat.Statistics;
private MultivariateStatisticalSummary summary;
public ExtractFeature(JavaRDD<Vector> data) {
this.summary = Statistics.colStats(data.rdd());
// return (mean_acc_x, mean_acc_y, mean_acc_z)
public double[] computeAvgAcc() {
return this.summary.mean().toArray();
// return (var_acc_x, var_acc_y, var_acc_z)
public double[] computeVariance() {
return this.summary.variance().toArray();
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.