Syntax error for gs = GridSearchCV(KNNBasic, param_grid, measures=['rmse', 'mae'], cv=3, n_jobs=-1)

Viewed 7

I am stuck on this line of code and keep getting a syntax error. Any help would be appreciated.

Setting up parameter grid to tune the hyperparameters

param_grid = {'k': [10,20,30], 'min_k': [3,6,9],'sim_options': {'name': ['msd', 'cosine'],'user_based': [False]}

Performing 3-fold cross validation to tune the hyperparameters

gs = GridSearchCV(KNNBasic, param_grid, measures=['rmse', 'mae'], cv=3, n_jobs=-1)

Fitting the data

gs.fit(data)

Find the best RMSE score

print(gs.best_score['rmse'])

Find the combination of parameters that gave the best RMSE score

print(gs.best_params['rmse'])

File "", line 5 gs = GridSearchCV(KNNBasic, param_grid, measures=['rmse', 'mae'], cv=3, n_jobs=-1) ^ SyntaxError: invalid syntax

0 Answers
Related