Skip to content

Use of target_names in example datasets is inconsistent #13962

@mitar

Description

@mitar

Description

It seems target_names sometimes correspond to values of categorical target and sometimes correspond to target colum name itself.

Steps/Code to Reproduce

from sklearn.datasets import load_linnerud
from sklearn.datasets import load_iris

print(load_linnerud()['target_names'])
print(load_iris()['target_names'])

Expected Results

I would expect consistency. Or that target_names target column names (even in the case of one column), or that it returns categorical target values (and then it should not exist for regression).

Actual Results

['Weight', 'Waist', 'Pulse']
array(['setosa', 'versicolor', 'virginica'], dtype='<U10')

Also note that once it is a list and once it is an array.

Versions

System:
    python: 3.6.7 (default, Oct 22 2018, 11:32:17)  [GCC 8.2.0]
executable: /usr/bin/python3
   machine: Linux-4.18.0-20-generic-x86_64-with-Ubuntu-18.04-bionic

BLAS:
    macros: HAVE_CBLAS=None
  lib_dirs: /usr/lib/x86_64-linux-gnu
cblas_libs: openblas, openblas

Python deps:
       pip: 19.0.3
setuptools: 41.0.1
   sklearn: 0.20.3
     numpy: 1.15.4
     scipy: 1.2.1
    Cython: None
    pandas: 0.23.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions