↓この続きです。 esu-ko.hatenablog.com
今回はアソシエーションルールに関してです。
アソシエーションルールはグラフ作成などではなく、
結果データを各指標やfrom/toで繰り返しソートしたくなります。
▼アソシエーションルールはこちら
使用するもの
ipywidget
では操作可能なテーブルが見つからなかったので、bokehを使うことにします。
bokehのデータテーブルは、カラムで自由にソート可能です。
基本的な使い方
bokehでデータを扱うためには専用のオブジェクトにする必要があります。
#表示するためのパーツ用 from bokeh.models.widgets import , TableColumn, DataTable #データソース用 from bokeh.models import ColumnDataSource #表示の操作よう from bokeh.plotting import output_notebook, show output_notebook() df = #適当なデータフレーム #データ1 source = ColumnDataSource(df) #データ2:カラム tc = [TableColumn(field = c,title=c) for c in df.columns]
TableColumn
のfieldとColumnDataSource
の絡む名で後ほどマッピングされます。
これをDataTable
に渡すことでGUIでソート可能なテーブルを出せます。
data_table = DataTable(source = source, columns = tc,width=600, height=500, fit_columns=True) show(data_table)