systemctl の service の編集

以下の方法で、vi でも systemctl の設定を編集できる # systemctl stop app@service # export SYSTEMD_EDITOR="/usr/bin/vi" # systemctl edit --full app@service enakai00.hatenablog.com

pandas の full outer join

df = pd.DataFrame(np.random.randint(0,100,size=(3, 4)), columns=list('ABCD')) df['_index'] = 1 pd.merge(df[['_index', 'A']], df[['_index','B']], how='outer', on='_index') df.drop(columns=['_index'], inplace=True) stackoverflow.com

get_dummies を逆変換する方法

In [1]: import pandas as pd In [2]: s = pd.Series(['a', 'b', 'a', 'c']) In [3]: s Out[3]: 0 a 1 b 2 a 3 c dtype: object In [4]: dummies = pd.get_dummies(s) In [5]: dummies Out[5]: a b c 0 1 0 0 1 0 1 0 2 1 0 0 3 0 0 1 In [6]: s2 = dummies.…

curl で timeoutしたときのトラブルシューティング

以下のコマンドで一旦確認。 アプリケーションがある場合 curl -v http://... telnet telnet XXX.XXX.XXX.XXX 443 # 接続成功 telnet XXX.XXX.XXX.XXX 443 Trying XXX.XXX.XXX.XXX... Connected to XXX.XXX.XXX.XXX. Escape character is '^]'. # 接続失敗 t…

pandas の Time Series の分析

towardsdatascience.com pandas.pydata.org stackoverflow.com statsmodel の分析も結構使えそう www.statsmodels.org

ネットワークの bottleneck 診査

likegeeks.com

tffm レコメンド性能高そう

github.com $ pip install tffm order とかよく挙動がわからない。パラメータがあるけど。 この辺、レコメンドエンジンに使えそう。 from sklearn.model_selection import train_test_split X_tr, X_te, y_tr, y_te = train_test_split(df.values, df['tfidf…

MySQL のテーブル更新情報

information_schema.tables に色々情報詰まってそう mysql> SELECT TABLE_NAME,UPDATE_TIME FROM information_schema.tables WHERE TABLE_SCHEMA = 'dbname'; +---------------------+---------------------+ | TABLE_NAME | UPDATE_TIME | +---------------…

xgboost のstratifiedkfold は使っても意味ないのか

xgboost の training にstratifiedkfoldを使ってみた。 from xgboost import XGBClassifier from sklearn.model_selection import GridSearchCV from sklearn.model_selection import StratifiedKFold from sklearn.metrics import accuracy_score param_gri…

feature enginearing のカテゴリ系

# 量で分割 --> categorical (pd.Interval) df['price_range'] = pd.qcut(allfeat['price'], 5) # 値で分割 --> categorical (pd.Interval) df['age_range'] = pd.qcut(allfeat['age'], 5) >>> iv = pd.Interval(left=0, right=5) >>> iv Interval(0, 5, clo…

アクセスログの統計処理

httpd.apache.org LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D" from datetime import (datetime, date, timedelta) import re import pandas as pd import numpy as np from IPython.display import display, HTML from p…

目盛りの訳は locator だった...

python の plt で、時間の目盛りをもっと細かく取りたいと思った。 目盛りは scale でなく、locatorの方が正しいらしい。 stackoverflow.com qiita.com

LSTM を書いてみた

出典元)Python 機械学習プログラミング https://www.amazon.co.jp/dp/4295003379/ tar 解凍 import tarfile with tarfile.open('aclImdb_v1.tar.gz', 'r:gz') as tar: tar.extractall() ai.stanford.edu データ作成 import pandas as pd import os base_pat…

str.translate() が便利

trans_dict = ('0123456789', 'abcdefghij') a = {ord(i):ord(h) for i, h in zip(*trans_dict)} '0120-333-666'.translate(a) 'abca-ddd-ggg' qiita.com

データ分析の流れ

準備 Prepare Problem a) Load libraries b) Load dataset Summarize Data a) Descriptive statistics b) Data visualizations Prepare Data a) Data Cleaning b) Feature Selection c) Data Transforms (Normalize,...) direcotory構成 echo '.DS_Store .ip…

Kaggle の過去問と解法集

Kaggle Past Competitions www.chioka.in github.com machinelearningmastery.com

python の future の使い方

import concurrent.futures import os score_list = [] def worker(my_random_seed): model = CatBoostClassifier( iterations=300, learning_rate=0.1, random_seed=my_random_seed ) model.fit( X_train, y_train, cat_features=cat_features, eval_set=(X…

機械学習の黄色本 について

機械学習の黄色本 www.amazon.co.jp https://www.amazon.co.jp/dp/4621061240www.amazon.co.jp Web PDF https://www.microsoft.com/en-us/research/uploads/prod/2006/01/Bishop-Pattern-Recognition-and-Machine-Learning-2006.pdf 演習問題 (www) の解答 h…

emsembling の有名記事

Kaggle Ensembling Guide | MLWave github.com github.com

t-SNE の有名記事

github.com Comparison of Manifold Learning methods — scikit-learn 0.20.2 documentation distill.pub lvdmaaten.github.io t-SNE: The effect of various perplexity values on the shape — scikit-learn 0.20.2 documentation Interaction Practical Le…

Jupyter Notebook の tips

www.dataquest.io おまけ kaggletils github.com

CoreOSとかいうもの

アプリケーションは基本 container で立ち上げる前提のOS っぽい。便利そうだけど、複雑。 https://coreos.com/ignition/docs/latest/what-is-ignition.html

--super-read-only の時に、MySQLをupdateする方法

mysql> CREATE DATABASE `test` DEFAULT CHARSET utf8mb4; ERROR 1290 (HY000): The MySQL server is running with the --super-read-only option so it cannot execute this statement SET GLOBAL super_read_only= 0;

docker の shell で変な表示になる問題

$ docker exec -it jenkins env COLUMNS=200 LINES=50 TERM=xterm bash qiita.com

CentOS の filesystem の記事

パート I. ファイルシステム - Red Hat Customer Portal

Hayperparameter tuning の便利サイト

3.2. Tuning the hyper-parameters of an estimator — scikit-learn 0.20.1 documentation fastml.com www.analyticsvidhya.com

mean encoding の方法、Kfold

import pandas as pd import numpy as np index_cols = ['shop_id', 'item_id', 'cnt'] global_mean = 0.2 df = pd.read_csv(filename) # groupby した gb = df.groupby(index_cols,as_index=False).agg({'cnt':{'target':'sum'}}) #fix column names gb.col…

MySQL のトランザクション 消化ステータス確認

KILLED のプロセスが transaction 掴んで焦った話。KILLED を消すためにmysqldを強制終了すると、dead lock が発生するのでやめたほうがいい。 以下のメッセージが出て追加deleteができなかった。。 transaction mysql Lock wait timeout exceeded; try rest…

rank, cluster のscoring 優良記事

rank https://icml.cc/2015/wp-content/uploads/2015/06/icml_ranking.pdf https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/MSR-TR-2010-82.pdf The Lemur Project / Wiki / RankLib Learning to Rank Overviewwellecks.wordpress.com…

binary の logloss と auc

Binary Class の測定 logloss l_pred = [0.5, 0.5, 0.5, 0.5] l_label = [0, 0, 0, 0] def logloss(l_pred, l_label): n = len(l_pred) score = 0 for t in range(n): i = l_pred[t] k = l_label[t] score += k * np.log(i) + (1 - k) * np.log(i) return - …