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 Tue Jul 21 07:44:21 2020 | |
@author: serge | |
""" | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import seaborn as sns |
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 sklearn.impute import MICEImputer | |
from sklearn.datasets import load_boston | |
from sklearn.ensemble import RandomForestRegressor | |
from sklearn.pipeline import Pipeline | |
from sklearn.model_selection import cross_val_score | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
sns.set(context='poster') |
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
:: Install choco .exe and add choco to PATH | |
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" | |
:: for ease of updating | |
choco install ChocolateyGUI -fy | |
:: basics | |
choco install googlechrome -fy | |
choco install agentransack -fy | |
choco install vlc -fy |
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
''' | |
References: | |
https://medium.com/teconomics-blog/using-ml-to-resolve-experiments-faster-bd8053ff602e | |
https://insightr.wordpress.com/2017/06/28/cross-fitting-double-machine-learning-estimator/ | |
https://arxiv.org/pdf/1608.00060.pdf | |
''' | |
import numpy as np | |
from sklearn.linear_model import LassoCV, LinearRegression, BayesianRidge, LogisticRegression |
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 | |
# the function | |
def f_of_x(X, w): | |
n,d = X.shape | |
X_dot_w = np.dot(X,w) | |
y = np.zeros(n) | |
# the inner product randomly goes through a sin | |
# or a cos | |
cos_flag = np.random.randn(n) < 0.0 |
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 matplotlib.pyplot as plt | |
import numpy as np | |
import seaborn | |
from keras.layers import Input, Dense, merge, ELU, Dropout | |
from keras.models import Model | |
from keras.regularizers import l2 | |
from keras import backend as K | |
from keras.optimizers import rmsprop, adam |
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 | |
def f_of_x(X,w): | |
n,d = X.shape | |
X_dot_w = np.dot(X,w) | |
y = np.zeros(n) | |
# the inner product goes through a sin | |
# or a cos, depending on simple condition | |
cos_flag = X[:,0] < 0.0 | |
sin_flag = ~cos_flag |
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 scipy.spatial.distance import pdist, squareform | |
# function that converts categorical variable | |
# into a one-hot encoding | |
def one_hot_encoding(x): | |
n = len(x) | |
min_category = np.min(x) | |
max_category = np.max(x) | |
num_categories = max_category - min_category + 1 |
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
''' | |
Based on: https://gist.github.com/bshillingford/6259986edca707ca58dd | |
Modified to work on Windows by: Sergey Feldman | |
Jan 17, 2016 | |
Requirements: pdflatex, bibtex | |
''' | |
import requests | |
import lxml.html as html |
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 | |
class Data_generator(object): | |
def __init__(self,K,d,reward_type='binary'): | |
self.d = d # dimension of the feature vector | |
self.K = K # number of bandits | |
self.reward_type = reward_type |
NewerOlder