Machine-Learning-for-Asset-Managers
Machine-Learning-for-Asset-Managers copied to clipboard
AttributeError: 'NoneType' object has no attribute 'labels_'
When I run the script called 'ch7_portfolio_construction' I get the following error:
AttributeError Traceback (most recent call last)
D:\User\Desktop\ch4_optimal_clustering.py in clusterKMeansBase(corr0, maxNumClusters, n_init, debug) 56 print("********") 57 ---> 58 newIdx = np.argsort(kmeans.labels_) 59 #print(newIdx) 60
AttributeError: 'NoneType' object has no attribute 'labels_'
Can you please help me to fix this bug? Thank you!
This is because min number of clusters was set to 4 in ch4_optimal_clustering.py in clusterKMeansBase, but it should be 2. I have updated this in this commit: https://github.com/emoen/Machine-Learning-for-Asset-Managers/commit/5acb8a56799439db2f026c18fa5cad1aed6be7d2