Skip to content

Instantly share code, notes, and snippets.

View doraneko94's full-sized avatar

Shuntaro Ohno doraneko94

View GitHub Profile
randomize
shiai_num = 10000 ;shiai_numの数値と等しい回数の試合を行います。
;データ読み込み変数定義
dim b1,10
dim b2,10
dim b3,10
dim b4,10
dim st,10
dim std,10
dim bunt,10
@doraneko94
doraneko94 / Osero.py
Last active January 27, 2018 23:58
The code of analyzing Osero (reversi). Prease import functions.py.
import functions as fn
from time import sleep
scale = 6
kifu = {}
now = []
end = 0
t = 0
while end == 0:
board = fn.board_set(kifu, now, scale)
@doraneko94
doraneko94 / ROC_PR.py
Created February 2, 2018 14:38
This code generates ROC curve and PR curve, and also prints AUCs individually.
import math, random
from matplotlib import pyplot as plt
def normal_cdf(x, mu=0, sigma=1):
return (1 + math.erf((x - mu) / math.sqrt(2) / sigma)) / 2
def inverse_normal_cdf(p, mu=0, sigma=1, tolerance=0.00001):
if mu != 0 or sigma != 1:
return mu + sigma * inverse_normal_cdf(p, tolerance=tolerance)
@doraneko94
doraneko94 / assess.py
Last active December 1, 2018 20:31
The code of "Brier Score", "ePCP", "the separation plot". Please import from this file to your project. The "actual_outcome" is a list of real labels (0 or 1), and the "fitted_value" is a list of probabilities that the data's label is 1. This code requires "numpy" and "pandas".
from matplotlib import pyplot as plt
from matplotlib import patches
import pandas as pd
import numpy as np
def BrierScores(actual_outcome, fitted_value):
X = np.array(actual_outcome)
p = np.array(fitted_value)
B = sum((p-X)**2)/len(X)
return B
@doraneko94
doraneko94 / enigma.py
Last active July 4, 2018 07:48
The code of "Enigma".
import random
import sys
alpha = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
hand1 = 22 #Change
hand2 = 5 #Change
rot_state1 = 0 #Change
rot_state2 = 1 #Change
rot_state3 = 2 #Change
rot_state0 = 3 #Change
chr1 = 23 #Change
@doraneko94
doraneko94 / caesar.py
Last active November 6, 2018 06:55
Descrambler for Caesar cipher.
ALPHA = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
word = input("Please Enter Words: ")
for i in range(len(alpha)):
process = ""
for w in word:
if w in alpha:
n = alpha.index(w) + i
if n > 25:
@doraneko94
doraneko94 / double_pendulum.py
Created September 21, 2018 09:56
Double pendulum simulator.
import math, tkinter, time, sys
g = 9.8
m1 = 1
m2 = 1
l1 = 150
l2 = 150
dt = 0.1
theta1 = math.pi / 2
theta2 = math.pi / 2 #+ 0.02
@doraneko94
doraneko94 / caesar_dictionary.py
Last active November 6, 2018 06:54
The improved version of "caesar.py" using a list of 153,484 words. "dictionary.pkl" is available from http://ushitora.net/archives/456 .
import pickle
ALPHA = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
word = input("Please Enter Words: ")
def plus_i(i, w):
if w in alpha:
n = alpha.index(w) + i
@doraneko94
doraneko94 / myfish.py
Created November 25, 2018 22:04
"Hey, that's my fish!"-ish CUI game. Because this game is my study and not user-friendly, please buy this board game or official App if you want to really enjoy "Hey, that's my fish!"
import random
alpha = ["A", "B", "C", "D"]
fishes = [1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,3,3]
f = random.sample(fishes, len(fishes))
@doraneko94
doraneko94 / partial_dependence.py
Last active December 7, 2018 01:50
Calculating partial dependence of any classifier which has an attribute of "n_features_" and "n_classes_".
import numpy as np
from scipy.stats.mstats import mquantiles
from math import sqrt, ceil
from matplotlib import pyplot as plt
def _grid_from_X(X, percentiles=(0.05, 0.95), grid_resolution=100):
if len(percentiles) != 2:
raise ValueError('percentile must be tuple of len 2')
if not all(0. <= x <= 1. for x in percentiles):