Skip to content

Instantly share code, notes, and snippets.

View matsuken92's full-sized avatar

kenmatsu4 matsuken92

View GitHub Profile
@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')
@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
%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_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)
# 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 / file0.txt
Last active January 16, 2016 16:51
確率的勾配降下法とは何か、をPythonで動かして解説する ref: http://qiita.com/kenmatsu4/items/d282054ddedbd68fecb0
\nabla f = \frac{d f({\bf x})}{d {\bf x}} = \left[ \begin{array}{r} \frac{\partial f}{\partial x_1} \\ ... \\ \frac{\partial f}{\partial x_2} \end{array} \right]
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)
@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
@matsuken92
matsuken92 / 01_preparation.py
Last active August 21, 2018 15:58
ROC Curve Animation
%matplotlib inline
import sys
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as st
from matplotlib import animation as ani
import sklearn.metrics as mt