New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG+1] Take over PR #7647 - Add a "filename" attribute to datasets that have a CSV file #9101

Merged
merged 23 commits into from Dec 4, 2017
Commits
Jump to file or symbol
Failed to load files and symbols.
+25 −10
Diff settings

Always

Just for now

Viewing a subset of changes. View all

add filename attribute for load_linnerud

  • Loading branch information...
alex-33 authored and maskani-moh committed Oct 12, 2016
commit 04431701404e9b3de40904b17817dc00e1989900
Copy path View file
@@ -568,8 +568,10 @@ def load_diabetes(return_X_y=False):
-------
data : Bunch
Dictionary-like object, the interesting attributes are:
'data', the data to learn and 'target', the regression target for each
sample.
'data', the data to learn, 'target', the regression target for each
sample, 'data_filename', the physical location of
diabetes data csv dataset, and 'target_filename', the physical location
of diabetes targets csv datataset.
(data, target) : tuple if ``return_X_y`` is True
@@ -588,7 +590,9 @@ def load_diabetes(return_X_y=False):
return Bunch(data=data, target=target, DESCR=fdescr,
feature_names=['age', 'sex', 'bmi', 'bp',
's1', 's2', 's3', 's4', 's5', 's6'])
's1', 's2', 's3', 's4', 's5', 's6'],
data_filename=data_filename,
target_filename=target_filename)
def load_linnerud(return_X_y=False):
@@ -615,22 +619,29 @@ def load_linnerud(return_X_y=False):
Dictionary-like object, the interesting attributes are: 'data' and
'targets', the two multivariate datasets, with 'data' corresponding to
the exercise and 'targets' corresponding to the physiological
measurements, as well as 'feature_names' and 'target_names'.
measurements, as well as 'feature_names' and 'target_names'. In addition,
you will also have access to 'data_filename', the physical location of
linnerud data csv dataset, and 'target_filename', the physical location
of linnerud targets csv datataset.
(data, target) : tuple if ``return_X_y`` is True
.. versionadded:: 0.18
"""
base_dir = join(dirname(__file__), 'data/')
data_filename = join(base_dir, 'linnerud_exercise.csv')
target_filename = join(base_dir, 'linnerud_physiological.csv')
# Read data
data_exercise = np.loadtxt(base_dir + 'linnerud_exercise.csv', skiprows=1)
data_physiological = np.loadtxt(base_dir + 'linnerud_physiological.csv',
skiprows=1)
data_exercise = np.loadtxt(data_filename, skiprows=1)
data_physiological = np.loadtxt(target_filename, skiprows=1)
# Read header
with open(base_dir + 'linnerud_exercise.csv') as f:
with open(data_filename) as f:
header_exercise = f.readline().split()
with open(base_dir + 'linnerud_physiological.csv') as f:
with open(target_filename) as f:
header_physiological = f.readline().split()
with open(dirname(__file__) + '/descr/linnerud.rst') as f:
descr = f.read()
@@ -640,7 +651,9 @@ def load_linnerud(return_X_y=False):
return Bunch(data=data_exercise, feature_names=header_exercise,
target=data_physiological,
target_names=header_physiological,
DESCR=descr)
DESCR=descr,
data_filename=data_filename,
target_filename=target_filename)
def load_boston(return_X_y=False):
@@ -189,6 +189,8 @@ def test_load_linnerud():
assert_equal(res.target.shape, (20, 3))
assert_equal(len(res.target_names), 3)
assert_true(res.DESCR)
assert_true(res.data_filename)
assert_true(res.target_filename)
# test return_X_y option
X_y_tuple = load_linnerud(return_X_y=True)
ProTip! Use n and p to navigate between commits in a pull request.