Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'labels_' #1

Open
adriana2903 opened this issue May 4, 2021 · 1 comment
Open

Comments

@adriana2903
Copy link

adriana2903 commented May 4, 2021

When I run the script called 'ch7_portfolio_construction' I get the following error:

AttributeError Traceback (most recent call last)
in
39 cov1 = pd.DataFrame(cov1, index=cols, columns=cols)
40 corr1 = mp.cov2corr(cov1)
---> 41 corr1, clstrs, silh = oc.clusterKMeansBase(pd.DataFrame(corr0))
42
43 # # code snippet 7.4 - intracluster optimal allocations

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!

@emoen
Copy link
Owner

emoen commented Jul 26, 2021

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: 5acb8a5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants