Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,10 @@ Enhancements
By `Sebastian Säger`_ and `YenChen Lin`_.

- Added new return type ``(data, target)`` : tuple option to
:func:`load_iris` dataset.
(`#7049 <https://github.com/scikit-learn/scikit-learn/pull/7049>`_) by
:func:`load_iris` dataset,
(`#7049 <https://github.com/scikit-learn/scikit-learn/pull/7049>`_)
:func:`load_breast_cancer` dataset
(`#7152 <https://github.com/scikit-learn/scikit-learn/pull/7152>`_) by
`Manvendra Singh`_.

Bug fixes
Expand Down
17 changes: 16 additions & 1 deletion sklearn/datasets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def load_iris(return_X_y=False):
'petal length (cm)', 'petal width (cm)'])


def load_breast_cancer():
def load_breast_cancer(return_X_y=False):
"""Load and return the breast cancer wisconsin dataset (classification).

The breast cancer dataset is a classic and very easy binary classification
Expand All @@ -332,6 +332,14 @@ def load_breast_cancer():
Features real, positive
================= ==============

Parameters
----------
return_X_y : boolean, default=False
If True, returns ``(data, target)`` instead of a Bunch object.
See below for more information about the `data` and `target` object.

.. versionadded:: 0.18

Returns
-------
data : Bunch
Expand All @@ -341,6 +349,10 @@ def load_breast_cancer():
meaning of the features, and 'DESCR', the
full description of the dataset.

(data, target) : tuple if ``return_X_y`` is True

.. versionadded:: 0.18

The copy of UCI ML Breast Cancer Wisconsin (Diagnostic) dataset is
downloaded from:
https://goo.gl/U2Uwz2
Expand Down Expand Up @@ -390,6 +402,9 @@ def load_breast_cancer():
'worst concavity', 'worst concave points',
'worst symmetry', 'worst fractal dimension'])

if return_X_y:
return data, target

return Bunch(data=data, target=target,
target_names=target_names,
DESCR=fdescr,
Expand Down
7 changes: 7 additions & 0 deletions sklearn/datasets/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ def test_load_breast_cancer():
assert_equal(res.target_names.size, 2)
assert_true(res.DESCR)

# test return_X_y option
X_y_tuple = load_breast_cancer(return_X_y=True)
bunch = load_breast_cancer()
assert_true(isinstance(X_y_tuple, tuple))
assert_array_equal(X_y_tuple[0], bunch.data)
assert_array_equal(X_y_tuple[1], bunch.target)


def test_load_boston():
res = load_boston()
Expand Down