Skip to content

Commit ffbaf40

Browse files
committed
modified files for 2.0.x
1 parent 6098789 commit ffbaf40

File tree

6 files changed

+2510
-10
lines changed

6 files changed

+2510
-10
lines changed

Chapter_09/2.0.x/python/org/sparksamples/plot_singular_values.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
def main():
9-
file_name = '/home/ubuntu/work/ml-resources/spark-ml/Chapter_09/scala/s.csv'
9+
file_name = '/home/ubuntu/work/ml-resources/spark-ml/Chapter_09/data/s.csv'
1010
data = np.genfromtxt(file_name, delimiter=',')
1111

1212
plt.plot(data)

Chapter_09/2.0.x/python/org/sparksamples/ploy_gallery.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from PIL import Image, ImageFilter
66
import os
77

8-
PATH = "../../../data"
8+
PATH = "../../../../data"
99

1010

1111
def main():
@@ -15,11 +15,11 @@ def main():
1515
im = Image.open(path)
1616
im.show()
1717

18-
tmp_path = "/tmp/aeGray.jpg"
18+
tmp_path = PATH + "/aeGray.jpg"
1919
ae_gary = Image.open(tmp_path)
2020
ae_gary.show()
2121

22-
pc = np.loadtxt("/tmp/pc.csv", delimiter=",")
22+
pc = np.loadtxt(PATH + "/pc.csv", delimiter=",")
2323
print(pc.shape)
2424
# (2500, 10)
2525

Chapter_09/2.0.x/scala/src/main/scala/org/sparksamples/ImageProcessing.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,17 @@ import org.apache.spark.{SparkConf, SparkContext}
1010
* @author Rajdeep Dua
1111
*/
1212
object ImageProcessing {
13-
val PATH= "../data"
13+
val PATH= "../../data"
14+
1415
def main(args: Array[String]): Unit = {
1516
val spConfig = (new SparkConf).setMaster("local[1]").setAppName("SparkApp").
1617
set("spark.driver.allowMultipleContexts", "true")
1718
val sc = new SparkContext(spConfig)
1819
val path = PATH + "/lfw/*"
1920
val rdd = sc.wholeTextFiles(path)
2021
val first = rdd.first
21-
//println(first)
2222
val files = rdd.map { case (fileName, content) => fileName.replace("file:", "") }
23-
//println(files.first)
24-
// file:/PATH/lfw/Aaron_Eckhart/Aaron_Eckhart_0001.jpg
23+
2524
println(files.count)
2625

2726
val aePath = PATH + "/lfw/Aaron_Eckhart/Aaron_Eckhart_0001.jpg"
@@ -50,7 +49,7 @@ object ImageProcessing {
5049
val cols = pc.numCols
5150
val pcBreeze = new DenseMatrix(rows, cols, pc.toArray)
5251
println(rows, cols)
53-
//csvwrite(new File("/tmp/pc.csv"), pcBreeze)
52+
csvwrite(new File(PATH + "/pc.csv"), pcBreeze)
5453
val projected = matrix.multiply(pc)
5554
println(projected.numRows, projected.numCols)
5655
// (1055,10)
@@ -88,7 +87,7 @@ object ImageProcessing {
8887
val svd300 = matrix.computeSVD(300, computeU = false)
8988
val sMatrix = new DenseMatrix(1, 300, svd300.s.toArray)
9089
println(sMatrix)
91-
csvwrite(new File("/home/ubuntu/work/ml-resources/spark-ml/Chapter_09/scala/s.csv"), sMatrix)
90+
csvwrite(new File(PATH + "/s.csv"), sMatrix)
9291

9392
}
9493
def approxEqual(array1: Array[Double], array2: Array[Double], tolerance: Double = 1e-6): Boolean = {

Chapter_09/data/aeGray.jpg

1.75 KB
Loading

0 commit comments

Comments
 (0)