Python TypeError:uuu init_uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu;洗牌';

Python TypeError:uuu init_uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu;洗牌';,python,nltk,Python,Nltk,我在Python2.6.6中运行代码时遇到了这个错误。在Python3.4.3中运行时没有问题 usr/lib64/python2.6/site-packages/sklearn/feature_selection/univariate_selection.py:319: UserWarning: Duplicate scores. Result may depend on feature ordering.There are probably duplicate features, or yo

我在Python2.6.6中运行代码时遇到了这个错误。在Python3.4.3中运行时没有问题

usr/lib64/python2.6/site-packages/sklearn/feature_selection/univariate_selection.py:319: UserWarning: Duplicate scores. Result may depend on feature ordering.There are probably duplicate features, or you used a classification score for a regression task.
      warn("Duplicate scores. Result may depend on feature ordering."
    Traceback (most recent call last):
      File "classification.py", line 31, in <module>
        main()
      File "classification.py", line 15, in main
        tm.optimaltrain(conf)
      File "/axp/gabm/npscnnct/dev/getThemes/textminer/textminer/classify.py", line 121, in optimaltrain
        score = self.cv(X,y,model)
      File "/axp/gabm/npscnnct/dev/getThemes/textminer/textminer/classify.py", line 140, in cv
        skf = cross_validation.StratifiedKFold(y, n_folds=self.cv_folds, shuffle=True)
    TypeError: __init__() got an unexpected keyword argument 'shuffle'
但是当我从代码中删除
Shuffle=True
时,它运行良好。我使用的模块是scipy 0.11.0、nltk 2.0.1、sklearn 0.14.1

请给我一些建议。
谢谢

这是您的
sklearn
版本(
0.14
)的源代码:

我已经链接到了
StratifiedKFold
上的init的实际行,这表明没有
shuffle
关键字参数

升级到v
0.15
,它确实有
shuffle
(如下所示:)


我将假设您在
Py3
上的
sklearn
版本是
0.15

在sklearn 0.14中,
交叉验证.StratifiedKFold()
没有关键字参数
随机播放
。显然,它只是在更高版本中添加的(实际上是0.15)


在分层之前,您可以更新sklearn,也可以自己洗牌输入(例如使用
random.shuffle()
)。

确保您将答案标记为正确,以便将来查看该答案的人知道有什么帮助@Scironic感谢您的解释和帮助
  def cv(self, X, y, model):
    y_true = []
    y_pred = []
    skf = cross_validation.StratifiedKFold(y, n_folds=self.cv_folds, shuffle=True)
    for train_index, test_index in skf:
      X_train, X_test = X[train_index], X[test_index]
      y_train, y_test = y[train_index], y[test_index]
      model.fit(X_train, y_train)
      y_pred += list(model.predict(X_test))
      y_true += list(y_test)