This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.mllib.regression.{ RidgeRegressionWithSGD, LabeledPoint } | |
import org.apache.spark.{ SparkConf, SparkContext } | |
import org.apache.spark.mllib.linalg.Vectors | |
import scala.io.Source | |
object Main extends App { | |
val sparkConfig = new SparkConf().setAppName("quotes").setMaster("local") | |
val sparkContext = new SparkContext(sparkConfig) | |
val quotesFileLines = Source.fromFile("...your...path...").getLines.toList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.mllib.regression.{ RidgeRegressionWithSGD, LabeledPoint } | |
import org.apache.spark.{ SparkConf, SparkContext } | |
import org.apache.spark.mllib.linalg.Vectors | |
import scala.io.Source | |
object Main extends App { | |
val sparkConfig = new SparkConf().setAppName("quotes").setMaster("local") | |
val sparkContext = new SparkContext(sparkConfig) | |
val quotesFileLines = Source.fromFile("...your...path...").getLines.toList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.mllib.regression.{ RidgeRegressionWithSGD, LabeledPoint } | |
import org.apache.spark.{ SparkConf, SparkContext } | |
import org.apache.spark.mllib.linalg.Vectors | |
import scala.io.Source |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val sparkConfig = new SparkConf().setAppName("quotes").setMaster("local") | |
val sparkContext = new SparkContext(sparkConfig) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val quotesFileLines = Source.fromFile("...your...path...").getLines.toList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val prices = quotesFileLines.map { _.split(",").toList(5).toDouble } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val growths = prices.drop(1).zip(prices.dropRight(1)).map { | |
case (current, previous) => 100.0 * (current - previous) / previous | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val probesNumber = 20 | |
val labeledPoints = for(i <- probesNumber until growths.size) yield { | |
LabeledPoint(growths(i), Vectors.dense(growths.slice(i - probesNumber, i).toArray)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val labeledPointsRDD = sparkContext.parallelize(labeledPoints) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val Array(trainingData, testData) = labeledPointsRDD.randomSplit(Array(0.7, 0.3)) |
OlderNewer