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

I have clustered crime articles based on crime category. But now I want to see which article belongs to which category ? #17

Open
prashant334 opened this issue Mar 16, 2018 · 1 comment

Comments

@prashant334
Copy link

Please give some hints or direction to perform that . I have followed your code. here I am attaching my data sheet.
classification.xlsx

@prashant334 prashant334 changed the title I have clustered crime articles based on crime category. But now I want to see whcih article belongs to which category ? I have clustered crime articles based on crime category. But now I want to see which article belongs to which category ? Mar 16, 2018
@brandomr
Copy link
Owner

Could you just try this as demonstrated in the notebook? Did you run into errors?



from __future__ import print_function

print("Top terms per cluster:")
print()
#sort cluster centers by proximity to centroid
order_centroids = km.cluster_centers_.argsort()[:, ::-1] 

for i in range(num_clusters):
    print("Cluster %d words:" % i, end='')
    
    for ind in order_centroids[i, :6]: #replace 6 with n words per cluster
        print(' %s' % vocab_frame.ix[terms[ind].split(' ')].values.tolist()[0][0].encode('utf-8', 'ignore'), end=',')
    print() #add whitespace
    print() #add whitespace
    
    print("Cluster %d titles:" % i, end='')
    for title in frame.ix[i]['title'].values.tolist():
        print(' %s,' % title, end='')
    print() #add whitespace
    print() #add whitespace
    
print()
print()

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