Skip to content
Snippets Groups Projects
Commit 565c9387 authored by Olivier Grisel's avatar Olivier Grisel
Browse files

Merge branch 'sc' of https://github.com/vene/scikit-learn into vene-sc

parents e93612aa d56281e0
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,7 @@ print __doc__ ...@@ -17,6 +17,7 @@ print __doc__
import logging import logging
from time import time from time import time
from numpy.random import RandomState
import pylab as pl import pylab as pl
from sklearn.datasets import fetch_olivetti_faces from sklearn.datasets import fetch_olivetti_faces
...@@ -29,10 +30,11 @@ logging.basicConfig(level=logging.INFO, ...@@ -29,10 +30,11 @@ logging.basicConfig(level=logging.INFO,
n_row, n_col = 2, 3 n_row, n_col = 2, 3
n_components = n_row * n_col n_components = n_row * n_col
image_shape = (64, 64) image_shape = (64, 64)
rng = RandomState(0)
############################################################################### ###############################################################################
# Load faces data # Load faces data
dataset = fetch_olivetti_faces(shuffle=True) dataset = fetch_olivetti_faces(shuffle=True, random_state=rng)
faces = dataset.data faces = dataset.data
n_samples, n_features = faces.shape n_samples, n_features = faces.shape
...@@ -79,16 +81,19 @@ estimators = [ ...@@ -79,16 +81,19 @@ estimators = [
('Sparse comp. - MiniBatchSparsePCA', ('Sparse comp. - MiniBatchSparsePCA',
decomposition.MiniBatchSparsePCA(n_components=n_components, alpha=1e-3, decomposition.MiniBatchSparsePCA(n_components=n_components, alpha=1e-3,
n_iter=100, chunk_size=3), n_iter=100, chunk_size=3,
random_state=rng),
True, False), True, False),
('MiniBatchDictionaryLearning', ('MiniBatchDictionaryLearning',
decomposition.MiniBatchDictionaryLearning(n_atoms=n_components, alpha=5e-3, decomposition.MiniBatchDictionaryLearning(n_atoms=15, alpha=5e-3,
n_iter=100, chunk_size=3), n_iter=50, chunk_size=3,
random_state=rng),
True, False), True, False),
('Cluster centers - MiniBatchKMeans', ('Cluster centers - MiniBatchKMeans',
MiniBatchKMeans(k=n_components, tol=1e-3, chunk_size=20, max_iter=50), MiniBatchKMeans(k=n_components, tol=1e-3, chunk_size=20, max_iter=50,
random_state=rng),
True, False) True, False)
] ]
...@@ -117,6 +122,7 @@ for name, estimator, center, transpose in estimators: ...@@ -117,6 +122,7 @@ for name, estimator, center, transpose in estimators:
components_ = estimator.components_ components_ = estimator.components_
if transpose: if transpose:
components_ = components_.T components_ = components_.T
plot_gallery('%s - Train time %.1fs' % (name, train_time), components_) plot_gallery('%s - Train time %.1fs' % (name, train_time),
components_[:n_components])
pl.show() pl.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment