Skip to content

Commit c2b0de5

Browse files
jaroslaw-weberagramfort
authored andcommitted
[MRG+1] added DESCR attribute in diabetes data (scikit-learn#8840)
* added DESCR attribute in diabetes data * added DESCR attribute in diabetes data (fix flake8) * added DESCR attribute in diabetes data (added test)
1 parent 1652a70 commit c2b0de5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

sklearn/datasets/base.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,14 +568,19 @@ def load_diabetes(return_X_y=False):
568568
569569
.. versionadded:: 0.18
570570
"""
571-
base_dir = join(dirname(__file__), 'data')
571+
572+
module_path = dirname(__file__)
573+
base_dir = join(module_path, 'data')
572574
data = np.loadtxt(join(base_dir, 'diabetes_data.csv.gz'))
573575
target = np.loadtxt(join(base_dir, 'diabetes_target.csv.gz'))
574576

577+
with open(join(module_path, 'descr', 'diabetes.rst')) as rst_file:
578+
fdescr = rst_file.read()
579+
575580
if return_X_y:
576581
return data, target
577582

578-
return Bunch(data=data, target=target,
583+
return Bunch(data=data, target=target, DESCR=fdescr,
579584
feature_names=['age', 'sex', 'bmi', 'bp',
580585
's1', 's2', 's3', 's4', 's5', 's6'])
581586

sklearn/datasets/tests/test_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def test_load_diabetes():
173173
assert_equal(res.data.shape, (442, 10))
174174
assert_true(res.target.size, 442)
175175
assert_equal(len(res.feature_names), 10)
176+
assert_true(res.DESCR)
176177

177178
# test return_X_y option
178179
X_y_tuple = load_diabetes(return_X_y=True)

0 commit comments

Comments
 (0)