Skip to content

Instantly share code, notes, and snippets.

View matsuken92's full-sized avatar

kenmatsu4 matsuken92

View GitHub Profile
@matsuken92
matsuken92 / ParameterGrid_test.py
Last active May 11, 2019 14:07
Demonstration of hidden class ParameterGrid on sklearn.
from sklearn.model_selection._search import ParameterGrid
param_grid = {
"metric_list" : [None, "None", "binary_logloss", "auc", ["binary_logloss"], ["auc"],
['binary_logloss','auc', ], ['auc', 'binary_logloss',] ],
"first_metric_only": [True, False],
"eval_train_metric": [True, False],
}
pg = ParameterGrid(param_grid)
@matsuken92
matsuken92 / default_import.py
Last active August 3, 2016 17:37
frequently used libraries etc
import math, sys, functools, os
import numpy as np
import numpy.random as rd
from numpy import matrix
import pandas as pd
import scipy as sp
from scipy import stats as st
from datetime import datetime as dt
from collections import Counter
from itertools import chain
trial_num = 10000
x = rd.multinomial(1, [1/6]*6, trial_num)
result = np.sum(x, axis=0)
data = np.array([result, np.array([1/6]*6)*trial_num]).T
# Draw graph
df = pd.DataFrame(data, columns=["trial","theory"],index=range(1,7))
ax = df.plot.bar()
ax.set_ylim(0,2000)
# LTS (Least Trimmed Squares) testing
# Reference: https://cran.r-project.org/web/packages/galts/galts.pdf
install.packages("galts")
install.packages("ggplot2")
require(galts)
require(ggplot2)
lts_test <- function(x, y) {
# Preparing
install.packages("Rlab")
install.packages("ggplot2")
install.packages("actuar")
install.packages("plyr")
require(plyr)
require(actuar)
require(ggplot2)
require(Rlab)
@matsuken92
matsuken92 / 01_preparation.py
Last active August 29, 2015 14:27
GLMM : draw graphs of mixture distributions.
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as st
from matplotlib import animation as ani
plt.style.use('ggplot')
plt.rc('text', usetex=True)
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as st
from matplotlib import animation as ani
plt.style.use('ggplot')
plt.rc('text', usetex=True)
@matsuken92
matsuken92 / 01_prep.py
Last active February 19, 2022 06:56
Graph for explanation of Standard Deviation.
%matplotlib inline
import matplotlib.pyplot as plt
from matplotlib import animation as ani
import numpy as np
import sys
plt.style.use('ggplot')
@matsuken92
matsuken92 / 01_quantile_reg_evaluate_func.py
Created July 28, 2015 15:15
Drawing a evaluate function for Quantile Regression.
%matplotlib inline
import matplotlib.pyplot as plt
import sys
import numpy as np
from matplotlib import animation as ani
plt.style.use('ggplot')
x = np.linspace(-2, 2, 500)
x2 = (1/2.)*x**2
@matsuken92
matsuken92 / 01_draw_lenna_and_filter.py
Last active August 29, 2015 14:24
Draw a image of famous Lenna and filtered image.
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import math
import mahotas as mh
import os.path
# get Lenna image
if os.path.isfile('./lenna.jpg'):
im = mh.demos.load('lena')