Skip to content

Instantly share code, notes, and snippets.

View nzw0301's full-sized avatar

Kento Nozawa nzw0301

  • Preferred Networks, Inc. / Preferred Elements, Inc.
  • Japan
  • 22:26 (UTC +09:00)
View GitHub Profile
require 'pp'
def ngram(n = 1, text)
data = []
0.upto(text.size-n) do |i|
data << text[i..i+n-1]
end
data
end
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import com.google.common.primitives.Ints;
import fileinput
import networkx as nx
g = nx.Graph() # 無向グラフ
file = "sample.txt"
# file = "facebook_combined.txt"
for line in fileinput.input(file):
edge = list(map(int, line.split()))
g.add_edge(edge[0], edge[1])
@nzw0301
nzw0301 / nn.py
Last active November 11, 2015 07:18
# coding: utf-8
import numpy as np
import sys
from sklearn.feature_extraction.text import CountVectorizer
def logistic_function(mat):
return 1/(1+np.exp(-mat))
@nzw0301
nzw0301 / mika_nn.py
Last active November 14, 2015 07:19
# coding: utf-8
import numpy as np
import sys
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.cross_validation import train_test_split
def logistic_function(mat):
return 1/(1+np.exp(-mat))
# coding: utf-8
import sys
import math
import numpy as np
from sklearn.feature_extraction.text import CountVectorizer
from sklearn import preprocessing
import scipy.special
fname = sys.argv[1]
@nzw0301
nzw0301 / .gitignore
Created January 13, 2016 18:05
nzwの.gitignore設定ファイル
*.aux
*.bbl
*.dvi
*.blg
*.fdb_latexmk
*.fls
*.log
*.synctex.gz
*.toc
*.lot
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nzw0301
nzw0301 / strick-breaking-process.ipynb
Created March 13, 2016 11:16
alphaに応じた折った棒の総和の変化を可視化
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.