<jupyter_start><jupyter_text>A lot of data points have average rating zero.Seems doubtful<jupyter_code>print(len(games[games['average_rating'] == 0]))
len(games)<jupyter_output><empty_output><jupyter_text>24380 have 0 rating and there are total 81312 data points<jupyter_code>games = games.dropna(axis=0)<jupyter_output><empty_output><jupyter_text>Removing all datapoints with null values<jupyter_code>games = games[games['average_rating'] > 0]<jupyter_output><empty_output><jupyter_text>Removing all data points with 0 rating<jupyter_code>plt.hist(games['average_rating'])
plt.show()
#Corelation matrix to see relation between the features
cormat = games.corr()
fig = plt.figure(figsize=(12,9))
sns.heatmap(cormat , vmax = 0.8 , square = True)
plt.show()<jupyter_output><empty_output><jupyter_text>Removing features which are not valuable<jupyter_code>columns = games.columns.tolist()
columns = [c for c in columns if c not in ['bayes_average_rating','average_rating','type','name','id']]
target = 'average_rating'
columns
X = games[columns]
X
Y = games[target]
Y
X_train , X_test , Y_train , Y_test = train_test_split(X,Y,test_size = 0.2,random_state=1)
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
LR = LinearRegression()
LR.fit(X_train,Y_train)
predictions = LR.predict(X_test)
mean_squared_error(predictions,Y_test)
from sklearn.ensemble import RandomForestRegressor
RFR = RandomForestRegressor(n_estimators = 100 , min_samples_leaf = 10 , random_state = 1)
RFR.fit(X_train,Y_train)
predictions = RFR.predict(X_test)
mean_squared_error(predictions,Y_test)
X_train.iloc[0]
from sklearn.neighbors import KNeighborsRegressor
knn = KNeighborsRegressor(n_neighbors = 3)
knn.fit(X_train,Y_train)
predictions = knn.predict(X_test)
mean_squared_error(predictions,Y_test)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11032990805840995, 'fraction_numerical': 0.0167658193618172, 'mean_word_length': 9.109289617486338, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '132963', 'license': 'Apache-2.0', 'n_tokens_mistral': 728, 'n_tokens_neox': 664, 'n_words': 128, 'path': 'Day5/Dataset/Board Game Review Prediction.ipynb', 'repo_name': 'faiz-hasan11/MLH-Local-Hack-Day', 'size': '1849'}