Skip to content

Instantly share code, notes, and snippets.

View gurimusan's full-sized avatar

gurimusan gurimusan

View GitHub Profile
@gurimusan
gurimusan / batch_gradient_descent.py
Created January 6, 2018 22:41
バッチ勾配降下法
# -*- coding: utf-8 -*-
import re
import urllib2
import numpy
def batch_gradient_descent(X, y, initial_theta, alpha, num_iters=1500):
u"""データセットに対してバッチ勾配降下法を実行し
目的関数を最小化するθを求める。
  • It's recommended to set an empty value to the following kernel config option:
  • CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" >>> Auto-cleaning packages...
@gurimusan
gurimusan / pagination.py
Last active September 25, 2017 17:24
ページネーションするための汎用クラス
# -*- coding: utf-8 -*-
from math import ceil
class PageOffset(object):
def __init__(self, start=1, size=0):
if start < 0:
raise AttributeError
if size < 0:
@gurimusan
gurimusan / agglomerative_clustering_with_centroid_method.py
Last active July 19, 2017 15:38
凝縮型クラスタリング
# -*- coding: utf-8 -*-
"""
凝縮型クラスタリング(agglomerative clustering)
重心法(centroid method)
"""
def sim(x1, x2):
if x1 == x2:
return float('inf')
return 1.0/(max(x1, x2) - min(x1, x2))
@gurimusan
gurimusan / 演習1.1.md
Last active June 6, 2017 14:51
計算理論の基礎 Michael Sipser

演習1.1

M1

a. 開始状態はどれか?

q1

@gurimusan
gurimusan / 5章演習問題1の解答.md
Created May 3, 2017 16:16
コンパイラ(中田育夫)のメモ

2分法を使うために、KeyWdTの書き換え、及びnextTokenのletterの場合のプログラムの書き換え。

KeyWdTの書き換え。

static struct keyWd KeyWdT[] = {
    {"if", If},
    {"do", Do},
    {"end", End},
    {"odd", Odd},
@gurimusan
gurimusan / 01.read-dfa.c.md
Last active April 21, 2017 22:32
gnu grep 3.0 のlib/dfa.cのソースコードリーディング
  • dfaalloc
  • dfasyntax
  • dfacomp
  • dfaparse L1963
  • lex L1253
  • regexp
  • dfassbuild
  • dfa_supported
  • dfaoptimize
  • dfaanalyze
@gurimusan
gurimusan / mysql_use_regexp_kana.md
Created April 13, 2017 03:01
MySQLのregexpを用いてカタカナのみで表現されていないカラムを検出する方法

MySQLのregexpはマルチバイト対応していない。

そこで、文字の16進数の文字列に変換してregexpを使う。

UTF-8前提が前提だと、pythonでカタカナを16進数に変換。

>>> '|'.join([''.join([hex(ord(cc)) for cc in c.encode('utf-8')]).replace('0x', '').upper() for c in u"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲンヴガギグゲゴザジズゼゾダヂヅデドバビブベボァィゥェォヵヶッャュョヮ"])
'E382A2|E382A4|E382A6|E382A8|E382AA|E382AB|E382AD|E382AF|E382B1|E382B3|E382B5|E382B7|E382B9|E382BB|E382BD|E382BF|E38381|E38384|E38386|E38388|E3838A|E3838B|E3838C|E3838D|E3838E|E3838F|E38392|E38395|E38398|E3839B|E3839E|E3839F|E383A0|E383A1|E383A2|E383A4|E383A6|E383A8|E383A9|E383AA|E383AB|E383AC|E383AD|E383AF|E383B0|E383B1|E383B2|E383B3|E383B4|E382AC|E382AE|E382B0|E382B2|E382B4|E382B6|E382B8|E382BA|E382BC|E382BE|E38380|E38382|E38385|E38387|E38389|E38390|E38393|E38396|E38399|E3839C|E382A1|E382A3|E382A5|E382A7|E382A9|E383B5|E383B6|E38383|E383A3|E383A5|E383A7|E383AE
@gurimusan
gurimusan / gentoo_install_battle_on_thinkpad-t460s.md
Last active February 14, 2017 19:04
gentoo install battle on thinkpad t460s

インストールメディアの作成

mac 上でinstall cdをusbに焼いた。

windows上でやること

fast bootを切る

@gurimusan
gurimusan / .vimrc
Last active February 8, 2017 02:23
" -----
" Dein
" -----
if &compatible
set nocompatible
endif
set runtimepath+=~/.vim/dein/repos/github.com/Shougo/dein.vim
if dein#load_state(expand('~/.vim/dein'))
call dein#begin(expand('~/.vim/dein'))