Skip to content

Commit 6bbdc86

Browse files
committed
Rebuild dev docs at master=0d26d54
1 parent de0940e commit 6bbdc86

File tree

227 files changed

+1246
-1255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

227 files changed

+1246
-1255
lines changed

dev/_downloads/plot_feature_transformation.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
from sklearn.linear_model import LogisticRegression
3535
from sklearn.ensemble import (RandomTreesEmbedding, RandomForestClassifier,
3636
GradientBoostingClassifier)
37-
from sklearn.feature_selection import SelectFromModel
3837
from sklearn.preprocessing import OneHotEncoder
3938
from sklearn.cross_validation import train_test_split
4039
from sklearn.metrics import roc_curve
40+
from sklearn.pipeline import make_pipeline
4141

4242
n_estimator = 10
4343
X, y = make_classification(n_samples=80000)
@@ -51,13 +51,13 @@
5151
test_size=0.5)
5252

5353
# Unsupervised transformation based on totally random trees
54-
rt = RandomTreesEmbedding(max_depth=3, n_estimators=n_estimator)
55-
rt_lm = LogisticRegression()
56-
rt.fit(X_train, y_train)
57-
rt_lm.fit(SelectFromModel(rt, prefit=True).transform(X_train_lr), y_train_lr)
54+
rt = RandomTreesEmbedding(max_depth=3, n_estimators=n_estimator,
55+
random_state=0)
5856

59-
y_pred_rt = rt_lm.predict_proba(
60-
SelectFromModel(rt, prefit=True).transform(X_test))[:, 1]
57+
rt_lm = LogisticRegression()
58+
pipeline = make_pipeline(rt, rt_lm)
59+
pipeline.fit(X_train, y_train)
60+
y_pred_rt = pipeline.predict_proba(X_test)[:, 1]
6161
fpr_rt_lm, tpr_rt_lm, _ = roc_curve(y_test, y_pred_rt)
6262

6363
# Supervised transformation based on random forests

dev/_downloads/plot_random_forest_embedding.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,14 @@
3030
from sklearn.datasets import make_circles
3131
from sklearn.ensemble import RandomTreesEmbedding, ExtraTreesClassifier
3232
from sklearn.decomposition import TruncatedSVD
33-
from sklearn.feature_selection import SelectFromModel
3433
from sklearn.naive_bayes import BernoulliNB
3534

3635
# make a synthetic dataset
3736
X, y = make_circles(factor=0.5, random_state=0, noise=0.05)
3837

3938
# use RandomTreesEmbedding to transform data
4039
hasher = RandomTreesEmbedding(n_estimators=10, random_state=0, max_depth=3)
41-
hasher.fit(X)
42-
model = SelectFromModel(hasher, prefit=True)
43-
X_transformed = model.transform(X)
40+
X_transformed = hasher.fit_transform(X)
4441

4542
# Visualize result using PCA
4643
pca = TruncatedSVD(n_components=2)
1.29 KB
Loading
1.29 KB
Loading
1.19 KB
Loading
-1.17 KB
Loading
45.5 KB
Loading
45.5 KB
Loading
122 KB
Loading

dev/_sources/auto_examples/ensemble/plot_feature_transformation.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ high-dimensional categorical embedding of the data.
4747
.. literalinclude:: plot_feature_transformation.py
4848
:lines: 23-
4949

50-
**Total running time of the example:** 4.56 seconds
51-
( 0 minutes 4.56 seconds)
50+
**Total running time of the example:** 4.87 seconds
51+
( 0 minutes 4.87 seconds)
5252

0 commit comments

Comments
 (0)