Skip to content

Instantly share code, notes, and snippets.

View KevinLiao159's full-sized avatar

Kevin Liao KevinLiao159

View GitHub Profile
@KevinLiao159
KevinLiao159 / make_recommendations_knn.py
Last active November 5, 2018 06:20
The "make_recommendations" method from my KNN recommender
def make_recommendations(self, fav_movie, n_recommendations):
"""
make top n movie recommendations
Parameters
----------
fav_movie: str, name of user input movie
n_recommendations: int, top n recommendations
"""
# get data
movie_user_mat_sparse, hashmap = self._prep_data()
@KevinLiao159
KevinLiao159 / make_recommendations_als.py
Created November 11, 2018 01:37
The "make_recommendations" method from my ALS recommender
def make_recommendations(self, fav_movie, n_recommendations):
"""
make top n movie recommendations
Parameters
----------
fav_movie: str, name of user input movie
n_recommendations: int, top n recommendations
"""
# get data
movie_user_mat_sparse, hashmap = self._prep_data()
@KevinLiao159
KevinLiao159 / tune_als.py
Created November 11, 2018 02:08
A function for ALS hyper-param tuning
from pyspark.ml.recommendation import ALS
def tune_ALS(train_data, validation_data, maxIter, regParams, ranks):
"""
grid search function to select the best model based on RMSE of
validation data
Parameters
----------