Instantly share code, notes, and snippets.

View api_test.py
import json
from http.server import HTTPServer, SimpleHTTPRequestHandler
class CustomHandler(SimpleHTTPRequestHandler):
def do_GET(self):
SimpleHTTPRequestHandler.do_GET(self)
print("===headers===\n", self.headers)
print("===path===\n", self.path)
def do_POST(self):
View autodiff_impl.py
# Ref. http://www.cs.cmu.edu/~wcohen/10-605/notes/autodiff.pdf
from collections import namedtuple
Assignment = namedtuple("Item", ("z", "g", "y_list"))
# f(x_1, x_2) = (2x_1 + x_2)^2
l = [Assignment(z="z1", g="add", y_list=["x1", "x1"]),
Assignment(z="z2", g="add", y_list=["z1", "x2"]),
Assignment(z="f", g="square", y_list=["z2"])]
View nfkc_compare.txt
# for Python 3.6
import unicodedata
# from 0 through 1,114,111 (https://docs.python.org/3.6/library/functions.html#chr)
for unicode_id in range(1114111):
char = chr(unicode_id)
normalized_char = unicodedata.normalize("NFKC", char)
if char != normalized_char:
if len(normalized_char) == 1:
code_point = ord(normalized_char)
View benchmark_pr58.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View kaggle_kernel_package.py
ImageHash 3.1
arrow 0.9.0
altair 1.2.0
tqdm 4.10.0
mlxtend 0.5.1.dev0
PyWavelets 0.5.0
pyLDAvis 2.0.0
TPOT 0.6.7
traitlets 4.3.1
funcy 1.7.2
View coincheckJPY.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View pca_tsne.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View recipe.apib
FORMAT: 1A
# レシピサイトWebAPIドキュメント
http://gotofritz.net/blog/weekly-challenge/restful-python-api-bottle/
## すべてのレシピのXMLを表示する [/recipes/]
### recipes_list [GET]
すべてのレシピのリストを返します。
View iris_xgboost.py
import numpy as np
import scipy as sp
import xgboost as xgb
from sklearn import datasets
from sklearn.metrics import confusion_matrix
from sklearn.grid_search import GridSearchCV
from sklearn.grid_search import RandomizedSearchCV
iris = datasets.load_iris()
trainX = iris.data[0::2,:]
View calculate_score.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
# File format : GROUPID,GOODSID,VIEWRATE,BUYRATE
# Usage : calculate_score.py target.csv predict.csv
def read_submit_file(submit_file):
viewrate = {}