Skip to content

Commit 07f401a

Browse files
committed
Rewrite examples/plot_forest_importance_faces.rb
1 parent 20de59b commit 07f401a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

examples/plot_forest_importances_faces.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
n_jobs = 1
1818

1919
# Load the faces datasets
20-
data = fetch_olivetti_faces.()
21-
x = data.images.reshape.(PyCall.tuple(PyCall.len(data.images), -1))
20+
data = fetch_olivetti_faces()
21+
x = data.images.reshape([PyCall.len(data.images), -1])
2222
y = data.target
2323

2424
mask = y < 5 # Limit to 5 classes
@@ -28,19 +28,19 @@
2828
# Build a forest and compute the pixel importances
2929
puts "Fitting ExtraTreesClassifier on faces data with #{n_jobs} cores..."
3030
t0 = Time.now
31-
forest = ExtraTreesClassifier.(
31+
forest = ExtraTreesClassifier.new(
3232
n_estimators: 1_000,
3333
max_features: 128,
3434
n_jobs: n_jobs,
3535
random_state: 0
3636
)
3737

38-
forest = forest.fit.(x, y)
38+
forest = forest.fit(x, y)
3939
puts "done in %0.3fs" % (Time.now - t0)
4040
importances = forest.feature_importances_
41-
importances = importances.reshape.(data.images[0].shape)
41+
importances = importances.reshape(data.images[0].shape)
4242

4343
# Plot pixel importances
44-
plt.matshow.(importances, cmap: plt.cm.hot)
45-
plt.title.("Pixel importances with forests of trees")
46-
plt.show.()
44+
plt.matshow(importances, cmap: plt.cm.__dict__[:hot])
45+
plt.title("Pixel importances with forests of trees")
46+
plt.show()

0 commit comments

Comments
 (0)