Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

NMF cosine similarities

# Perform the necessary imports
import pandas as pd
from sklearn.preprocessing import normalize

# Normalize the NMF features: norm_features
norm_features = normalize(nmf_features)

# Create a DataFrame: df
df = pd.DataFrame(norm_features, index=titles)

# Select the row corresponding to 'Cristiano Ronaldo': article
article = df.loc['Cristiano Ronaldo']

# Compute the dot products: similarities
similarities = df.dot(article)

# Display those with the largest cosine similarity
print(similarities.nlargest())
Comment

PREVIOUS NEXT
Code Example
Python :: access dictionary in f string 
Python :: bagging algorithm 
Python :: python loop take out element backwardly 
Python :: como colocar uma variavel no print python 
Python :: function transformer and feature union 
Python :: looping through the dict. and return the key with the highest value 
Python :: type hinting with default value python 
Python :: python sort by last name using lambda 
Python :: website screenshot python compress image 
Python :: matplotlib boxplot fill box with pattern 
Python :: allow django imagefield accept base 64 image 
Python :: subsetting a column and giving it a value using numpy 
Python :: create list python 
Python :: loc condition on first 3 columns of dataframe 
Python :: How to Use the abs() Function with a Complex Number Argument 
Python :: filter parent based on related child name values 
Python :: python dummy command 
Python :: the 100th iteration in python next() 
Python :: reate the "soup." This is a beautiful soup object: 
Python :: why we need open ( ) and close ( ) in os 
Python :: python change type of every element in a dictionary 
Python :: expionenttiation python 
Python :: how to write a correct python code 
Python :: QAction pressed pyqt5 
Python :: dorp ligne in df where values equal zeros 
Python :: Find the minimum item in this RDD 
Python :: Limits the result count to the number specified 
Python :: tensorflow loop csdn 
Python :: python compactar arquivo antes de exportar 
Python :: connect kaggle to colab 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =