File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 17
17
n_jobs = 1
18
18
19
19
# 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 ] )
22
22
y = data . target
23
23
24
24
mask = y < 5 # Limit to 5 classes
28
28
# Build a forest and compute the pixel importances
29
29
puts "Fitting ExtraTreesClassifier on faces data with #{ n_jobs } cores..."
30
30
t0 = Time . now
31
- forest = ExtraTreesClassifier . (
31
+ forest = ExtraTreesClassifier . new (
32
32
n_estimators : 1_000 ,
33
33
max_features : 128 ,
34
34
n_jobs : n_jobs ,
35
35
random_state : 0
36
36
)
37
37
38
- forest = forest . fit . ( x , y )
38
+ forest = forest . fit ( x , y )
39
39
puts "done in %0.3fs" % ( Time . now - t0 )
40
40
importances = forest . feature_importances_
41
- importances = importances . reshape . ( data . images [ 0 ] . shape )
41
+ importances = importances . reshape ( data . images [ 0 ] . shape )
42
42
43
43
# 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 ( )
You can’t perform that action at this time.
0 commit comments