Skip to content

Instantly share code, notes, and snippets.

View matsuken92's full-sized avatar

kenmatsu4 matsuken92

View GitHub Profile
@matsuken92
matsuken92 / 1-dim steepest descent.py
Last active May 6, 2023 10:30
Various types of gradient descent method
import numpy as np
import matplotlib.pyplot as plt
from moviepy.editor import *
from matplotlib import animation as ani
sigma = 1
mu = 3
def norm_dist_neg(x):
return -1./(np.sqrt(2 * np.pi) * sigma)* np.exp(-0.5*((x-mu)**2)/((sigma**2)))
@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_preparation.py
Last active January 23, 2022 14:45
Describe and explain Q-Q plot
%matplotlib inline
import sys
import matplotlib.pyplot as plt
from matplotlib import animation as ani
import numpy as np
import pandas as pd
import scipy.stats as st
from scipy.special import ndtri
# Data Import
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import animation as ani
plt.figure(figsize=(8,8))
n=20
@matsuken92
matsuken92 / 01_calculate.py
Last active July 8, 2021 21:10
[Python] Autoencoder with chainer [Relu, 1000units, Dropout:activate]
# these code on this page are based on the following chainer's example. Thanks!
# https://github.com/pfnet/chainer/tree/master/examples/mnist/train_mnist.py
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from sklearn.datasets import fetch_mldata
from chainer import cuda, Variable, FunctionSet, optimizers
import chainer.functions as F
import sys, time, math
@matsuken92
matsuken92 / 01_visualize_norm_dist.py
Last active April 29, 2020 04:59
カイ二乗分布の可視化
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import chi2
from matplotlib import animation as ani
def plot_dist(data, bins, title =""):
plt.figure(figsize=(7,5))
plt.title(title)
plt.hist(data, bins, color="lightgreen", normed=True)
@matsuken92
matsuken92 / 01_initialize.py
Last active January 17, 2020 12:08
Tweet analysis
from requests_oauthlib import OAuth1Session
from requests.exceptions import ConnectionError, ReadTimeout, SSLError
import json, datetime, time, pytz, re, sys, traceback, unicodedata, pymongo
#from pymongo import Connection # Connection classは廃止されたのでMongoClientに変更
from pymongo import MongoClient
import numpy as np
from collections import defaultdict
from bson.objectid import ObjectId
import MeCab as mc
@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)
# coding:utf-8
%matplotlib inline
import matplotlib.pyplot as plt
from wordcloud import WordCloud
from bs4 import BeautifulSoup
import requests
import MeCab as mc
def mecab_analysis(text):
t = mc.Tagger('-Ochasen -d /usr/local/Cellar/mecab/0.996/lib/mecab/dic/mecab-ipadic-neologd/')
@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