Skip to content

Instantly share code, notes, and snippets.

View psinger's full-sized avatar

Philipp Singer psinger

View GitHub Profile
@psinger
psinger / .screenrc
Created February 6, 2024 10:28
Screenrc
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]'
# huge scrollback buffer
defscrollback 5000
# no welcome message
startup_message off
# 256 colors
""" Calibrated Classifier Model: To calibrate predictions using Platt's scaling, Isotonic Regression or Splines
"""
import copy
import datatable as dt
from h2oaicore.mojo import MojoWriter, MojoFrame
from h2oaicore.systemutils import config
from h2oaicore.models import CustomModel, LightGBMModel
from sklearn.preprocessing import LabelEncoder
import numpy as np
""" Calibrated Classifier Model: To calibrate predictions using Platt's scaling, Isotonic Regression or Splines
"""
import copy
import datatable as dt
from h2oaicore.mojo import MojoWriter, MojoFrame
from h2oaicore.systemutils import config
from h2oaicore.models import CustomModel, LightGBMModel
from sklearn.preprocessing import LabelEncoder
import numpy as np
Name # plays Actual Expected Ratio Dif
Kerryon Johnson 118 5.432 3.755 1.446 1.677
Kenneth Dixon 60 5.550 4.201 1.321 1.349
Saquon Barkley 261 5.008 3.738 1.340 1.270
Nick Chubb 190 5.184 3.931 1.319 1.253
Derrick Henry 200 4.825 3.695 1.306 1.130
Jordan Wilkins 60 5.600 4.558 1.229 1.042
Aaron Jones 132 5.485 4.465 1.228 1.020
Zach Zenner 55 4.818 3.845 1.253 0.973
Phillip Lindsay 189 5.466 4.510 1.212 0.955
@psinger
psinger / gist:103a0b0d433e4d61bf12ed218abce89f
Last active December 2, 2019 13:14
2018 Yards per Attempt stats for players with more than 50 rushing plays
Name # plays Actual Expected Ratio Dif
Kerryon Johnson 118 5.432 3.755 1.446 1.677
Kenneth Dixon 60 5.550 4.201 1.321 1.349
Saquon Barkley 261 5.008 3.738 1.340 1.270
Nick Chubb 190 5.184 3.931 1.319 1.253
Derrick Henry 200 4.825 3.695 1.306 1.130
Jordan Wilkins 60 5.600 4.558 1.229 1.042
Aaron Jones 132 5.485 4.465 1.228 1.020
Zach Zenner 55 4.818 3.845 1.253 0.973
Phillip Lindsay 189 5.466 4.510 1.212 0.955
@psinger
psinger / pandas_groupby_apply_multiprocessing.py
Created November 5, 2019 14:08
Pandas groupby apply multiprocessing #python #pandas
from joblib import Parallel, delayed
import multiprocessing
import pandas as pd
import time
def applyParallel(dfGrouped, func):
retLst = Parallel(n_jobs=multiprocessing.cpu_count())(delayed(func)(group) for name, group in dfGrouped)
return pd.concat(retLst)
def myfunc(df)
return df
@psinger
psinger / tta_segmentation.py
Last active November 5, 2019 14:09
tta segmentation #ml #pytorch #python
#https://github.com/qubvel/ttach
import ttach as tta
transforms = tta.Compose(
[
tta.HorizontalFlip(),
tta.VerticalFlip(),
# tta.Rotate90(angles=[0, 180]),
# tta.Scale(scales=[1, 2, 4]),
# tta.Multiply(factors=[0.9, 1, 1.1]),
from sklearn.base import BaseEstimator, TransformerMixin
from pandas.api.types import CategoricalDtype
import pandas as pd
class DummyEncoder(BaseEstimator, TransformerMixin):
def __init__(self, min_frequency=1, dummy_na=True):
self.min_frequency = min_frequency
self.dummy_na = dummy_na
self.categories = dict()
import numpy as np
x = np.array([525., 300., 450., 300., 400., 500., 550., 125., 300., 400., 500., 550.])
y = np.array([250., 225., 275., 350., 325., 375., 450., 400., 500., 550., 600., 525.])
data = np.array([x, y])
model = analyze(data)
from pymc import Normal, Uniform, MvNormal, Exponential
from numpy.linalg import inv, det
from numpy import log, pi, dot
import numpy as np
from scipy.special import gammaln
def _model(data, robust=False):
# priors might be adapted here to be less flat
mu = Normal('mu', 0, 0.000001, size=2)
sigma = Uniform('sigma', 0, 1000, size=2)