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
| package com.company; | |
| import java.util.*; | |
| import java.util.stream.Collectors; | |
| public class Main { | |
| public static void main(String[] args) { | |
| int[] arr = {1, 2, 3, 4, 5}; | |
| int[] arr2 = {-5, 0, 10, -5, 0, 5, 5}; |
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
| CDR | 20150811 | 27.51 | 27.95 | 27.51 | 27.55 | 204668 | 0 |
|---|
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 meanSquaredError = scoreAndLabels.map { case(l, s) => math.pow((l - s), 2) }.mean |
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 scoreAndLabels = testData.map { point => | |
| val score = model.predict(point.features) | |
| (point.label, score) | |
| } |
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 model = RidgeRegressionWithSGD.train(trainingData, numIterations, stepSize, regularizationParam) |
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 numIterations = 1000 | |
| val stepSize = 0.005 | |
| val regularizationParam = 0.01 |
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)) |
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 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 growths = prices.drop(1).zip(prices.dropRight(1)).map { | |
| case (current, previous) => 100.0 * (current - previous) / previous | |
| } |
NewerOlder