From ba164c8a2423b80b88dcc10c905a5f85918bb836 Mon Sep 17 00:00:00 2001 From: Hanmin Qin Date: Sun, 19 Aug 2018 22:18:38 +0800 Subject: [PATCH] EXA Use fetch_openml(returnX_y=True) --- .../linear_model/plot_sparse_logistic_regression_mnist.py | 4 +--- examples/multioutput/plot_classifier_chain_yeast.py | 5 ++--- examples/neural_networks/plot_mnist_filters.py | 4 +--- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/examples/linear_model/plot_sparse_logistic_regression_mnist.py b/examples/linear_model/plot_sparse_logistic_regression_mnist.py index 7f5a328c08f0d..523f5683a5a1b 100644 --- a/examples/linear_model/plot_sparse_logistic_regression_mnist.py +++ b/examples/linear_model/plot_sparse_logistic_regression_mnist.py @@ -36,9 +36,7 @@ train_samples = 5000 # Load data from https://www.openml.org/d/554 -mnist = fetch_openml('mnist_784', version=1) -X = mnist.data -y = mnist.target +X, y = fetch_openml('mnist_784', version=1, return_X_y=True) random_state = check_random_state(0) permutation = random_state.permutation(X.shape[0]) diff --git a/examples/multioutput/plot_classifier_chain_yeast.py b/examples/multioutput/plot_classifier_chain_yeast.py index ea62eda756de3..cb3a5085e316d 100644 --- a/examples/multioutput/plot_classifier_chain_yeast.py +++ b/examples/multioutput/plot_classifier_chain_yeast.py @@ -47,9 +47,8 @@ print(__doc__) # Load a multi-label dataset from https://www.openml.org/d/40597 -yeast = fetch_openml('yeast', version=4) -X = yeast.data -Y = yeast.target == 'TRUE' +X, Y = fetch_openml('yeast', version=4, return_X_y=True) +Y = Y == 'TRUE' X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=.2, random_state=0) diff --git a/examples/neural_networks/plot_mnist_filters.py b/examples/neural_networks/plot_mnist_filters.py index bd8a9e96027a3..ab50d4e59a813 100644 --- a/examples/neural_networks/plot_mnist_filters.py +++ b/examples/neural_networks/plot_mnist_filters.py @@ -27,9 +27,7 @@ print(__doc__) # Load data from https://www.openml.org/d/554 -mnist = fetch_openml('mnist_784', version=1) -X = mnist.data -y = mnist.target +X, y = fetch_openml('mnist_784', version=1, return_X_y=True) # rescale the data, use the traditional train/test split X_train, X_test = X[:60000], X[60000:]