<jupyter_start><jupyter_text><jupyter_code>!pip install surprise
import pandas as pd
import numpy as np
from surprise import Dataset, Reader
from surprise import SVD
from surprise import accuracy
from surprise.model_selection import cross_validate, train_test_split
from surprise.prediction_algorithms import Prediction
import random
from surprise.model_selection import GridSearchCV
from surprise.prediction_algorithms import algo_base
from surprise import KNNBasic
from surprise import SVDpp
from surprise import NMF
from surprise import NormalPredictor
from surprise import BaselineOnly
#mount your own drive to avoid downloading the data multiple time 

from google.colab import drive
drive.mount('/content/gdrive')
df_state= pd.read_pickle('/content/gdrive/MyDrive/YelpDataset/PickleFiles/yelp_data_df_ON')
df_state.head()
reader = Reader(rating_scale=(1, 5))
data = Dataset.load_from_df(df_state[['user_id', 'business_id', 'stars']], reader) # We cannot pass in text, bcz load_from_df takes only 3 and it is made specifically for reviews

train, test= train_test_split(data, train_size=0.8)
np = NormalPredictor() # Predicting random rating based on distribution of training set
bo= BaselineOnly() #Algorithm predicting the baseline estimate for given user and item.
np.fit(train)
bo.fit(train)
np_preds= np.test(test)
bo_preds= bo.test(test)
accuracy.mse(np_preds)
accuracy.mse(bo_preds)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0723314606741573, 'fraction_numerical': 0.0035112359550561797, 'mean_word_length': 7.142857142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '226127', 'license': 'MIT', 'n_tokens_mistral': 441, 'n_tokens_neox': 421, 'n_words': 143, 'path': 'baseline_model.ipynb', 'repo_name': 'akshaypt7/RestroRecommender-1', 'size': '1424'}