Search in sources :

Example 1 with SVMModel

use of org.apache.spark.mllib.classification.SVMModel in project incubator-sdap-mudrod by apache.

the class SparkSVM method main.

public static void main(String[] args) {
    MudrodEngine me = new MudrodEngine();
    JavaSparkContext jsc = me.startSparkDriver().sc;
    String path = SparkSVM.class.getClassLoader().getResource("inputDataForSVM_spark.txt").toString();
    JavaRDD<LabeledPoint> data = MLUtils.loadLibSVMFile(jsc.sc(), path).toJavaRDD();
    // Run training algorithm to build the model.
    int numIterations = 100;
    final SVMModel model = SVMWithSGD.train(data.rdd(), numIterations);
    // Save and load model
    model.save(jsc.sc(), SparkSVM.class.getClassLoader().getResource("javaSVMWithSGDModel").toString());
    jsc.sc().stop();
}
Also used : SVMModel(org.apache.spark.mllib.classification.SVMModel) MudrodEngine(org.apache.sdap.mudrod.main.MudrodEngine) JavaSparkContext(org.apache.spark.api.java.JavaSparkContext) LabeledPoint(org.apache.spark.mllib.regression.LabeledPoint) LabeledPoint(org.apache.spark.mllib.regression.LabeledPoint)

Aggregations

MudrodEngine (org.apache.sdap.mudrod.main.MudrodEngine)1 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)1 SVMModel (org.apache.spark.mllib.classification.SVMModel)1 LabeledPoint (org.apache.spark.mllib.regression.LabeledPoint)1