私はコミットログの書き方に悩む英語の苦手な人間である。実際、似たような人は世の中に結構いるようで、頻出単語を集計したりまとめたものは既にあって役に立つのだけれど、これらはあくまで単語の話であり、具体的な文を構成する過程でやっぱり困る部分がかなりあった。
要するに、どういう時にどういう文が使われているのか、ということを示した例文集が欲しいのである。ググると他にも「例文集があればいいのに」みたいな声はあるくせして、しかし誰も作ろうとしない。何なんだお前ら。それじゃ私が楽できないじゃないか。
p(t| x, {\bf x}, {\bf t}) = N(t| m(x), s^2(x)) (1.69) |
私はコミットログの書き方に悩む英語の苦手な人間である。実際、似たような人は世の中に結構いるようで、頻出単語を集計したりまとめたものは既にあって役に立つのだけれど、これらはあくまで単語の話であり、具体的な文を構成する過程でやっぱり困る部分がかなりあった。
要するに、どういう時にどういう文が使われているのか、ということを示した例文集が欲しいのである。ググると他にも「例文集があればいいのに」みたいな声はあるくせして、しかし誰も作ろうとしない。何なんだお前ら。それじゃ私が楽できないじゃないか。
import pandas as pd | |
import numpy as np | |
""" | |
http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-munging/target-encoding.html | |
""" | |
class FreqencyEncoder: | |
"""Encode categorical integer features to numerical features correspondig to its frequency.""" |
def load_train_data(): | |
paths = sorted(glob.glob('../data/train/*.csv.gz')) | |
with Pool() as p: | |
df = pd.concat(p.map(read_csv, paths), ignore_index=True, axis=0, copy=False) | |
logger.info('data size {}'.format(df.shape)) | |
return df | |
def load_val_data(): |
def negative_down_sampling(data, random_state, target_variable): | |
positive_data = data[data[target_variable] == 1] | |
positive_ratio = float(len(positive_data)) / len(data) | |
negative_data = data[data[target_variable] == 0].sample( | |
frac=positive_ratio / (1 - positive_ratio), random_state=random_state) | |
return pd.concat([positive_data, negative_data]) | |
def multi_class_downsampling(data, random_state, target_variable): | |
data0 = data[data[target_variable] == 0] |
for cols in ATTRIBUTION_CATEGORIES: | |
# Aggregation function | |
def rate_calculation(x): | |
"""Calculate the attributed rate. Scale by confidence""" | |
rate = x.sum() / float(x.count()) | |
conf = np.min([1, np.log(x.count()) / log_group]) | |
return rate * conf | |
# Perform the merge | |
X_train = X_train.merge( |
# set class weights | |
classdist = pd.value_counts(val['target']) | |
weights = {i: round(np.sum(classdist) / classdist[i]) for i in classdist.index} |
arr = np.empty((0,3), int) | |
arr = np.append(arr, np.array([[1, 2, 3],[4, 5, 6]]), axis=0) | |
arr = np.append(arr, np.array([[7, 8, 9],[10, 11, 12]]), axis=0) | |
arr.reshape(-1,2,3) | |
>array([[[ 1, 2, 3], | |
> [ 4, 5, 6]], | |
> [[ 7, 8, 9], | |
> [10, 11, 12]]]) |
""" | |
クラスごとにサブプロットで散布図見た。 | |
""" | |
for Keys, labels in zip(SampleKeys, classlabels): | |
w = 10 | |
n = len(Keys) | |
h = math.floor(n/w) if n%w==0 else math.floor(n/w) + 1 | |
fig, ax = plt.subplots(h, w, figsize=(15, 2*h)) | |
ax = ax.reshape(-1,) |