-
-
Save amankharwal/769bfe19751d52da3002878ceba3c5fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
articles = data["Article"].tolist() | |
uni_tfidf = text.TfidfVectorizer(input=articles, stop_words="english") | |
uni_matrix = uni_tfidf.fit_transform(articles) | |
uni_sim = cosine_similarity(uni_matrix) | |
def recommend_articles(x): | |
return ", ".join(data["Title"].loc[x.argsort()[-5:-1]]) | |
data["Recommended Articles"] = [recommend_articles(x) for x in uni_sim] | |
data.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment