简体   繁体   English

PySpark LogisticRegressionWithLBFGS导入错误

[英]PySpark LogisticRegressionWithLBFGS Import error

I am trying to use the pysoark LogisticRegression library.Below is part of my code: 我正在尝试使用pysoark LogisticRegression库.Below是我的代码的一部分:

    from pyspark.mllib.linalg import Vectors
    from pyspark.mllib.regression import LabeledPoint
    from pyspark.mllib.classification import LogisticRegressionWithLBFGS, LogisticRegressionModel,   LogisticRegressionWithSGD
    from pyspark import SparkContext

I am getting the error: 我收到错误:

    Traceback (most recent call last):
    File "LogisticRegression.py", line 3, in <module> 
    from pyspark.mllib.classification import    LogisticRegressionWithLBFGS, LogisticRegressionModel, LogisticRegressionWithSGD
    ImportError: cannot import name LogisticRegressionWithLBFGS

Is there a circular import dependency here?I am using Python 2.7.9 这里有循环导入依赖吗?我使用的是Python 2.7.9

I'd say your version of pyspark is outdated. 我说你的pyspark版本已经过时了。

Try : 试试:

pip freeze | grep pyspark

LogisticRegressionWithLBFGS class was introduced in pyspark 1.2.0. LogisticRegressionWithLBFGS类在pyspark 1.2.0中引入。

To upgrade your version of pyspark you can use pip as well : 要升级您的pyspark版本,您也可以使用pip

pip install pyspark --upgrade

Edit : 编辑:

@ShuaiYuan comment's seems right and you can't use pip for pyspark. @ShuaiYuan评论似乎是正确的,你不能使用pip为pyspark。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM