Skip to content

Instantly share code, notes, and snippets.

@satomacoto
satomacoto / tensoflow.sublime-project
Created November 16, 2015 03:34
SublimeText project setting
{
"build_systems":
[
{
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"name": "Anaconda Python Builder",
"selector": "source.python",
"shell_cmd": "~/.virtualenvs/tensorflow/bin/python -u \"$file\""
}
],
@satomacoto
satomacoto / gensim_vs_sklearn.py
Created August 18, 2015 08:18
gensim vs. sklearn
# -*- coding: utf-8 -*-
import gensim
from sklearn.feature_extraction.text import CountVectorizer
from gensim.corpora.dictionary import Dictionary
from gensim.corpora import MmCorpus
import numpy as np
import lda
# -*- coding: utf-8 -*-
import pandas as pd
import numpy as np
from sklearn.datasets import load_digits
from sklearn import grid_search, metrics
from sklearn.pipeline import Pipeline, FeatureUnion
from sklearn.linear_model import LogisticRegression, RidgeClassifier, PassiveAggressiveRegressor, ElasticNet
from sklearn.ensemble import GradientBoostingRegressor, ExtraTreesRegressor, RandomForestRegressor
from sklearn.neighbors import KNeighborsClassifier, KNeighborsRegressor
@satomacoto
satomacoto / README.md
Created May 14, 2015 10:04
pandas tips

set_index <-> reset_index

@satomacoto
satomacoto / gist:29690c651cbfc0cd23d7
Created April 15, 2015 01:49
条件を満たす要素をまとめて変える

python, pandas

In [1]: df
Out[1]:
  apple banana cherry
0     0      3   good
1     1      4    bad
2     2      5   good
In [2]: df.loc[df.cherry == 'bad', ['apple', 'banana']] = np.nan
@satomacoto
satomacoto / gist:0d0cc58e3bbcaea68148
Last active August 29, 2015 14:16
Yahoo!競馬の情報から直近5走のデータを取得して縦馬柱をipythonで表示する
import pandas as pd
from lxml import html
# 出馬表
denma_url = 'http://keiba.yahoo.co.jp/race/denma/1405040911/'
xpath = '//table'
denma_tree = html.parse(denma_url)
denma_table = denma_tree.xpath(xpath)[2]
denma_html = html.tostring(denma_table)
denma_html = denma_html.decode('utf-8').replace('<br>', '\\n')
@satomacoto
satomacoto / gist:f72326c61304d90ca52c
Last active August 29, 2015 14:15
month iteration
# https://labix.org/python-dateutil
from dateutil import rrule, parser
dt = parser.parse('2014-01-01')
for x in rrule.rrule(rrule.MONTHLY, dtstart=dt, count=3):
print(x)
@satomacoto
satomacoto / gist:efce940c067ee962d4e5
Last active August 29, 2015 14:14
doc2vec most_similar_labels and most_similar_words sample
>>> import gensim
>>> sentences = [
... ['human', 'interface', 'computer'], #0
... ['survey', 'user', 'computer', 'system', 'response', 'time'], #1
... ['eps', 'user', 'interface', 'system'], #2
... ['system', 'human', 'system', 'eps'], #3
... ['user', 'response', 'time'], #4
... ['trees'], #5
... ['graph', 'trees'], #6
... ['graph', 'minors', 'trees'], #7
@satomacoto
satomacoto / MyLWMA.mq4.c
Last active August 29, 2015 14:05
MyLWMA
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
// 指標バッファ
double BufMA[];
// パラメータ
extern int MA_Period = 20;
def hoge():
print "hogehoge"