Menu

Displaying Recommended News Articles

The recommendation function returns similarity scores. The next step is to display the headlines of the most similar news articles.

Code

def display_recommendations(title):
recommendations = recommend_news(title)
print("Recommended News Articles:\n")
for article in recommendations[1:6]:
print(news.iloc[article[0]]['headline'])

Explanation

The function displays the top five news articles with the highest similarity scores.

The first result is ignored because it represents the selected article itself.

Output

The five most relevant news headlines are displayed.