Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
import numpy as np | |
from hyperopt import hp, tpe, fmin | |
# Single line bayesian optimization of polynomial function | |
best = fmin(fn = lambda x: np.poly1d([1, -2, -28, 28, 12, -26, 100])(x), | |
space = hp.normal('x', 4.9, 0.5), algo=tpe.suggest, | |
max_evals = 2000) |
This file contains 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
# -*- coding: utf-8 -*- | |
""" | |
Created on Mon Sep 23 23:16:44 2017 | |
@author: Marios Michailidis | |
This is an example that performs stacking to improve mean squared error | |
This examples uses 2 bases learners (a linear regression and a random forest) | |
and linear regression (again) as a meta learner to achieve the best score. | |
The initial train data are split in 2 halves to commence the stacking. |
This file contains 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
# -*- coding: utf-8 -*- | |
""" | |
Created on Mon Sep 23 23:16:44 2017 | |
@author: Marios Michailidis | |
This is an example of a simple method that performs bagging | |
""" |
This file contains 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
import numpy as np | |
from keras.layers import Dense, Input | |
from keras.models import Model | |
x = Input((1,)) | |
y = Dense(1, activation ='linear')(x) | |
m = Model(x,y) | |
m.compile(loss = 'mse', optimizer='sgd') | |
_x = np.linspace(1,2, num = 1e3) |
This file contains 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 datetime import date | |
sundays=0 | |
for year in range(1901,2001): | |
for month in range(1,13): | |
if date(year,month,1).weekday()==6: | |
sundays+=1 | |
print sundays |