May-12-2019, 11:01 AM
Hi,
I'm running the following code in Spyder(Python 3.7). However, the output is <IPython.core.display.HTML object>, rather than a table. Am I missing something here? Thanks in advance.
I'm running the following code in Spyder(Python 3.7). However, the output is <IPython.core.display.HTML object>, rather than a table. Am I missing something here? Thanks in advance.
#import libraries import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier data = pd.read_csv('FIFA 2018 Statistics.csv') y = (data['Man of the Match'] == "Yes") # Convert from string "Yes"/"No" to binary feature_names = [i for i in data.columns if data[i].dtype in [np.int64]] X = data[feature_names] train_X, val_X, train_y, val_y = train_test_split(X, y, random_state=1) my_model = RandomForestClassifier(random_state=0).fit(train_X, train_y) import eli5 from eli5.sklearn import PermutationImportance perm = PermutationImportance(my_model, random_state=1).fit(val_X, val_y) eli5.show_weights(perm, feature_names = val_X.columns.tolist())