text_html_output_1.png
from sklearn.decomposition import TruncatedSVD

import numpy as np

import pandas as pd

new_pr = pd.read_csv('/kaggle/input/collaborative-csv/data_collaborative_full_csv')
new_pr = new_pr.sample(50000)

sentiment_matrix = new_pr.pivot_table(values='total_score', index='asin', columns='reviewerID', fill_value=0)
sentiment_matrix

sentiment_matrix.shape

X = sentiment_matrix

from sklearn.decomposition import TruncatedSVD
SVD = TruncatedSVD(n_components=10)
decomposed_matrix = SVD.fit_transform(X)
decomposed_matrix.shape
'\nThe singular value decomposition(SVD) provides another way to factorize a matrix, into singular vectors and singular values. ... The SVD is used widely both in the calculation of other matrix operations, such as matrix inverse, but also as a data reduction method in machine learning\n'
decomposed_matrix.shape

correlation_matrix = np.corrcoef(decomposed_matrix)
correlation_matrix

i = '0486413012'
product_names = list(X.index)
product_ID = product_names.index(i)
product_ID

correlation_product_ID = correlation_matrix[product_ID]
correlation_product_ID.shape