From a442cdeb3ca1f8d5d9169293ad0b7c2d4c4cd663 Mon Sep 17 00:00:00 2001 From: Yuki Sakishita Date: Fri, 4 Aug 2023 19:12:04 +0900 Subject: [PATCH 1/2] Changed to explicit relative reference --- .../ch6_feature_importance_analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..bbddaa6 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 From bdef84e0bc8ec8465fa18fded3cb7c8f576c0f58 Mon Sep 17 00:00:00 2001 From: Yuki Sakishita Date: Fri, 4 Aug 2023 19:34:19 +0900 Subject: [PATCH 2/2] Fixed attribute name `fit.enumerators_` to `fit.estimators` --- .../ch6_feature_importance_analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 bbddaa6..ae5c78d 100644 --- a/Machine_Learning_for_Asset_Managers/ch6_feature_importance_analysis.py +++ b/Machine_Learning_for_Asset_Managers/ch6_feature_importance_analysis.py @@ -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