This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Example to show how to plot histogram with accumulate ratio. | |
Plot multiple histogram using seaborn.FacetGrid() | |
""" | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
% matplotlib inline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Example of matplotlib barplot with accumulative ratio on 2nd axis.""" | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
import seaborn as sns | |
# Plot with seaborn darkgrid style | |
% matplotlib inline | |
sns.set(style="darkgrid", palette="muted", color_codes=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
""" | |
Detect face and save cropped images. | |
http://vaaaaaanquish.hatenablog.com/entry/2016/08/15/193636 | |
http://dlib.net/face_detector.py.html | |
""" | |
import cv2 | |
import os | |
import glob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
""" | |
Convert IMDB META data(matlab .mat) to csv. | |
IMDB-WIKI – 500k+ face images with age and gender labels | |
- https://data.vision.ee.ethz.ch/cvl/rrothe/imdb-wiki/ | |
- https://stackoverflow.com/questions/13965740/converting-matlabs-datenum-format-to-python | |
""" | |
from datetime import datetime, timedelta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import pickle | |
from collections import defaultdict | |
class Timer: | |
def __init__(self): | |
self.time_pool = defaultdict(list) | |
self.start_dict = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Build keras directory structure for flow_from_dir method""" | |
import os | |
import shutil | |
import numpy as np | |
from glob import glob | |
DATA_DIR = 'data/clean' | |
FILE_EXT_PTN = '*.jpg' | |
TARGET_DIR = 'data/shrine_temple2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Frequency used matplotlib subplot.""" | |
import math | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# Apply plot function into all data in Xs dictionary. | |
def subplots(Xs, plot_func): | |
# Set subplots location info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
env_name=$1 | |
env_dir=venv | |
python3 -m venv $env_dir | |
source $env_dir/bin/activate | |
pip install --upgrade pip | |
pip install scipy | |
pip install numpy pandas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Convertace article with TEX syntax with Hatena Blog Syntax """ | |
import os | |
import re | |
from typing import List, Callable | |
from copy import deepcopy | |
def replace_m(x: str, rep_map: List[dict]) -> str: | |
for pattern, repl in rep_map: | |
x = x.replace(pattern, repl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""AR(1) Process Simulation """ | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from statsmodels.graphics.tsaplots import plot_acf | |
def gen_ar1(phi, N=1000): | |
"""Simulate AR(1) process""" | |
Z = np.random.normal(0, 1, N) # Gaussian W.N. |