scikit learn - Python: How to calculate the values of Precision-recall and F-measure through Singular Value Decomposition on MovieLens 1M Dataset? -


i tried calculate using sklearn.metrics.precision_recall_fscore_support but, gave me error valueerror: can't handle mix of multiclass-multioutput , continuous-multioutput

output of predicted matrix , test matrix available in screenshot. image output

import numpy np import pandas pd math import sqrt scipy.sparse.linalg import svds sklearn.model_selection import train_test_split sklearn.metrics import mean_squared_error sklearn.metrics import mean_absolute_error  df = pd.read_csv('/home/linux/documents/recommendersystem/datasets/movielens/ml-1m/ratings.dat', sep='::', names=['user_id', 'item_id', 'rating', 'timestamp'], engine='python')  n_users = df.user_id.unique().shape[0] n_items = df.item_id.unique().shape[0] print('number of users = ' + str(n_users) + ' | number of movies = ' + str(n_items) )  train_data, test_data = train_test_split(df, test_size=0.25)  # create 2 user-item matrices, 1 training , testing train_data_matrix = np.zeros((6040, 3952)) line in train_data.itertuples():     train_data_matrix[line[1]-1, line[2]-1] = line[3]  test_data_matrix = np.zeros((6040, 3952)) line in test_data.itertuples():     test_data_matrix[line[1]-1, line[2]-1] = line[3]  # svd components train matrix. choose k. u, s, vt = svds(train_data_matrix, k=100) s_diag_matrix = np.diag(s) x_pred = np.dot(np.dot(u, s_diag_matrix), vt) print('svd rmse: ' + str(sqrt(mean_squared_error(test_data_matrix, x_pred)))) print('svd mae: ' + str(mean_absolute_error(test_data_matrix, x_pred))) 


Comments