From 98a94907c100f0432e53c49f8bd1ea78587487a8 Mon Sep 17 00:00:00 2001 From: manu-chroma Date: Fri, 5 Aug 2016 17:11:05 +0530 Subject: [PATCH 1/5] added return_X_y option to breast_cancer_dataset, tests included --- sklearn/datasets/base.py | 17 ++++++++++++++++- sklearn/datasets/tests/test_base.py | 7 +++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/sklearn/datasets/base.py b/sklearn/datasets/base.py index a70938905ba93..43040256c291b 100644 --- a/sklearn/datasets/base.py +++ b/sklearn/datasets/base.py @@ -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 @@ -332,6 +332,14 @@ def load_breast_cancer(): Features real, positive ================= ============== + Parameters + ---------- + return_X_y : boolean, deafult=True + 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 @@ -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 @@ -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, diff --git a/sklearn/datasets/tests/test_base.py b/sklearn/datasets/tests/test_base.py index 8253221d20e6e..6be9b399e122e 100644 --- a/sklearn/datasets/tests/test_base.py +++ b/sklearn/datasets/tests/test_base.py @@ -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() From ad52ef10dfa61efd7bdbfaa2fb697cf384939954 Mon Sep 17 00:00:00 2001 From: manu-chroma Date: Sat, 6 Aug 2016 01:46:34 +0530 Subject: [PATCH 2/5] fix typo --- sklearn/datasets/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/datasets/base.py b/sklearn/datasets/base.py index 43040256c291b..3d6107268b132 100644 --- a/sklearn/datasets/base.py +++ b/sklearn/datasets/base.py @@ -334,7 +334,7 @@ def load_breast_cancer(return_X_y=False): Parameters ---------- - return_X_y : boolean, deafult=True + 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. From 08123ae5823ce00a6d216a28402c9aa663e770e2 Mon Sep 17 00:00:00 2001 From: manu-chroma Date: Sat, 6 Aug 2016 01:47:57 +0530 Subject: [PATCH 3/5] update whats_new --- doc/whats_new.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/whats_new.rst b/doc/whats_new.rst index a2453ad7988a9..b76fc970cc4ac 100644 --- a/doc/whats_new.rst +++ b/doc/whats_new.rst @@ -231,7 +231,7 @@ Enhancements By `Sebastian Säger`_ and `YenChen Lin`_. - Added new return type ``(data, target)`` : tuple option to - :func:`load_iris` dataset. + :func:`load_iris` dataset, :func: `load_breast_cancer` dataset (`#7049 `_) by `Manvendra Singh`_. From 822a2cc1343f8a8921ca41066b0974c38eb233b4 Mon Sep 17 00:00:00 2001 From: manu-chroma Date: Sat, 6 Aug 2016 01:58:25 +0530 Subject: [PATCH 4/5] removed extra space --- doc/whats_new.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/whats_new.rst b/doc/whats_new.rst index b76fc970cc4ac..982adba2b893a 100644 --- a/doc/whats_new.rst +++ b/doc/whats_new.rst @@ -231,7 +231,7 @@ Enhancements By `Sebastian Säger`_ and `YenChen Lin`_. - Added new return type ``(data, target)`` : tuple option to - :func:`load_iris` dataset, :func: `load_breast_cancer` dataset + :func:`load_iris` dataset, :func:`load_breast_cancer` dataset (`#7049 `_) by `Manvendra Singh`_. From 1d11afc3eb629dbc7748d06354f5aa2ccbd62baa Mon Sep 17 00:00:00 2001 From: manu-chroma Date: Sat, 6 Aug 2016 02:10:11 +0530 Subject: [PATCH 5/5] improved whats_new changelog --- doc/whats_new.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/whats_new.rst b/doc/whats_new.rst index 982adba2b893a..12054f40e8faa 100644 --- a/doc/whats_new.rst +++ b/doc/whats_new.rst @@ -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, :func:`load_breast_cancer` dataset - (`#7049 `_) by + :func:`load_iris` dataset, + (`#7049 `_) + :func:`load_breast_cancer` dataset + (`#7152 `_) by `Manvendra Singh`_. Bug fixes