diff --git a/Machine_Learning_for_Asset_Managers/ch6_feature_importance_analysis.py b/Machine_Learning_for_Asset_Managers/ch6_feature_importance_analysis.py index eea5d56..ae5c78d 100644 --- a/Machine_Learning_for_Asset_Managers/ch6_feature_importance_analysis.py +++ b/Machine_Learning_for_Asset_Managers/ch6_feature_importance_analysis.py @@ -10,7 +10,7 @@ import statsmodels.api as sm1 import matplotlib.pylab as plt -from ch4_optimal_clustering import clusterKMeansBase +from .ch4_optimal_clustering import clusterKMeansBase #Code snippet 6.1 generating a set of informative, redundant, and noisy explanatory variables # returns matrix X of training samples, and vector y of class labels for the training samples @@ -30,7 +30,7 @@ def getTestData(n_features=100, n_informative=25, n_redundant=25, n_samples=1000 #code snippet 6.2 implementation of an ensembke MDI method def featImpMDI(fit, featNames): #feat importance based on IS mean impurity reduction - df0 = {i:tree.feature_importances_ for i, tree in enumerate(fit.enumerators_)} + df0 = {i:tree.feature_importances_ for i, tree in enumerate(fit.estimators_)} df0 = pd.DataFrame.from_dict(df0, orient='index') df0.columns = featNames df0 = df0.replace(0, np.nan) #because max_features=1