Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
º¿º

Sergey Feldman sergeyf

💭
º¿º
View GitHub Profile
View king_county_covid.py
# -*- 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
@sergeyf
sergeyf / mice_n_imputations_experiment.py
Last active Jun 14, 2018
mice_n_imputations_experiment.py
View mice_n_imputations_experiment.py
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')
@sergeyf
sergeyf / install-choco-script.bat
Last active Jul 13, 2020 — forked from zaccb/install-choco-script.bat
Chocolatey install script
View install-choco-script.bat
:: 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
View double_ml.py
'''
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
View mdn_harder_data.py
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
View MDN_beta.py
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
View difficult_problem.py
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
View gaussian_encodings.py
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
View arxiv2kindle.py
'''
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
View contextual_bandit_data_generator.py
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