Skip to content

Instantly share code, notes, and snippets.

View krrrr38's full-sized avatar
💭
🍣

Ken Kaizu krrrr38

💭
🍣
View GitHub Profile
@krrrr38
krrrr38 / example5_3.py
Created December 11, 2011 16:52
Fisher linear discriminant
#coding:utf-8
# 4.1.4 フィッシャーの線形判別(p.185)
# 3クラスへの応用
import numpy as np
from pylab import *
import sys
N = 150 # データ数
@krrrr38
krrrr38 / example9_2.py
Created December 12, 2011 02:51
SVM by OpenOpt.QP
#SVM by OpenOpt
#use 'classification.txt'
from scipy import *
from scipy.linalg import norm
import numpy as np
from openopt import QP
from pylab import *
C = 0.5 #
SIGMA = 0.45 # the parameter of gaussian_kernel
@krrrr38
krrrr38 / breadth_search.py
Created December 21, 2011 19:15
twitterの道探すやつ.途中でやめた
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
search route between 2 users in twitter
"""
print __doc__
import sys
import twitter
@krrrr38
krrrr38 / gist:1577321
Created January 8, 2012 05:18
twitter data #programming
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''ハッシュタグ#programmngからStatusListを受け取りファイルへテキストを保存する
1,「#programming」を条件にデータを取得
2,「, . ( ) 」をスペースに置換
3,小文字に変換
#4,スペースで文字を分割
#5,文字が#で始まっていたら#を削除
@krrrr38
krrrr38 / gist:1605252
Created January 13, 2012 09:17
年俸1000万!!
#!/usr/bin/python
# -*- coding:utf-8 -*-
'''年俸1000万がどうとか
http://alpha.cgios.net/alpha/cgios
'''
import sys
@krrrr38
krrrr38 / puyopuyo.py
Created January 22, 2012 05:48
人材獲得作戦2011 - ぷよぷよ
#!/usr/bin/python
# -*- coding:utf-8 -*-
import sys
import copy
def usage():
print "usage: %s puyomap_file" % sys.argv[0]
return 1
@krrrr38
krrrr38 / sony_rectangular.py
Created January 23, 2012 10:17
sonyの問題
#!/usr/bin/python
# -*- coding:utf-8 -*-
'''
他人のコード使って重要な所間違ってたからそこだけ修正したやつ
'''
from itertools import product
from collections import namedtuple
@krrrr38
krrrr38 / tex_pdf.sh
Created February 2, 2012 06:37
usage: tex_pdf.sh tex_file
#!/bin/bash
CMDNAME=`basename $0`
if [ $# -ne 1 ]; then
echo "usage: CMDNAME: tex_file" 1>&2
exit 0
fi
tex_file=$1
@krrrr38
krrrr38 / permutate.scala
Created February 13, 2012 01:47
なんか勘違いしてる?解決済
def permutation(l: List[Int]): Iterator[List[Int]] = {
if (l.isEmpty)
Iterator(Nil)
else
// for (i <- 0 until l.length;
for (i <- Iterator.range(0, l.length);
next <- permutation(l.slice(0, i) ::: l.slice(i+1, l.length)))
yield l(i) :: next
}
@krrrr38
krrrr38 / p21.scala
Created February 18, 2012 22:43
Seqのappendの疑問
def insertAtErrorL[A](e: A, i: Int, ls: Seq[A]): Seq[A] = ls.take(i) :+ e ++ ls.drop(i)
// scala> <console>:7: error: value ++ is not a member of type parameter A
// def insertAtErrorL[A](e: A, i: Int, ls: Seq[A]): Seq[A] = ls.take(i) :+ e ++ ls.drop(i)
// ^
def insertAtErrorR[A](e: A, i: Int, ls: Seq[A]): Seq[A] = ls.take(i) ++ e +: ls.drop(i)
// scala> <console>:1: error: left- and right-associative operators with same precedence may not be mixed
// def insertAtErrorR[A](e: A, i: Int, ls: Seq[A]): Seq[A] = ls.take(i) ++ e +: ls.drop(i)
// ^