Thanks Ahyoung!
Problem solved.
Here are my codes
// para #1
val temp =
norm_featured_2f.select("norm_2f_features").rdd.map(r=>r(0).asInstanceOf[DenseVector].toArray).collect()
z.put("norm_featured_2f",temp)
// para #2
%pyspark
import matplotlib as matplt
matplt.use('Agg')
import matplotlib.pyplot as plt; plt.rcdefaults()
import StringIO
def show(p)
img = StringIO.StringIO()
p.savefig(img, format='svg')
img.seek(0)
print "%html <div style='width:700px'>" +img.buf + "</div>"
data = z.get('norm_featured_2f')
x=[]
y=[]
print ("SAMPLE")
for i in range(0,9):
x.append(data[i][0])
y.append(data[i][1])
plt.clf()
plt.suptitle('title', fontsize=30, fontweight='bold')
plt.plot(x,y,'bo')
plt.grid(True)
show(plt)
> On Feb 12, 2016, at 1:30 AM, Ahyoung Ryu <[email protected]> wrote:
>
> Hi 상형,
>
> If you need some sample codes about plotting with Pyspark, please see this
> notebook( by @felixcheung ).
>
> https://www.zeppelinhub.com/viewer/notebooks/aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2ZlbGl4Y2hldW5nL3NwYXJrLW5vdGVib29rLWV4YW1wbGVzL21hc3Rlci9aZXBwZWxpbl9ub3RlYm9vay8yQU1YNUNWQ1Uvbm90ZS5qc29u
>
> <https://www.zeppelinhub.com/viewer/notebooks/aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2ZlbGl4Y2hldW5nL3NwYXJrLW5vdGVib29rLWV4YW1wbGVzL21hc3Rlci9aZXBwZWxpbl9ub3RlYm9vay8yQU1YNUNWQ1Uvbm90ZS5qc29u>
>
> Hope this help! : )
> Ahyoung
>
>
> 2016년 2월 11일 (목) 오후 10:29, 진상형 <[email protected]
> <mailto:[email protected]>>님이 작성:
> Hi, I'm getting trouble to plotting in pyspark
>
> There is a dataframe (col:"features", col:"predictions") which is result from
> kmeans.
>
> And my goal is to plot the feature_vector(x,y) and predictions of
> kmeans_model.
>
> HERE ARE CODES AND RESULTS
>
>
> z.put("result", model.transform(norm_featured_2f))
>
> //res~: Object = [norm_2f_features: vector]
>
>
> %pyspark
> import matplotlib
> matplotlib.use('Agg')
> import matplotlib.pyplot as plt; plt.rcdefaults()
> import numpy as np
> import StringIO
>
> def show(p):
> img = StringIO.StringIO()
> p.savefig(img, format='svg')
> img.seek(0)
> print "%html <div style='width:600px'>" + img.buf + "</div>"
>
> data = z["result"]
> x = []
> y = []
> for i in data[0]:
> x.append(i._1())
> y.append(i._2())
>
> //TypeError: 'JavaObject' object is not callable
>
>
> Anyone help
>
> Is there any sample codes, or notebook about this?
>
>