1 2 3 4 | sudo apt-get install python-software-properties sudo apt-add-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer |
1 2 | export SCALA_HOME=Path_Where_Scala_File_Is_Located export PATH=$SCALA_HOME/binATH |
1 | tar -xvf spark-2.1.0-bin-hadoop2.7.tgz |
1 2 | export SPARK_HOME=Path_Where_Spark_Is_Installed export PATH=$PATHSPARK_HOME/bin |
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | //Importing the necessary classes import org.apache.spark._ ... //Creating an Object earthquake object earthquake { def main(args: Array[String]) { //Creating a Spark Configuration and Spark Context val sparkConf = new SparkConf().setAppName("earthquake").setMaster("local[2]") val sc = new SparkContext(sparkConf) //Loading the Earthquake ROC Dataset file as a LibSVM file val data = MLUtils.loadLibSVMFile(sc, *Path to the Earthquake File* ) //Training the data for Machine Learning val splits = data.randomSplit( *Splitting 60% to 40%* , seed = 11L) val training = splits(0).cache() val test = splits(1) //Creating a model of the trained data val numIterations = 100 val model = *Creating SVM Model with SGD* ( *Training Data* , *Number of Iterations* ) //Using map transformation of model RDD val scoreAndLabels = *Map the model to predict features* //Using Binary Classification Metrics on scoreAndLabels val metrics = * Use Binary Classification Metrics on scoreAndLabels *(scoreAndLabels) val auROC = metrics. *Get the area under the ROC Curve*() //Displaying the area under Receiver Operating Characteristic println("Area under ROC = " + auROC) } } |
欢迎光临 168大数据 (http://www.bi168.cn/) | Powered by Discuz! X3.2 |