1. 程式人生 > >python報警告--DeprecationWarning

python報警告--DeprecationWarning

#使用sklearn.cross_validation裡的train_test_split模組用於分割資料

使用上述匯入時,出現DeprecationWarning警告的型別錯誤:

該型別的警告大多屬於版本更新時,所使用的方法過時的原因,可以在該方法的說明處查詢替換的方法

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.18版本中被棄用,支援所有重構的類和函式都被移動到的model_selection模組。 另請注意,新的CV迭代器的介面與本模組的介面不同。 此模組將在0.20中刪除。

解決方法:將“from sklearn.cross_validation import train_test_split”改為“from sklearn.model_selection import train_test_split”