3

I am trying to load the file titanic and I face the following problem. My code is:

from sklearn import datasets
titanic = datasets.load_titanic()

I get the following:

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

While I can load another file. Can anyone help?

bastelflp
  • 9,362
  • 7
  • 32
  • 67
mar
  • 43
  • 1
  • 3

2 Answers2

4

According to the documentation, there is no toy dataset load_titanic() for the current stable version (scikit-learn v0.19.1) - which version are you using? You get the version via sklearn.__version__.

From the docs, there are the following toy datasets available:

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

Maybe your tutorial is outdated?

bastelflp
  • 9,362
  • 7
  • 32
  • 67
1

sklearn v0.20.2 does not have load_titanic either. You can easily use:

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

But please take note that this is only a subset of the data. The total number of passengers of the Titanic is 2223 (or 2224), and the number of survivors is 706. Please see Wikipedia.

Sarah
  • 1,854
  • 17
  • 18