【问题标题】:AttributeError: module 'sklearn.datasets' has no attribute 'load_titanic'AttributeError:模块“sklearn.datasets”没有属性“load_titanic”
【发布时间】:2018-04-24 20:35:47
【问题描述】:

我正在尝试加载文件 Titanic,但遇到以下问题。我的代码是:

from sklearn import datasets
titanic = datasets.load_titanic()

我得到以下信息:

AttributeError: module 'sklearn.datasets' has no attribute 'load_titanic'

虽然我可以加载另一个文件。任何人都可以帮忙吗?

【问题讨论】:

    标签: python-3.x python-3.6 attributeerror sklearn-pandas


    【解决方案1】:

    According to the documentation,当前稳定版本(scikit-learn v0.19.1)没有玩具数据集load_titanic() - 你使用的是哪个版本?您可以通过sklearn.__version__ 获取版本。

    在文档中,有以下可用的玩具数据集:

    load_boston()
    load_iris()
    load_diabetes(
    load_digits()
    load_linnerud()
    load_wine()
    load_breast_cancer()
    

    也许你的教程已经过时了?

    【讨论】:

      【解决方案2】:

      sklearn v0.20.2 也没有load_titanic。您可以轻松使用:

      import seaborn as sns
      titanic=sns.load_dataset('titanic')
      

      但请注意,这只是数据的一个子集。泰坦尼克号的乘客总数为2223人(或2224人),幸存者人数为706人。请看Wikipedia

      【讨论】:

        猜你喜欢
        • 2018-04-14
        • 2019-02-18
        • 1970-01-01
        • 2020-01-01
        • 2019-07-20
        • 2021-11-05
        • 2021-11-04
        • 2021-02-23
        相关资源
        最近更新 更多