幹葉図とは、
4-6. 幹葉表示 | 統計学の
この
結果を
図の使いどころ
統計検定の
幹葉表示 - Wikipedia
また、
幹葉表示
stem and leaf representation
とは、個別の 観測値の 適当な ケタまでを 「幹」と して その 次の ケタの 数を 「葉」と して 簡易な ヒストグラムの 形に 整理していく ものである。
個人的には、
Python で
インストール
pip で
コマンド
python3 -m pip install -U stemgraphic
OUTPUT
Installing collected packages: docopt, seaborn, stemgraphic Successfully installed docopt-0.6.2 seaborn-0.9.0 stemgraphic-0.7.2
動かしてみる
stemgraphic quickstart with numbers — stemgraphic 0.6.1 documentation を
Sample は、
今回は、
数値データを 幹葉表示する
%matplotlib inline import pandas as pd from stemgraphic import stem_graphic
# Sample データの読みこみ df = pd.read_csv('https://raw.githubusercontent.com/dionresearch/stemgraphic/master/datasets/iris.csv') df.describe()
sepal_length | sepal_width | petal_length | petal_width | |
---|---|---|---|---|
count | 150.000000 | 150.000000 | 150.000000 | 150.000000 |
mean | 5.843333 | 3.054000 | 3.758667 | 1.198667 |
std | 0.828066 | 0.433594 | 1.764420 | 0.763161 |
min | 4.300000 | 2.000000 | 1.000000 | 0.100000 |
25% | 5.100000 | 2.800000 | 1.600000 | 0.300000 |
50% | 5.800000 | 3.000000 | 4.350000 | 1.300000 |
75% | 6.400000 | 3.300000 | 5.100000 | 1.800000 |
max | 7.900000 | 4.400000 | 6.900000 | 2.500000 |
stem_graphic(df['petal_width'])
ヒートマップ表示
ヒートマップを
from stemgraphic.graphic import heatmap heatmap(df['petal_width'])
( 0 1 2 3 4 5 6 7 8 9 stem 1 6 0 0 0 0 0 0 0 0 0 2 28 0 0 0 0 0 0 0 0 0 3 7 0 0 0 0 0 0 0 0 0 4 7 0 0 0 0 0 0 0 0 0 5 1 0 0 0 0 0 0 0 0 0 6 1 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 10 7 0 0 0 0 0 0 0 0 0 11 3 0 0 0 0 0 0 0 0 0 12 5 0 0 0 0 0 0 0 0 0 13 13 0 0 0 0 0 0 0 0 0 14 8 0 0 0 0 0 0 0 0 0 15 12 0 0 0 0 0 0 0 0 0 16 4 0 0 0 0 0 0 0 0 0 17 2 0 0 0 0 0 0 0 0 0 18 12 0 0 0 0 0 0 0 0 0 19 5 0 0 0 0 0 0 0 0 0 20 6 0 0 0 0 0 0 0 0 0 21 6 0 0 0 0 0 0 0 0 0 22 3 0 0 0 0 0 0 0 0 0 23 8 0 0 0 0 0 0 0 0 0 24 3 0 0 0 0 0 0 0 0 0 25 3 0 0 0 0 0 0 0 0 0, 0.1, <matplotlib.axes._subplots.AxesSubplot at 0x10a4215c0>)
データの
濃度曲線を 描画する
濃度曲線を
from stemgraphic.graphic import density_plot density_plot(df['petal_width'])
(<matplotlib.figure.Figure at 0x10d15c438>, <matplotlib.axes._subplots.AxesSubplot at 0x10cca66d8>)
メソッドの
# hist= True でヒストグラムを追加、rug=True ラグを追加 from stemgraphic.graphic import density_plot density_plot(df['petal_width'], hist=True, limit_var=True, rug=True)
(<matplotlib.figure.Figure at 0x10ef79518>, <matplotlib.axes._subplots.AxesSubplot at 0x10a1ab898>)
以下に、
stemgraphic/notebooks at master · dionresearch/stemgraphic
カテゴリデータ、
以上です。
コメント