# Number of cores to use to perform parallel fitting of the forest modeln_jobs=1# Load the faces datasetdata=fetch_olivetti_faces()X=data.images.reshape((len(data.images),-1))y=data.targetmask=y<5# Limit to 5 classesX=X[mask]y=y[mask]# Build a forest and compute the pixel importancesprint("Fitting ExtraTreesClassifier on faces data with %d cores..."%n_jobs)t0=time()forest=ExtraTreesClassifier(n_estimators=1000,max_features=128,n_jobs=n_jobs,random_state=0)forest.fit(X,y)print("done in %0.3fs"%(time()-t0))importances=forest.feature_importances_importances=importances.reshape(data.images[0].shape)

trace=go.Heatmap(z=importances,colorscale='Hot',showscale=False)layout=go.Layout(title="Pixel importances with forests of trees",yaxis=dict(autorange='reversed'))fig=go.Figure(data=[trace],layout=layout)py.iplot(fig)