Skip to content

Instantly share code, notes, and snippets.

View ytakashina's full-sized avatar
🌊

Yuya Takashina ytakashina

🌊
View GitHub Profile
@ytakashina
ytakashina / pip
Last active August 17, 2017 01:25
pip install tqdm numpy cupy scipy scikit-learn pandas seaborn bokeh graphviz pystan chainer tensorflow keras
@ytakashina
ytakashina / plotly-network.py
Created August 25, 2017 11:12
plotly でネットワークを描画しようとした
import plotly
import plotly.offline as py
import plotly.graph_objs as go
plotly.offline.init_notebook_mode(connected=True)
# pos = nx.spring_layout(graph)
pos = nx.circular_layout(graph)
Xv = [v[0] for v in pos.values()]
Yv = [v[1] for v in pos.values()]
@ytakashina
ytakashina / setup.sh
Last active September 25, 2017 12:30
if [ "$(id -u)" != "0" ]; then
echo "Installation was failed. Run as a super user!" 1>&2
return 1
fi
apt update && apt -y upgrade
apt install -y git vim w3m wget tmux vsftpd graphviz openssh-server build-essential
apt upgrade gcc cmake
@ytakashina
ytakashina / jupyter-import.md
Last active November 16, 2017 07:27
Jupyter notebook の import 用 snippets 。
  • data
import tqdm
import pickle
import numpy as np
import scipy
import sklearn
import pandas as pd
import plotly
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
H, W = map(int, input().split())
maze = []
distances = []
n_aisle = 0
for i in range(H):
row = input()
maze.append(row)
distances.append([100000000 for i in range(W)])
n_aisle += row.count('.')
$ pycodestyle . | cut -d: -f1 | sort | uniq | xargs autopep8 -i --ignore E501
@ytakashina
ytakashina / bayesian_networks.py
Last active April 8, 2018 02:36
Discrete bayesian_networks
def counts_given_parents(adj, X):
n, d = X.shape
states_list = [set(col) for col in X.T]
pstates_list = [Counter(map(tuple, X[:, adj.T[i]])).keys() for i in range(d)]
counts = {i: {j: {k: np.count_nonzero(X[:, i] == k)
for k in states_list[i]}
for j in pstates_list[i]}
for i in range(d)}
return counts

Networks

g = ig.Graph.Adjacency((pre_h_pred != 0).tolist())
g.es['weight'] = pre_h_pred[pre_h_pred.nonzero()]
g.vs['label'] = list(geos.values())
layt = g.layout('kk', dim=2)
N = len(pre_h_pred)
Xn = [layt[n][0] for n in range(N)]
Yn = [layt[n][1] for n in range(N)]