This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# movie profile | |
movie_profile = movies[['id', 'title', 'genres']] | |
movie_profile.rename(columns={'id': 'movieId'}, inplace=True) | |
genres = [item.strip() for l in all_genres for item in l ] | |
unique_genres = set(genres) | |
for genre in unique_genres: | |
movie_profile[genre] = 0 | |
for i in range(len(movie_profile)): | |
if type(movie_profile['genres'].iloc[i]) != None.__class__: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
algo = SVD() | |
trainset = data.build_full_trainset() | |
algo.fit(trainset) | |
# Than predict ratings for all pairs (u, i) that are NOT in the training set. | |
testset = trainset.build_anti_testset() | |
predictions = algo.test(testset) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proba = {'Manchester City': {'qtr': 0, 'semi': 0, 'final': 0, 'champion': 0}, | |
'Bayern Munich': {'qtr': 0, 'semi': 0, 'final': 0, 'champion': 0}, | |
'Paris Saint-Germain': {'qtr': 300, 'semi': 0, 'final': 0, 'champion': 0}, | |
'Real Madrid': {'qtr': 0, 'semi': 0, 'final': 0, 'champion': 0}, | |
'Juventus': {'qtr': 0, 'semi': 0, 'final': 0, 'champion': 0}, | |
'Lyon': {'qtr': 0, 'semi': 0, 'final': 0, 'champion': 0}, | |
'Barcelona': {'qtr': 0, 'semi': 0, 'final': 0, 'champion': 0}, | |
'Napoli': {'qtr': 0, 'semi': 0, 'final': 0, 'champion': 0}, | |
'Chelsea': {'qtr': 0, 'semi': 0, 'final': 0, 'champion': 0}, | |
'Atalanta': {'qtr': 300, 'semi': 0, 'final': 0, 'champion': 0}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn import preprocessing | |
from imblearn.over_sampling import RandomOverSampler | |
le = preprocessing.LabelEncoder() | |
fixtures['Score'] = le.fit_transform(fixtures['Score'].astype(str)) | |
ros = RandomOverSampler(random_state=42) | |
fixtures, Score_ = ros.fit_resample(fixtures.drop(columns=['Score']), fixtures['Score']) | |
fixtures['Score'] = le.inverse_transform(Score_) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# "fixtures" is the fixture table containing all the matches that have taken place | |
# "aggregate" is the set of selected features | |
fixtures = fixtures.merge(aggregate, left_on='Home', right_on='Squad') | |
fixtures = fixtures.merge(aggregate, left_on='Away', right_on='Squad', suffixes=('_Home', '_Away')) |
NewerOlder