n * mのグラフを書く
row, col = 10, 3 fig = plt.figure(figsize=(col * 5, row * 4)) for i, c in enumerate(df.columns): ax = fig.add_subplot(row, col, i + 1)
いつもの円グラフ
s.plot.pie(pctdistance=0.6, labeldistance=0.3, textprops={'color': "white", 'weight': "bold", 'fontsize': 12}, wedgeprops={'linewidth': 2,'edgecolor':"white"},)
自分流jupyter notebookの1セル目
import collections import pathlib # データ処理周り import numpy as np import pandas as pd from IPython.core.display import display # 可視化ライブラリ import matplotlib.pyplot as plt from matplotlib import cm # colormap import seaborn as sns %matplotlib inline # pandasのwarningが邪魔なので import warnings warnings.filterwarnings('ignore') # options # pd.set_option('display.max_columns', 50) plt.style.use('ggplot')
いつものHML分析
d = access_features['count'].sort_values().reset_index() d.columns = ['base_index', 'count'] d = d.reset_index() from sklearn.cluster import KMeans from matplotlib import cm kmeans = KMeans(n_clusters=3) kmeans.fit(d[['count']]) d.loc[:, 'cluster'] = kmeans.labels_ fig, ax = plt.subplots() colors = cm.Accent.colors for i in range(3): target = d[d['cluster'] == i] ax.scatter(x=target['index'], y=target['count'], c=colors[i]
pandasで日時周り
df
にtime
カラムがあることを想定
文字列 -> datetime型
time
が2017-01-01
とかの文字列だったとき
pd.to_datatime(df['time'])
でだいたいよしなにparseしてくれる
unixtime -> datetime型
time
がunixtimeだったとき
pd.to_datatime(df['time'], unit='s')
一部情報を取り出す(日付、月、時間等)
datetime = pd.to_datatime(df['time']) datetime.dt.hour
数百字のテキストを分類/クラスタリングしてみる with Keras
参考文献メモ。
分類
- ベース: Sequence Classification with LSTM Recurrent Neural Networks in Python with Keras - Machine Learning Mastery
- python - Keras LSTM multiclass classification - Stack Overflow
短文ならLSTM, 長文ならRNNが良いという噂。
クラスタリングするなら
- 【ICML読み会】Unsupervised Deep Embedding for Clustering Analysis - SSSSLIDE
- Unsupervised Deep Embedding for Clustering Analysis
色々
Recursive AutoEncoder
LSTMを理解する
KerasでLSTM AutoEncoder
PyCharmでRoot以外にもPythonPathを追加したい時
PyCharm: 2017.1バージョン
Preference > Project: