Spark中组件Mllib的学习29之支持向量机SVM-方法2

更多代码请见:https://github.com/xubo245/SparkLearning
Spark中组件Mllib的学习之分类篇
1解释
spark官网第二种方法建立SVMmodel

2.代码:

/**
  * @author xubo
  *         ref:Spark MlLib机器学习实战
  *         more code:https://github.com/xubo245/SparkLearning
  *         more blog:http://blog.csdn.net/xubo245
  */
package org.apache.spark.mllib.learning.regression

import java.text.SimpleDateFormat
import java.util.Date

import org.apache.spark.mllib.classification.{SVMModel, SVMWithSGD}
import org.apache.spark.mllib.evaluation.BinaryClassificationMetrics
import org.apache.spark.mllib.util.MLUtils
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.mllib.optimization.L1Updater

/**
  * Created by xubo on 2016/5/23.
  * SVM
  */
object SVMFromSpark2Learning {
  def main(args: Array[String]) {
    val conf = new SparkConf().setMaster("local[4]").setAppName(this.getClass().getSimpleName().filter(!_.equals('$')))
    val sc = new SparkContext(conf)

    // Load training data in LIBSVM format.
    val data = MLUtils.loadLibSVMFile(sc, "file/data/mllib/input/regression/sample_libsvm_data.txt")

    // Split data into training (60%) and test (40%).
    val splits = data.randomSplit(Array(0.6, 0.4), seed = 11L)
    val training = splits(0).cache()
    val test = splits(1)

    // Run training algorithm to build the model
    val numIterations = 100

    //method 1
    //    val model = SVMWithSGD.train(training, numIterations)

    //method 2
    val svmAlg = new SVMWithSGD()
    svmAlg.optimizer.
      setNumIterations(numIterations).
      setRegParam(0.1).
      setUpdater(new L1Updater)
    val model = svmAlg.run(training)


    // Clear the default threshold.
    model.clearThreshold()

    // Compute raw scores on the test set.
    val scoreAndLabels = test.map { point =>
      val score = model.predict(point.features)
      (score, point.label)
    }

    // Get evaluation metrics.
    val metrics = new BinaryClassificationMetrics(scoreAndLabels)
    val auROC = metrics.areaUnderROC()

    println("Area under ROC = " + auROC)
    println(model.weights)
    println("model.weights.size" + model.weights.size)
    scoreAndLabels.take(10).foreach(println)
    // Save and load model
    val iString = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())
    val path = "file/data/mllib/output/regression/sample_libsvm_data" + iString + "/result"
    model.save(sc, path)
    val sameModel = SVMModel.load(sc, path)
    println(sameModel.weights)
    println("end")
    sc.stop
  }
}

3.结果:

Area under ROC = 1.0
[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.13783517724601466,-3.1222101772460142,0.0,4.9867616869624065,6.35923081383617,6.891442730128846,0.8181771385458148,0.3097101772460146,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,2.2968796972768697,8.293579454514326,3.974527843646873,-0.0,2.9503351772460142,7.5963207932706975,1.4655543966303575,-7.185215899977705,-8.849258258788748,-15.81337989246107,-13.639119854604457,-1.223878500999535,22.155650349510783,3.009785720362156,-0.4972101772460146,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,2.189795773040486,7.865243757568792,7.112815171690069,5.222190171690069,-1.7251710764936685,-10.113870934882186,-2.4123051423415354,-15.872715899977702,-43.59586513856508,-53.73255178384851,-41.99461994201903,-13.73425447488869,-19.77514628341968,-0.5420999679960112,-8.355046004581647,-7.325335177246015,-1.4815851772460147,-0.5909601772460146,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,5.509397424368363,5.519065171690069,0.8761115279273785,-3.5847301828019615,-18.1463142081894,-18.464083910292164,-30.872715899977695,-40.388340899977706,-39.380226625436606,-37.39477038883295,-32.357032092175125,-22.021620399520277,-32.62861026031238,-25.85661738769483,-31.466711708300146,-13.345951510712547,-7.151306115537353,-3.1690851772460142,-1.5440851772460147,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.8456798388883541,-1.2311283291719626,-4.3034801828019615,-13.854021359716636,-23.02016980953982,-41.36190375400642,-46.026720676317055,-39.79501716400513,-11.99568801866026,-18.40642887044021,-23.238425956296172,-52.8174965144595,-37.745224967996016,-41.16709996799602,-40.99522496799602,-11.91709996799601,-3.8617131527223902,-3.7628351772460156,-3.1690851772460142,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0,-6.325335177246015,-11.230119162173036,-14.44410518280196,-23.275805445794713,-47.5004437573929,-54.7045252514618,-33.70724388557044,-9.505492767228736,20.605799562555795,11.18192672460626,-3.566860350871969,-24.413810502197677,-31.49522496799602,-49.29209996799601,-55.07334996799601,-38.432041757946806,-11.962471905887742,-6.372210177246015,-3.1690851772460142,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-2.2784601772460142,-10.684710177246016,-17.352415556064095,-28.933290758366216,-35.43393113886715,-35.95124194311829,-52.08778625161769,-17.2255255740857,17.110469472025596,29.819696700587187,33.7557743053465,25.760403053066906,11.201540435033953,-6.83897496799601,-50.182724967996,-78.56336730106291,-67.64012588096452,-41.91908517724602,-11.403460177246016,-3.2472101772460142,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-3.4190851772460147,-16.21596017724601,-26.89901541181884,-28.623920062594607,-38.45824878986433,-51.42044680695175,-49.90739321638901,-19.112471969054468,23.107999027391045,57.03102047124557,65.52139930534648,44.767070201207666,36.07924343219592,3.199104530194077,-41.60189933824799,-93.75616802910525,-75.87221017724602,-52.93471017724602,-20.55971017724601,-4.794085177246015,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-9.090960177246016,-24.002937634862736,-19.32299068982304,-23.359229291498195,-42.80800203788202,-43.71437411051801,-55.52466230698107,-21.69653730698106,42.76402176523723,86.03441331834891,93.68058133549245,66.9261222861558,48.49438296305026,6.949877469842939,-46.1475445601594,-81.74721017724602,-74.84096017724602,-61.55971017724602,-29.45033517724601,-8.747210177246016,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-15.499500880964519,-14.705092824402875,-9.057086538164059,-39.58621079569384,-64.56976594363476,-63.6543346642761,-44.374642545004335,-14.68517059065482,63.71206211184672,111.3151590547207,117.60069464531908,90.46894824066996,44.63257937717154,-7.695102770208612,-45.85658517724602,-77.87221017724602,-74.04408517724602,-67.80971017724602,-39.96596017724602,-14.278460177246016,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-9.214352683576724,-13.213974967996014,-43.391009460049176,-74.71307325021601,-83.57231160820618,-66.64764135493095,-42.05636561675474,-6.074053268481326,98.40515233789158,126.27717333754497,127.88577439768694,91.00299325676097,37.627675839019844,-26.28546893041137,-44.54408517724602,-74.71596017724602,-76.96596017724602,-68.13783517724602,-43.73158517724602,-19.01283517724601,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0,-7.5853178441790865,-39.703514054028496,-70.04199943654228,-85.52846017724602,-75.91908517724602,-50.85658517724602,-31.30971017724601,16.31209216693155,112.4411219995339,130.37720242272732,132.125150684832,74.82438253958523,27.628444761280544,-24.21596017724601,-49.74721017724602,-72.73158517724602,-72.63783517724602,-61.30971017724602,-45.34096017724602,-18.88783517724601,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0,-31.32533517724601,-62.32533517724602,-77.63783517724602,-91.51283517724602,-71.65346017724602,-42.85658517724602,-11.715960177246016,46.65895830338581,116.80283467149071,144.76456047208674,118.65825897049115,62.78424325676098,7.441273538202901,-21.099070995572816,-54.70033517724602,-73.01283517724602,-65.99721017724602,-55.01283517724602,-43.34096017724602,-16.02846017724601,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.09096017724601467,-38.65346017724602,-65.87221017724602,-86.85658517724602,-88.87221017724602,-63.419085177246025,-34.60658517724602,4.122210177246015,58.18278503563453,109.71545445451433,144.2286607436448,100.14041158777755,43.08039893615566,4.560225130957888,-27.389944425165787,-61.528231753209,-73.4126244803005,-67.96596017724602,-42.77846017724602,-36.98158517724602,-15.606585177246014,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-2.5440851772460142,-40.74721017724602,-66.41908517724602,-91.73158517724602,-86.49721017724602,-62.51283517724602,-23.05971017724601,24.54408517724601,58.96403503563453,107.53462160265508,122.97772279619048,87.04666158777755,36.21983142804218,-6.597927618058493,-39.85984110227982,-59.988048152656006,-70.94204253107537,-58.43471017724602,-38.48158517724602,-32.71596017724602,-11.731585177246016,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-2.4347101772460142,-36.73158517724602,-63.32533517724602,-93.57533517724602,-89.68471017724602,-63.481585177246025,-8.035150585098878,38.973932284704006,66.31841415300826,112.77441024744816,109.14343795448812,72.80353585097419,19.932530163028378,-29.371892960288886,-53.29046897485556,-62.41533101200168,-50.16908877950716,-40.40236157758448,-36.46596017724602,-24.95033517724601,-6.512835177246015,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.9815851772460145,-25.30971017724601,-58.59096017724602,-89.94424105419513,-99.48942116973163,-65.58056078555018,-7.113965839843261,34.23304765401862,62.07954557785629,100.00876233030206,100.10297517043257,54.89778403347672,0.06461626554617624,-38.62787588157201,-46.81812250370681,-43.860715837339974,-29.82020880202319,-36.872670347075605,-30.74721017724601,-16.79408517724601,-1.4347101772460147,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0,-13.903460177246016,-45.570203538884286,-69.73644458566298,-89.76526730142511,-65.10901730142511,-28.453317341885533,5.568740181614654,14.646972194139263,39.996437907737416,40.66836262450001,-0.490516441056583,-27.948411543358276,-36.94630060542174,-20.400038510225432,-40.19594045378262,-32.58977250415879,-26.934574320623398,-23.01283517724601,-5.262835177246015,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-3.9659601772460156,-5.080575261360139,-28.97259599328143,-60.35781973378538,-59.71921215348418,-43.821301373692165,-21.25124010616062,-28.57445976684736,-9.667605690727699,-10.495730690727699,-23.194411049315573,-36.120730690727704,-36.54063883570329,-35.30532720622055,-33.45973018280196,-24.365980182801955,-17.83766221294792,-9.278460177246016,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.5440851772460146,10.442811736995536,5.960871688209347,-14.926541714943955,-28.159724145339997,-34.06597329643792,-21.230105690727694,-30.370730690727697,-33.648727044158335,-29.635118099691752,-27.471032301595148,-37.544671768681575,-29.194581817640923,-23.615980182801955,-15.27223018280196,-11.14723018280196,-2.603287212947922,-1.4190851772460145,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0174165846830223,2.7504095936598643,4.626948766324235,8.205774413151186,-8.33897496799601,-21.604599967996013,-44.33432523955408,-46.72843851091236,-35.77497190588775,-24.693804671115103,-24.80526541181884,-18.30851918240324,-10.274337152257287,-4.6003551828019615,1.6978414423427328,3.938008141544108,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0,-2.9972101772460142,-3.0597101772460142,0.7628351772460145,1.3565851772460145,-13.059710177246016,-23.85658517724601,-28.84096017724601,-21.09096017724601,-12.512835177246016,-11.684710177246016,-9.512835177246016,-4.965960177246015,-0.9659601772460145]
model.weights.size692
(-1061247.2326738844,0.0)
(649719.7350374918,1.0)
(-1222679.3086386784,0.0)
(-774443.01874187,0.0)
(556558.937209885,1.0)
(556650.685503292,1.0)
(732650.9874731204,1.0)
(-1394923.8805013362,0.0)
(538053.9116693947,1.0)
(642089.8823006029,1.0)
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2016-05-24 22:33:32 WARN  ParquetRecordReader:193 - Can not initialize counter due to context is not a instance of TaskInputOutputContext, but is org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl
[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.13783517724601466,-3.1222101772460142,0.0,4.9867616869624065,6.35923081383617,6.891442730128846,0.8181771385458148,0.3097101772460146,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,2.2968796972768697,8.293579454514326,3.974527843646873,-0.0,2.9503351772460142,7.5963207932706975,1.4655543966303575,-7.185215899977705,-8.849258258788748,-15.81337989246107,-13.639119854604457,-1.223878500999535,22.155650349510783,3.009785720362156,-0.4972101772460146,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,2.189795773040486,7.865243757568792,7.112815171690069,5.222190171690069,-1.7251710764936685,-10.113870934882186,-2.4123051423415354,-15.872715899977702,-43.59586513856508,-53.73255178384851,-41.99461994201903,-13.73425447488869,-19.77514628341968,-0.5420999679960112,-8.355046004581647,-7.325335177246015,-1.4815851772460147,-0.5909601772460146,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,5.509397424368363,5.519065171690069,0.8761115279273785,-3.5847301828019615,-18.1463142081894,-18.464083910292164,-30.872715899977695,-40.388340899977706,-39.380226625436606,-37.39477038883295,-32.357032092175125,-22.021620399520277,-32.62861026031238,-25.85661738769483,-31.466711708300146,-13.345951510712547,-7.151306115537353,-3.1690851772460142,-1.5440851772460147,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.8456798388883541,-1.2311283291719626,-4.3034801828019615,-13.854021359716636,-23.02016980953982,-41.36190375400642,-46.026720676317055,-39.79501716400513,-11.99568801866026,-18.40642887044021,-23.238425956296172,-52.8174965144595,-37.745224967996016,-41.16709996799602,-40.99522496799602,-11.91709996799601,-3.8617131527223902,-3.7628351772460156,-3.1690851772460142,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0,-6.325335177246015,-11.230119162173036,-14.44410518280196,-23.275805445794713,-47.5004437573929,-54.7045252514618,-33.70724388557044,-9.505492767228736,20.605799562555795,11.18192672460626,-3.566860350871969,-24.413810502197677,-31.49522496799602,-49.29209996799601,-55.07334996799601,-38.432041757946806,-11.962471905887742,-6.372210177246015,-3.1690851772460142,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-2.2784601772460142,-10.684710177246016,-17.352415556064095,-28.933290758366216,-35.43393113886715,-35.95124194311829,-52.08778625161769,-17.2255255740857,17.110469472025596,29.819696700587187,33.7557743053465,25.760403053066906,11.201540435033953,-6.83897496799601,-50.182724967996,-78.56336730106291,-67.64012588096452,-41.91908517724602,-11.403460177246016,-3.2472101772460142,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-3.4190851772460147,-16.21596017724601,-26.89901541181884,-28.623920062594607,-38.45824878986433,-51.42044680695175,-49.90739321638901,-19.112471969054468,23.107999027391045,57.03102047124557,65.52139930534648,44.767070201207666,36.07924343219592,3.199104530194077,-41.60189933824799,-93.75616802910525,-75.87221017724602,-52.93471017724602,-20.55971017724601,-4.794085177246015,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-9.090960177246016,-24.002937634862736,-19.32299068982304,-23.359229291498195,-42.80800203788202,-43.71437411051801,-55.52466230698107,-21.69653730698106,42.76402176523723,86.03441331834891,93.68058133549245,66.9261222861558,48.49438296305026,6.949877469842939,-46.1475445601594,-81.74721017724602,-74.84096017724602,-61.55971017724602,-29.45033517724601,-8.747210177246016,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-15.499500880964519,-14.705092824402875,-9.057086538164059,-39.58621079569384,-64.56976594363476,-63.6543346642761,-44.374642545004335,-14.68517059065482,63.71206211184672,111.3151590547207,117.60069464531908,90.46894824066996,44.63257937717154,-7.695102770208612,-45.85658517724602,-77.87221017724602,-74.04408517724602,-67.80971017724602,-39.96596017724602,-14.278460177246016,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-9.214352683576724,-13.213974967996014,-43.391009460049176,-74.71307325021601,-83.57231160820618,-66.64764135493095,-42.05636561675474,-6.074053268481326,98.40515233789158,126.27717333754497,127.88577439768694,91.00299325676097,37.627675839019844,-26.28546893041137,-44.54408517724602,-74.71596017724602,-76.96596017724602,-68.13783517724602,-43.73158517724602,-19.01283517724601,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0,-7.5853178441790865,-39.703514054028496,-70.04199943654228,-85.52846017724602,-75.91908517724602,-50.85658517724602,-31.30971017724601,16.31209216693155,112.4411219995339,130.37720242272732,132.125150684832,74.82438253958523,27.628444761280544,-24.21596017724601,-49.74721017724602,-72.73158517724602,-72.63783517724602,-61.30971017724602,-45.34096017724602,-18.88783517724601,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0,-31.32533517724601,-62.32533517724602,-77.63783517724602,-91.51283517724602,-71.65346017724602,-42.85658517724602,-11.715960177246016,46.65895830338581,116.80283467149071,144.76456047208674,118.65825897049115,62.78424325676098,7.441273538202901,-21.099070995572816,-54.70033517724602,-73.01283517724602,-65.99721017724602,-55.01283517724602,-43.34096017724602,-16.02846017724601,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.09096017724601467,-38.65346017724602,-65.87221017724602,-86.85658517724602,-88.87221017724602,-63.419085177246025,-34.60658517724602,4.122210177246015,58.18278503563453,109.71545445451433,144.2286607436448,100.14041158777755,43.08039893615566,4.560225130957888,-27.389944425165787,-61.528231753209,-73.4126244803005,-67.96596017724602,-42.77846017724602,-36.98158517724602,-15.606585177246014,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-2.5440851772460142,-40.74721017724602,-66.41908517724602,-91.73158517724602,-86.49721017724602,-62.51283517724602,-23.05971017724601,24.54408517724601,58.96403503563453,107.53462160265508,122.97772279619048,87.04666158777755,36.21983142804218,-6.597927618058493,-39.85984110227982,-59.988048152656006,-70.94204253107537,-58.43471017724602,-38.48158517724602,-32.71596017724602,-11.731585177246016,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-2.4347101772460142,-36.73158517724602,-63.32533517724602,-93.57533517724602,-89.68471017724602,-63.481585177246025,-8.035150585098878,38.973932284704006,66.31841415300826,112.77441024744816,109.14343795448812,72.80353585097419,19.932530163028378,-29.371892960288886,-53.29046897485556,-62.41533101200168,-50.16908877950716,-40.40236157758448,-36.46596017724602,-24.95033517724601,-6.512835177246015,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.9815851772460145,-25.30971017724601,-58.59096017724602,-89.94424105419513,-99.48942116973163,-65.58056078555018,-7.113965839843261,34.23304765401862,62.07954557785629,100.00876233030206,100.10297517043257,54.89778403347672,0.06461626554617624,-38.62787588157201,-46.81812250370681,-43.860715837339974,-29.82020880202319,-36.872670347075605,-30.74721017724601,-16.79408517724601,-1.4347101772460147,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0,-13.903460177246016,-45.570203538884286,-69.73644458566298,-89.76526730142511,-65.10901730142511,-28.453317341885533,5.568740181614654,14.646972194139263,39.996437907737416,40.66836262450001,-0.490516441056583,-27.948411543358276,-36.94630060542174,-20.400038510225432,-40.19594045378262,-32.58977250415879,-26.934574320623398,-23.01283517724601,-5.262835177246015,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-3.9659601772460156,-5.080575261360139,-28.97259599328143,-60.35781973378538,-59.71921215348418,-43.821301373692165,-21.25124010616062,-28.57445976684736,-9.667605690727699,-10.495730690727699,-23.194411049315573,-36.120730690727704,-36.54063883570329,-35.30532720622055,-33.45973018280196,-24.365980182801955,-17.83766221294792,-9.278460177246016,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.5440851772460146,10.442811736995536,5.960871688209347,-14.926541714943955,-28.159724145339997,-34.06597329643792,-21.230105690727694,-30.370730690727697,-33.648727044158335,-29.635118099691752,-27.471032301595148,-37.544671768681575,-29.194581817640923,-23.615980182801955,-15.27223018280196,-11.14723018280196,-2.603287212947922,-1.4190851772460145,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0174165846830223,2.7504095936598643,4.626948766324235,8.205774413151186,-8.33897496799601,-21.604599967996013,-44.33432523955408,-46.72843851091236,-35.77497190588775,-24.693804671115103,-24.80526541181884,-18.30851918240324,-10.274337152257287,-4.6003551828019615,1.6978414423427328,3.938008141544108,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0,-2.9972101772460142,-3.0597101772460142,0.7628351772460145,1.3565851772460145,-13.059710177246016,-23.85658517724601,-28.84096017724601,-21.09096017724601,-12.512835177246016,-11.684710177246016,-9.512835177246016,-4.965960177246015,-0.9659601772460145]
end

相对于方法1,model。save和load很快出结果
Area under ROC = 1.0都为1,说明方法很好。AUC为1表示分类器很完美

参考
【1】http://spark.apache.org/docs/1.5.2/mllib-guide.html
【2】http://spark.apache.org/docs/1.5.2/programming-guide.html
【3】https://github.com/xubo245/SparkLearning

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值