Spark文档示例中的SVMWithSGD不起作用

时间:2014-10-17 09:49:35

标签: apache-spark apache-spark-mllib

我正在使用PySpark运行Spark 1.1.0。

当我直接从文档中运行示例时:

from pyspark.mllib.regression import LabeledPoint
from pyspark.mllib.classification import SVMWithSGD
import array

data = [
    LabeledPoint(0.0, [0.0]),
    LabeledPoint(1.0, [1.0]),
    LabeledPoint(1.0, [2.0]),
    LabeledPoint(1.0, [3.0])
]

svm = SVMWithSGD.train(sc.parallelize(data))
svm.predict(array([1.0])) > 0

我收到错误:

TypeError                                 Traceback (most recent call last)
<ipython-input-5-68bcda022b28> in <module>()
     12 
     13 svm = SVMWithSGD.train(sc.parallelize(data))
---> 14 svm.predict(array([1.0])) > 0

TypeError: 'module' object is not callable

可能是什么问题?

1 个答案:

答案 0 :(得分:0)

我正在导入错误的数组包

import array

而不是

from numpy import array
相关问题