2017-06-20 176 views
0
import operator 
import pandas as pd 
import numpy as np 
import matplotlib.pyplot as plt 
import xgboost as xgb 
import seaborn as sns 
%matplotlib inline 

pd.set_option('display.max_columns', 50) 

导入上述文件后,我得到了一个模块未找到错误,因为我没有安装xboost,因为我是python和数据分析的新手。弃用警告

然后我直接从here安装它。

现在安装xgboost我得到了一条反对预警相同的代码上面的线是如下之后:

C:\ProgramData\Anaconda3\lib\site-packages\sklearn\cross_validation.py:44: 
DeprecationWarning: This module was deprecated in version 0.18 in favor 
of the model_selection module into which all the refactored classes and 
functions are moved. 
Also note that the interface of the new CV iterators are different from 
that of this module. This module will be removed in 0.20. 
    "This module will be removed in 0.20.", DeprecationWarning) 

请告诉我为什么,该警报显示出来,如何解决这个问题?

+0

这意味着,在产品的代码更高版本使用的是将不再工作。阅读'model_selection'模块的文档,并将代码放入其中,以便用户可以在更高版本中使用您的代码。 – rassar

+1

Sklearn将会停止交叉验证。他们把在cross_validation下的类放到model_selection中。我认为XGBoost也已更新,因为它们使用'try' /'except'来导入'KFold','StratifiedKFold'(例如[https://github.com/dmlc/xgboost/blob/6f16f0ef5829965ba420ef6937617600d286820a/python-包/ xgboost/compat.py#L51))。 – Jarad

回答

0

使用

from sklearn.model_selection import cross_val_score 

相反

from sklearn.cross_validation import cross_val_score 
+0

在OP的问题中没有这样的代码行,所以你甚至在回答什么? – Ajean

+0

@Ajean我只是有同样的错误:DeprecationWarning:该模块在版本0.18中被弃用,赞成 的model_selection模块,所有重构类和 函数被移入其中。 ......所以可能他会在其他文件或第44行导入cross_validation(这就是弃用警告所说的)。 –

+0

这只是一个猜测。不要写一个答案,你应该询问OP的评论。你现在还不能这样做,但你应该等到可以的时候,否则你的回答很可能是错的,因此会吸引低价。 – Ajean