{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# daru + rbplotly + statsample のデモ\n",
"\n",
"https://archive.ics.uci.edu/ml/datasets/wine\n",
"←このデータから、赤ワインの評価と白ワインの評価に差があるかを調べる"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"require 'daru'\n",
"require 'rbplotly'\n",
"require 'daru/plotly'\n",
"require 'statsample'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## csvを読み込む"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
" \n",
" Daru::DataFrame(10x13) | \n",
"
\n",
"\n",
" \n",
" \n",
" | \n",
" \n",
" type | \n",
" \n",
" fixed acidity | \n",
" \n",
" volatile acidity | \n",
" \n",
" citric acid | \n",
" \n",
" residual sugar | \n",
" \n",
" chlorides | \n",
" \n",
" free sulfur dioxide | \n",
" \n",
" total sulfur dioxide | \n",
" \n",
" density | \n",
" \n",
" pH | \n",
" \n",
" sulphates | \n",
" \n",
" alcohol | \n",
" \n",
" quality | \n",
" \n",
"
\n",
" \n",
"\n",
" \n",
" \n",
" 0 | \n",
" \n",
" red | \n",
" \n",
" 7.4 | \n",
" \n",
" 0.7 | \n",
" \n",
" 0 | \n",
" \n",
" 1.9 | \n",
" \n",
" 0.076 | \n",
" \n",
" 11 | \n",
" \n",
" 34 | \n",
" \n",
" 0.9978 | \n",
" \n",
" 3.51 | \n",
" \n",
" 0.56 | \n",
" \n",
" 9.4 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
" \n",
" 1 | \n",
" \n",
" red | \n",
" \n",
" 7.8 | \n",
" \n",
" 0.88 | \n",
" \n",
" 0 | \n",
" \n",
" 2.6 | \n",
" \n",
" 0.098 | \n",
" \n",
" 25 | \n",
" \n",
" 67 | \n",
" \n",
" 0.9968 | \n",
" \n",
" 3.2 | \n",
" \n",
" 0.68 | \n",
" \n",
" 9.8 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
" \n",
" 2 | \n",
" \n",
" red | \n",
" \n",
" 7.8 | \n",
" \n",
" 0.76 | \n",
" \n",
" 0.04 | \n",
" \n",
" 2.3 | \n",
" \n",
" 0.092 | \n",
" \n",
" 15 | \n",
" \n",
" 54 | \n",
" \n",
" 0.997 | \n",
" \n",
" 3.26 | \n",
" \n",
" 0.65 | \n",
" \n",
" 9.8 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
" \n",
" 3 | \n",
" \n",
" red | \n",
" \n",
" 11.2 | \n",
" \n",
" 0.28 | \n",
" \n",
" 0.56 | \n",
" \n",
" 1.9 | \n",
" \n",
" 0.075 | \n",
" \n",
" 17 | \n",
" \n",
" 60 | \n",
" \n",
" 0.998 | \n",
" \n",
" 3.16 | \n",
" \n",
" 0.58 | \n",
" \n",
" 9.8 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
" \n",
" 4 | \n",
" \n",
" red | \n",
" \n",
" 7.4 | \n",
" \n",
" 0.7 | \n",
" \n",
" 0 | \n",
" \n",
" 1.9 | \n",
" \n",
" 0.076 | \n",
" \n",
" 11 | \n",
" \n",
" 34 | \n",
" \n",
" 0.9978 | \n",
" \n",
" 3.51 | \n",
" \n",
" 0.56 | \n",
" \n",
" 9.4 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
" \n",
" 5 | \n",
" \n",
" red | \n",
" \n",
" 7.4 | \n",
" \n",
" 0.66 | \n",
" \n",
" 0 | \n",
" \n",
" 1.8 | \n",
" \n",
" 0.075 | \n",
" \n",
" 13 | \n",
" \n",
" 40 | \n",
" \n",
" 0.9978 | \n",
" \n",
" 3.51 | \n",
" \n",
" 0.56 | \n",
" \n",
" 9.4 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
" \n",
" 6 | \n",
" \n",
" red | \n",
" \n",
" 7.9 | \n",
" \n",
" 0.6 | \n",
" \n",
" 0.06 | \n",
" \n",
" 1.6 | \n",
" \n",
" 0.069 | \n",
" \n",
" 15 | \n",
" \n",
" 59 | \n",
" \n",
" 0.9964 | \n",
" \n",
" 3.3 | \n",
" \n",
" 0.46 | \n",
" \n",
" 9.4 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
" \n",
" 7 | \n",
" \n",
" red | \n",
" \n",
" 7.3 | \n",
" \n",
" 0.65 | \n",
" \n",
" 0 | \n",
" \n",
" 1.2 | \n",
" \n",
" 0.065 | \n",
" \n",
" 15 | \n",
" \n",
" 21 | \n",
" \n",
" 0.9946 | \n",
" \n",
" 3.39 | \n",
" \n",
" 0.47 | \n",
" \n",
" 10 | \n",
" \n",
" 7 | \n",
" \n",
"
\n",
" \n",
" \n",
" 8 | \n",
" \n",
" red | \n",
" \n",
" 7.8 | \n",
" \n",
" 0.58 | \n",
" \n",
" 0.02 | \n",
" \n",
" 2 | \n",
" \n",
" 0.073 | \n",
" \n",
" 9 | \n",
" \n",
" 18 | \n",
" \n",
" 0.9968 | \n",
" \n",
" 3.36 | \n",
" \n",
" 0.57 | \n",
" \n",
" 9.5 | \n",
" \n",
" 7 | \n",
" \n",
"
\n",
" \n",
" \n",
" 9 | \n",
" \n",
" red | \n",
" \n",
" 7.5 | \n",
" \n",
" 0.5 | \n",
" \n",
" 0.36 | \n",
" \n",
" 6.1 | \n",
" \n",
" 0.071 | \n",
" \n",
" 17 | \n",
" \n",
" 102 | \n",
" \n",
" 0.9978 | \n",
" \n",
" 3.35 | \n",
" \n",
" 0.8 | \n",
" \n",
" 10.5 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
"\n",
" \n",
"
"
],
"text/plain": [
"#\n",
" type fixed acid volatile a citric aci residual s chlorides free sulfu total sulf density pH sulphates alcohol quality\n",
" 0 red 7.4 0.7 0 1.9 0.076 11 34 0.9978 3.51 0.56 9.4 5\n",
" 1 red 7.8 0.88 0 2.6 0.098 25 67 0.9968 3.2 0.68 9.8 5\n",
" 2 red 7.8 0.76 0.04 2.3 0.092 15 54 0.997 3.26 0.65 9.8 5\n",
" 3 red 11.2 0.28 0.56 1.9 0.075 17 60 0.998 3.16 0.58 9.8 6\n",
" 4 red 7.4 0.7 0 1.9 0.076 11 34 0.9978 3.51 0.56 9.4 5\n",
" 5 red 7.4 0.66 0 1.8 0.075 13 40 0.9978 3.51 0.56 9.4 5\n",
" 6 red 7.9 0.6 0.06 1.6 0.069 15 59 0.9964 3.3 0.46 9.4 5\n",
" 7 red 7.3 0.65 0 1.2 0.065 15 21 0.9946 3.39 0.47 10 7\n",
" 8 red 7.8 0.58 0.02 2 0.073 9 18 0.9968 3.36 0.57 9.5 7\n",
" 9 red 7.5 0.5 0.36 6.1 0.071 17 102 0.9978 3.35 0.8 10.5 5"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wine = Daru::DataFrame.from_csv('./winequality-both.csv')\n",
"wine.head 10 # 最初の10行を表示"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 赤ワインと白ワインを分ける"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[\"red\", \"white\"]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wine['type'].uniq.to_a"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" Daru::DataFrame(10x13) | \n",
"
\n",
"\n",
" \n",
" \n",
" | \n",
" \n",
" type | \n",
" \n",
" fixed acidity | \n",
" \n",
" volatile acidity | \n",
" \n",
" citric acid | \n",
" \n",
" residual sugar | \n",
" \n",
" chlorides | \n",
" \n",
" free sulfur dioxide | \n",
" \n",
" total sulfur dioxide | \n",
" \n",
" density | \n",
" \n",
" pH | \n",
" \n",
" sulphates | \n",
" \n",
" alcohol | \n",
" \n",
" quality | \n",
" \n",
"
\n",
" \n",
"\n",
" \n",
" \n",
" 0 | \n",
" \n",
" red | \n",
" \n",
" 7.4 | \n",
" \n",
" 0.7 | \n",
" \n",
" 0 | \n",
" \n",
" 1.9 | \n",
" \n",
" 0.076 | \n",
" \n",
" 11 | \n",
" \n",
" 34 | \n",
" \n",
" 0.9978 | \n",
" \n",
" 3.51 | \n",
" \n",
" 0.56 | \n",
" \n",
" 9.4 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
" \n",
" 1 | \n",
" \n",
" red | \n",
" \n",
" 7.8 | \n",
" \n",
" 0.88 | \n",
" \n",
" 0 | \n",
" \n",
" 2.6 | \n",
" \n",
" 0.098 | \n",
" \n",
" 25 | \n",
" \n",
" 67 | \n",
" \n",
" 0.9968 | \n",
" \n",
" 3.2 | \n",
" \n",
" 0.68 | \n",
" \n",
" 9.8 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
" \n",
" 2 | \n",
" \n",
" red | \n",
" \n",
" 7.8 | \n",
" \n",
" 0.76 | \n",
" \n",
" 0.04 | \n",
" \n",
" 2.3 | \n",
" \n",
" 0.092 | \n",
" \n",
" 15 | \n",
" \n",
" 54 | \n",
" \n",
" 0.997 | \n",
" \n",
" 3.26 | \n",
" \n",
" 0.65 | \n",
" \n",
" 9.8 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
" \n",
" 3 | \n",
" \n",
" red | \n",
" \n",
" 11.2 | \n",
" \n",
" 0.28 | \n",
" \n",
" 0.56 | \n",
" \n",
" 1.9 | \n",
" \n",
" 0.075 | \n",
" \n",
" 17 | \n",
" \n",
" 60 | \n",
" \n",
" 0.998 | \n",
" \n",
" 3.16 | \n",
" \n",
" 0.58 | \n",
" \n",
" 9.8 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
" \n",
" 4 | \n",
" \n",
" red | \n",
" \n",
" 7.4 | \n",
" \n",
" 0.7 | \n",
" \n",
" 0 | \n",
" \n",
" 1.9 | \n",
" \n",
" 0.076 | \n",
" \n",
" 11 | \n",
" \n",
" 34 | \n",
" \n",
" 0.9978 | \n",
" \n",
" 3.51 | \n",
" \n",
" 0.56 | \n",
" \n",
" 9.4 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
" \n",
" 5 | \n",
" \n",
" red | \n",
" \n",
" 7.4 | \n",
" \n",
" 0.66 | \n",
" \n",
" 0 | \n",
" \n",
" 1.8 | \n",
" \n",
" 0.075 | \n",
" \n",
" 13 | \n",
" \n",
" 40 | \n",
" \n",
" 0.9978 | \n",
" \n",
" 3.51 | \n",
" \n",
" 0.56 | \n",
" \n",
" 9.4 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
" \n",
" 6 | \n",
" \n",
" red | \n",
" \n",
" 7.9 | \n",
" \n",
" 0.6 | \n",
" \n",
" 0.06 | \n",
" \n",
" 1.6 | \n",
" \n",
" 0.069 | \n",
" \n",
" 15 | \n",
" \n",
" 59 | \n",
" \n",
" 0.9964 | \n",
" \n",
" 3.3 | \n",
" \n",
" 0.46 | \n",
" \n",
" 9.4 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
" \n",
" 7 | \n",
" \n",
" red | \n",
" \n",
" 7.3 | \n",
" \n",
" 0.65 | \n",
" \n",
" 0 | \n",
" \n",
" 1.2 | \n",
" \n",
" 0.065 | \n",
" \n",
" 15 | \n",
" \n",
" 21 | \n",
" \n",
" 0.9946 | \n",
" \n",
" 3.39 | \n",
" \n",
" 0.47 | \n",
" \n",
" 10 | \n",
" \n",
" 7 | \n",
" \n",
"
\n",
" \n",
" \n",
" 8 | \n",
" \n",
" red | \n",
" \n",
" 7.8 | \n",
" \n",
" 0.58 | \n",
" \n",
" 0.02 | \n",
" \n",
" 2 | \n",
" \n",
" 0.073 | \n",
" \n",
" 9 | \n",
" \n",
" 18 | \n",
" \n",
" 0.9968 | \n",
" \n",
" 3.36 | \n",
" \n",
" 0.57 | \n",
" \n",
" 9.5 | \n",
" \n",
" 7 | \n",
" \n",
"
\n",
" \n",
" \n",
" 9 | \n",
" \n",
" red | \n",
" \n",
" 7.5 | \n",
" \n",
" 0.5 | \n",
" \n",
" 0.36 | \n",
" \n",
" 6.1 | \n",
" \n",
" 0.071 | \n",
" \n",
" 17 | \n",
" \n",
" 102 | \n",
" \n",
" 0.9978 | \n",
" \n",
" 3.35 | \n",
" \n",
" 0.8 | \n",
" \n",
" 10.5 | \n",
" \n",
" 5 | \n",
" \n",
"
\n",
" \n",
"\n",
" \n",
"
"
],
"text/plain": [
"#\n",
" type fixed acid volatile a citric aci residual s chlorides free sulfu total sulf density pH sulphates alcohol quality\n",
" 0 red 7.4 0.7 0 1.9 0.076 11 34 0.9978 3.51 0.56 9.4 5\n",
" 1 red 7.8 0.88 0 2.6 0.098 25 67 0.9968 3.2 0.68 9.8 5\n",
" 2 red 7.8 0.76 0.04 2.3 0.092 15 54 0.997 3.26 0.65 9.8 5\n",
" 3 red 11.2 0.28 0.56 1.9 0.075 17 60 0.998 3.16 0.58 9.8 6\n",
" 4 red 7.4 0.7 0 1.9 0.076 11 34 0.9978 3.51 0.56 9.4 5\n",
" 5 red 7.4 0.66 0 1.8 0.075 13 40 0.9978 3.51 0.56 9.4 5\n",
" 6 red 7.9 0.6 0.06 1.6 0.069 15 59 0.9964 3.3 0.46 9.4 5\n",
" 7 red 7.3 0.65 0 1.2 0.065 15 21 0.9946 3.39 0.47 10 7\n",
" 8 red 7.8 0.58 0.02 2 0.073 9 18 0.9968 3.36 0.57 9.5 7\n",
" 9 red 7.5 0.5 0.36 6.1 0.071 17 102 0.9978 3.35 0.8 10.5 5"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"reds = wine.where(wine['type'].eq('red'))\n",
"reds.head 10"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" Daru::DataFrame(10x13) | \n",
"
\n",
"\n",
" \n",
" \n",
" | \n",
" \n",
" type | \n",
" \n",
" fixed acidity | \n",
" \n",
" volatile acidity | \n",
" \n",
" citric acid | \n",
" \n",
" residual sugar | \n",
" \n",
" chlorides | \n",
" \n",
" free sulfur dioxide | \n",
" \n",
" total sulfur dioxide | \n",
" \n",
" density | \n",
" \n",
" pH | \n",
" \n",
" sulphates | \n",
" \n",
" alcohol | \n",
" \n",
" quality | \n",
" \n",
"
\n",
" \n",
"\n",
" \n",
" \n",
" 1599 | \n",
" \n",
" white | \n",
" \n",
" 7 | \n",
" \n",
" 0.27 | \n",
" \n",
" 0.36 | \n",
" \n",
" 20.7 | \n",
" \n",
" 0.045 | \n",
" \n",
" 45 | \n",
" \n",
" 170 | \n",
" \n",
" 1.001 | \n",
" \n",
" 3 | \n",
" \n",
" 0.45 | \n",
" \n",
" 8.8 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
" \n",
" 1600 | \n",
" \n",
" white | \n",
" \n",
" 6.3 | \n",
" \n",
" 0.3 | \n",
" \n",
" 0.34 | \n",
" \n",
" 1.6 | \n",
" \n",
" 0.049 | \n",
" \n",
" 14 | \n",
" \n",
" 132 | \n",
" \n",
" 0.994 | \n",
" \n",
" 3.3 | \n",
" \n",
" 0.49 | \n",
" \n",
" 9.5 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
" \n",
" 1601 | \n",
" \n",
" white | \n",
" \n",
" 8.1 | \n",
" \n",
" 0.28 | \n",
" \n",
" 0.4 | \n",
" \n",
" 6.9 | \n",
" \n",
" 0.05 | \n",
" \n",
" 30 | \n",
" \n",
" 97 | \n",
" \n",
" 0.9951 | \n",
" \n",
" 3.26 | \n",
" \n",
" 0.44 | \n",
" \n",
" 10.1 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
" \n",
" 1602 | \n",
" \n",
" white | \n",
" \n",
" 7.2 | \n",
" \n",
" 0.23 | \n",
" \n",
" 0.32 | \n",
" \n",
" 8.5 | \n",
" \n",
" 0.058 | \n",
" \n",
" 47 | \n",
" \n",
" 186 | \n",
" \n",
" 0.9956 | \n",
" \n",
" 3.19 | \n",
" \n",
" 0.4 | \n",
" \n",
" 9.9 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
" \n",
" 1603 | \n",
" \n",
" white | \n",
" \n",
" 7.2 | \n",
" \n",
" 0.23 | \n",
" \n",
" 0.32 | \n",
" \n",
" 8.5 | \n",
" \n",
" 0.058 | \n",
" \n",
" 47 | \n",
" \n",
" 186 | \n",
" \n",
" 0.9956 | \n",
" \n",
" 3.19 | \n",
" \n",
" 0.4 | \n",
" \n",
" 9.9 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
" \n",
" 1604 | \n",
" \n",
" white | \n",
" \n",
" 8.1 | \n",
" \n",
" 0.28 | \n",
" \n",
" 0.4 | \n",
" \n",
" 6.9 | \n",
" \n",
" 0.05 | \n",
" \n",
" 30 | \n",
" \n",
" 97 | \n",
" \n",
" 0.9951 | \n",
" \n",
" 3.26 | \n",
" \n",
" 0.44 | \n",
" \n",
" 10.1 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
" \n",
" 1605 | \n",
" \n",
" white | \n",
" \n",
" 6.2 | \n",
" \n",
" 0.32 | \n",
" \n",
" 0.16 | \n",
" \n",
" 7 | \n",
" \n",
" 0.045 | \n",
" \n",
" 30 | \n",
" \n",
" 136 | \n",
" \n",
" 0.9949 | \n",
" \n",
" 3.18 | \n",
" \n",
" 0.47 | \n",
" \n",
" 9.6 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
" \n",
" 1606 | \n",
" \n",
" white | \n",
" \n",
" 7 | \n",
" \n",
" 0.27 | \n",
" \n",
" 0.36 | \n",
" \n",
" 20.7 | \n",
" \n",
" 0.045 | \n",
" \n",
" 45 | \n",
" \n",
" 170 | \n",
" \n",
" 1.001 | \n",
" \n",
" 3 | \n",
" \n",
" 0.45 | \n",
" \n",
" 8.8 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
" \n",
" 1607 | \n",
" \n",
" white | \n",
" \n",
" 6.3 | \n",
" \n",
" 0.3 | \n",
" \n",
" 0.34 | \n",
" \n",
" 1.6 | \n",
" \n",
" 0.049 | \n",
" \n",
" 14 | \n",
" \n",
" 132 | \n",
" \n",
" 0.994 | \n",
" \n",
" 3.3 | \n",
" \n",
" 0.49 | \n",
" \n",
" 9.5 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
" \n",
" 1608 | \n",
" \n",
" white | \n",
" \n",
" 8.1 | \n",
" \n",
" 0.22 | \n",
" \n",
" 0.43 | \n",
" \n",
" 1.5 | \n",
" \n",
" 0.044 | \n",
" \n",
" 28 | \n",
" \n",
" 129 | \n",
" \n",
" 0.9938 | \n",
" \n",
" 3.22 | \n",
" \n",
" 0.45 | \n",
" \n",
" 11 | \n",
" \n",
" 6 | \n",
" \n",
"
\n",
" \n",
"\n",
" \n",
"
"
],
"text/plain": [
"#\n",
" type fixed acid volatile a citric aci residual s chlorides free sulfu total sulf density pH sulphates alcohol quality\n",
" 1599 white 7 0.27 0.36 20.7 0.045 45 170 1.001 3 0.45 8.8 6\n",
" 1600 white 6.3 0.3 0.34 1.6 0.049 14 132 0.994 3.3 0.49 9.5 6\n",
" 1601 white 8.1 0.28 0.4 6.9 0.05 30 97 0.9951 3.26 0.44 10.1 6\n",
" 1602 white 7.2 0.23 0.32 8.5 0.058 47 186 0.9956 3.19 0.4 9.9 6\n",
" 1603 white 7.2 0.23 0.32 8.5 0.058 47 186 0.9956 3.19 0.4 9.9 6\n",
" 1604 white 8.1 0.28 0.4 6.9 0.05 30 97 0.9951 3.26 0.44 10.1 6\n",
" 1605 white 6.2 0.32 0.16 7 0.045 30 136 0.9949 3.18 0.47 9.6 6\n",
" 1606 white 7 0.27 0.36 20.7 0.045 45 170 1.001 3 0.45 8.8 6\n",
" 1607 white 6.3 0.3 0.34 1.6 0.049 14 132 0.994 3.3 0.49 9.5 6\n",
" 1608 white 8.1 0.22 0.43 1.5 0.044 28 129 0.9938 3.22 0.45 11 6"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"whites = wine.where(wine['type'].eq 'white')\n",
"whites.head 10"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## qualityのヒストグラムを書く"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Object"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"include Daru::Plotly::Methods # plot, generate_data"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
""
],
"text/plain": [
"#[5, 5, 5, 6, 5, 5, 5, 7, 7, 5, 5, 5, 5, 5, 5, 5, 7, 5, 4, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 6, 5, 6, 5, 6, 5, 6, 6, 7, 4, 5, 5, 4, 6, 5, 5, 4, 5, 5, 5, 5, 5, 6, 6, 5, 6, 5, 5, 5, 5, 6, 5, 5, 7, 5, 5, 5, 5, 5, 5, 6, 6, 5, 5, 4, 5, 5, 5, 6, 5, 4, 5, 5, 5, 5, 6, 5, 6, 5, 5, 5, 5, 6, 5, 5, 4, 6, 5, 5, 5, 6, 6, 6, 6, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 6, 5, 6, 6, 6, 6, 6, 5, 6, 5, 5, 5, 5, 5, 5, 7, 5, 5, 5, 5, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 5, 6, 5, 5, 5, 6, 6, 6, 4, 5, 5, 5, 5, 5, 5, 5, 6, 5, 4, 6, 5, 5, 5, 5, 4, 6, 5, 4, 6, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 6, 7, 4, 7, 5, 5, 5, 6, 7, 7, 5, 5, 7, 6, 6, 6, 5, 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, 3, 6, 6, 5, 6, 5, 6, 7, 6, 6, 6, 7, 7, 6, 6, 6, 6, 7, 7, 6, 8, 8, 7, 6, 6, 6, 6, 5, 7, 4, 6, 6, 6, 6, 4, 5, 5, 6, 6, 5, 7, 8, 8, 5, 6, 6, 6, 6, 6, 5, 7, 7, 6, 5, 6, 7, 7, 8, 7, 4, 6, 6, 6, 5, 6, 5, 6, 7, 5, 6, 7, 6, 6, 6, 6, 5, 6, 6, 7, 5, 6, 6, 6, 5, 7, 6, 6, 5, 6, 7, 6, 5, 6, 6, 4, 7, 6, 6, 5, 6, 5, 6, 7, 6, 5, 6, 5, 5, 5, 6, 6, 6, 6, 5, 6, 6, 6, 6, 7, 5, 6, 6, 6, 6, 6, 7, 6, 5, 6, 6, 6, 7, 5, 4, 6, 6, 6, 5, 6, 5, 6, 7, 7, 5, 6, 6, 6, 5, 6, 5, 6, 7, 6], :type=>:histogram, :name=>\"white\", :marker=>{:color=>\"white\"}}], @layout={:paper_bgcolor=>\"silver\", :plot_bgcolor=>\"silver\", :font=>{:color=>\"white\"}}, @config={:linkText=>\"Export to plot.ly\", :showLink=>true}, @embedded=true>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"#"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"red_qualities = generate_data(reds['quality'], type: :histogram, opts: { name: 'red', marker: { color: '#80273F' } })\n",
"white_qualities = generate_data(whites['quality'], type: :histogram, opts: { name: 'white', marker: { color: 'white' }})\n",
"Plotly::Plot.new(\n",
" data: red_qualities + white_qualities,\n",
" layout: { paper_bgcolor: 'silver', plot_bgcolor: 'silver', font: { color: 'white' } }\n",
").show"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"↑ なんとなく違いがありそう"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/plain": [
"5.6360225140712945"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"reds['quality'].mean # 平均値"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5.87790935075541"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"whites['quality'].mean"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"平均値を見ると、白ワインの方が評価が高いように見える。\n",
"\n",
"たまたま高くなっただけじゃないのか? → t検定で検証する"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## t検定\n",
"\n",
"t検定: 2つの数値の集合があるとき、それらの平均値の違いに意味があるかどうか検証する手法\n",
"\n",
"赤ワインと白ワインの `quality` の平均値に差があるのか仮説検定する。"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/t.rb:291.\n",
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/t.rb:292.\n",
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/levene.rb:51.\n",
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/levene.rb:51.\n",
"NOTE: Daru::Vector#only_valid is deprecated; use reject_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#only_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/levene.rb:60.\n",
"NOTE: Daru::Vector#only_valid is deprecated; use reject_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#only_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/levene.rb:60.\n",
"NOTE: Daru::Vector#only_valid is deprecated; use reject_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#only_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/levene.rb:71.\n",
"NOTE: Daru::Vector#only_valid is deprecated; use reject_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#only_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/levene.rb:71.\n",
"/usr/local/lib/ruby/gems/2.4.0/gems/distribution-0.7.3/lib/distribution/math_extension/incomplete_beta.rb:14: warning: constant ::Fixnum is deprecated\n",
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/t.rb:267.\n",
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/t.rb:267.\n",
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/t.rb:269.\n",
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/t.rb:269.\n",
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/t.rb:271.\n",
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/t.rb:271.\n",
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/t.rb:272.\n",
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/t.rb:272.\n",
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/t.rb:281.\n",
"NOTE: Daru::Vector#n_valid is deprecated; use count_values instead. It will be removed on or after 2016-10-01.\n",
"Daru::Vector#n_valid called from /usr/local/lib/ruby/gems/2.4.0/gems/statsample-2.0.2/lib/statsample/test/t.rb:282.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Analysis 2017-05-22 16:20:08 +0000\n",
"= Statsample::Test::T\n",
" == Two Sample T Test\n",
" Mean and standard deviation\n",
"+----------+--------+--------+------+\n",
"| Variable | mean | sd | n |\n",
"+----------+--------+--------+------+\n",
"| quality | 5.6360 | 0.8076 | 1599 |\n",
"| quality | 5.8779 | 0.8856 | 4898 |\n",
"+----------+--------+--------+------+\n",
"\n",
" Levene test for equality of variances : F(1, 6495) = 0.6213 , p = 0.4306\n",
" T statistics\n",
"+--------------------+----------+-----------+----------------+\n",
"| Type | t | df | p (both tails) |\n",
"+--------------------+----------+-----------+----------------+\n",
"| Equal variance | -9.6856 | 6495 | 0.0000 |\n",
"| Non equal variance | -10.1494 | 2950.7505 | 0.0000 |\n",
"+--------------------+----------+-----------+----------------+\n",
"\n",
" Effect size\n",
"+-------+---------+\n",
"| x1-x2 | -0.2419 |\n",
"| d | -0.2599 |\n",
"+-------+---------+\n",
"\n",
"\n"
]
}
],
"source": [
"Statsample::Analysis.store(Statsample::Test::T) do\n",
" t = Statsample::Test.t_two_samples_independent(reds['quality'], whites['quality'])\n",
" summary t\n",
"end\n",
"Statsample::Analysis.run_batch"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"p値が十分小さい(p = 0.0000)ので、統計的に有意な差がある → 白ワインの方が総じて評価が高い\n",
"\n",
"※あくまでこのデータからは有意な差があるというだけ"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 結構使えるのでは?\n",
"\n",
"だいたいのことができますが、まだ不十分なところもあります。"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 速度"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`Daru::DataFrame#corr` 相関係数を出すメソッド → 遅い"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" Daru::DataFrame(12x12) | \n",
"
\n",
"\n",
" \n",
" \n",
" | \n",
" \n",
" fixed acidity | \n",
" \n",
" volatile acidity | \n",
" \n",
" citric acid | \n",
" \n",
" residual sugar | \n",
" \n",
" chlorides | \n",
" \n",
" free sulfur dioxide | \n",
" \n",
" total sulfur dioxide | \n",
" \n",
" density | \n",
" \n",
" pH | \n",
" \n",
" sulphates | \n",
" \n",
" alcohol | \n",
" \n",
" quality | \n",
" \n",
"
\n",
" \n",
"\n",
" \n",
" \n",
" fixed acidity | \n",
" \n",
" 1.0 | \n",
" \n",
" 0.21900825635100266 | \n",
" \n",
" 0.32443572544730104 | \n",
" \n",
" -0.11198128107823678 | \n",
" \n",
" 0.29819477170273795 | \n",
" \n",
" -0.28273542836956794 | \n",
" \n",
" -0.32905390129522527 | \n",
" \n",
" 0.45890998228044255 | \n",
" \n",
" -0.2527004683162333 | \n",
" \n",
" 0.29956774438249995 | \n",
" \n",
" -0.09545152256332995 | \n",
" \n",
" -0.07674320790962286 | \n",
" \n",
"
\n",
" \n",
" \n",
" volatile acidity | \n",
" \n",
" 0.21900825635100266 | \n",
" \n",
" 1.0000000000000002 | \n",
" \n",
" -0.37798131705526566 | \n",
" \n",
" -0.19601117434765503 | \n",
" \n",
" 0.3771242764338664 | \n",
" \n",
" -0.35255730641340716 | \n",
" \n",
" -0.4144761946507196 | \n",
" \n",
" 0.2712956478511821 | \n",
" \n",
" 0.261454402742256 | \n",
" \n",
" 0.2259836797410744 | \n",
" \n",
" -0.03764038583468137 | \n",
" \n",
" -0.26569947761148033 | \n",
" \n",
"
\n",
" \n",
" \n",
" citric acid | \n",
" \n",
" 0.32443572544730104 | \n",
" \n",
" -0.37798131705526566 | \n",
" \n",
" 1.0 | \n",
" \n",
" 0.14245122598675725 | \n",
" \n",
" 0.038998014089851825 | \n",
" \n",
" 0.13312580951823125 | \n",
" \n",
" 0.19524197598145304 | \n",
" \n",
" 0.09615392906417021 | \n",
" \n",
" -0.32980819113172016 | \n",
" \n",
" 0.0561973001349725 | \n",
" \n",
" -0.01049349217337923 | \n",
" \n",
" 0.08553171718367827 | \n",
" \n",
"
\n",
" \n",
" \n",
" residual sugar | \n",
" \n",
" -0.11198128107823678 | \n",
" \n",
" -0.19601117434765503 | \n",
" \n",
" 0.14245122598675725 | \n",
" \n",
" 0.9999999999999999 | \n",
" \n",
" -0.12894049990326722 | \n",
" \n",
" 0.4028706400566557 | \n",
" \n",
" 0.4954815870066449 | \n",
" \n",
" 0.552516950293483 | \n",
" \n",
" -0.2673198368768104 | \n",
" \n",
" -0.1859274052901841 | \n",
" \n",
" -0.3594147708159969 | \n",
" \n",
" -0.03698048458576987 | \n",
" \n",
"
\n",
" \n",
" \n",
" chlorides | \n",
" \n",
" 0.29819477170273795 | \n",
" \n",
" 0.3771242764338664 | \n",
" \n",
" 0.038998014089851825 | \n",
" \n",
" -0.12894049990326722 | \n",
" \n",
" 1.0000000000000002 | \n",
" \n",
" -0.1950447852077002 | \n",
" \n",
" -0.27963044744333765 | \n",
" \n",
" 0.3626146565578091 | \n",
" \n",
" 0.04470797955050543 | \n",
" \n",
" 0.395593306547331 | \n",
" \n",
" -0.2569155799729125 | \n",
" \n",
" -0.20066550043510553 | \n",
" \n",
"
\n",
" \n",
" \n",
" free sulfur dioxide | \n",
" \n",
" -0.28273542836956794 | \n",
" \n",
" -0.35255730641340716 | \n",
" \n",
" 0.13312580951823125 | \n",
" \n",
" 0.4028706400566557 | \n",
" \n",
" -0.1950447852077002 | \n",
" \n",
" 1.0000000000000002 | \n",
" \n",
" 0.7209340813785245 | \n",
" \n",
" 0.025716842144663805 | \n",
" \n",
" -0.14585389640016552 | \n",
" \n",
" -0.18845724880121598 | \n",
" \n",
" -0.1798384348893394 | \n",
" \n",
" 0.05546305861663346 | \n",
" \n",
"
\n",
" \n",
" \n",
" total sulfur dioxide | \n",
" \n",
" -0.32905390129522527 | \n",
" \n",
" -0.4144761946507196 | \n",
" \n",
" 0.19524197598145304 | \n",
" \n",
" 0.4954815870066449 | \n",
" \n",
" -0.27963044744333765 | \n",
" \n",
" 0.7209340813785245 | \n",
" \n",
" 1.0 | \n",
" \n",
" 0.03239451234680212 | \n",
" \n",
" -0.23841310290340784 | \n",
" \n",
" -0.27572681991620573 | \n",
" \n",
" -0.26573963910715914 | \n",
" \n",
" -0.04138545385560974 | \n",
" \n",
"
\n",
" \n",
" \n",
" density | \n",
" \n",
" 0.45890998228044255 | \n",
" \n",
" 0.2712956478511821 | \n",
" \n",
" 0.09615392906417021 | \n",
" \n",
" 0.552516950293483 | \n",
" \n",
" 0.3626146565578091 | \n",
" \n",
" 0.025716842144663805 | \n",
" \n",
" 0.03239451234680212 | \n",
" \n",
" 1.0 | \n",
" \n",
" 0.011686080687174244 | \n",
" \n",
" 0.25947849534575335 | \n",
" \n",
" -0.6867454216813362 | \n",
" \n",
" -0.3058579060694189 | \n",
" \n",
"
\n",
" \n",
" \n",
" pH | \n",
" \n",
" -0.2527004683162333 | \n",
" \n",
" 0.261454402742256 | \n",
" \n",
" -0.32980819113172016 | \n",
" \n",
" -0.2673198368768104 | \n",
" \n",
" 0.04470797955050543 | \n",
" \n",
" -0.14585389640016552 | \n",
" \n",
" -0.23841310290340784 | \n",
" \n",
" 0.011686080687174244 | \n",
" \n",
" 1.0000000000000002 | \n",
" \n",
" 0.19212340657115304 | \n",
" \n",
" 0.12124846709464465 | \n",
" \n",
" 0.019505703714435736 | \n",
" \n",
"
\n",
" \n",
" \n",
" sulphates | \n",
" \n",
" 0.29956774438249995 | \n",
" \n",
" 0.2259836797410744 | \n",
" \n",
" 0.0561973001349725 | \n",
" \n",
" -0.1859274052901841 | \n",
" \n",
" 0.395593306547331 | \n",
" \n",
" -0.18845724880121598 | \n",
" \n",
" -0.27572681991620573 | \n",
" \n",
" 0.25947849534575335 | \n",
" \n",
" 0.19212340657115304 | \n",
" \n",
" 0.9999999999999999 | \n",
" \n",
" -0.003029194944255261 | \n",
" \n",
" 0.038485445876515374 | \n",
" \n",
"
\n",
" \n",
" \n",
" alcohol | \n",
" \n",
" -0.09545152256332995 | \n",
" \n",
" -0.03764038583468137 | \n",
" \n",
" -0.01049349217337923 | \n",
" \n",
" -0.3594147708159969 | \n",
" \n",
" -0.2569155799729125 | \n",
" \n",
" -0.1798384348893394 | \n",
" \n",
" -0.26573963910715914 | \n",
" \n",
" -0.6867454216813362 | \n",
" \n",
" 0.12124846709464465 | \n",
" \n",
" -0.003029194944255261 | \n",
" \n",
" 1.0 | \n",
" \n",
" 0.44431852000752226 | \n",
" \n",
"
\n",
" \n",
" \n",
" quality | \n",
" \n",
" -0.07674320790962286 | \n",
" \n",
" -0.26569947761148033 | \n",
" \n",
" 0.08553171718367827 | \n",
" \n",
" -0.03698048458576987 | \n",
" \n",
" -0.20066550043510553 | \n",
" \n",
" 0.05546305861663346 | \n",
" \n",
" -0.04138545385560974 | \n",
" \n",
" -0.3058579060694189 | \n",
" \n",
" 0.019505703714435736 | \n",
" \n",
" 0.038485445876515374 | \n",
" \n",
" 0.44431852000752226 | \n",
" \n",
" 1.0 | \n",
" \n",
"
\n",
" \n",
"\n",
" \n",
"
"
],
"text/plain": [
"#\n",
" fixed acid volatile a citric aci residual s chlorides free sulfu total sulf density pH sulphates alcohol quality\n",
" fixed acid 1.0 0.21900825 0.32443572 -0.1119812 0.29819477 -0.2827354 -0.3290539 0.45890998 -0.2527004 0.29956774 -0.0954515 -0.0767432\n",
" volatile a 0.21900825 1.00000000 -0.3779813 -0.1960111 0.37712427 -0.3525573 -0.4144761 0.27129564 0.26145440 0.22598367 -0.0376403 -0.2656994\n",
" citric aci 0.32443572 -0.3779813 1.0 0.14245122 0.03899801 0.13312580 0.19524197 0.09615392 -0.3298081 0.05619730 -0.0104934 0.08553171\n",
" residual s -0.1119812 -0.1960111 0.14245122 0.99999999 -0.1289404 0.40287064 0.49548158 0.55251695 -0.2673198 -0.1859274 -0.3594147 -0.0369804\n",
" chlorides 0.29819477 0.37712427 0.03899801 -0.1289404 1.00000000 -0.1950447 -0.2796304 0.36261465 0.04470797 0.39559330 -0.2569155 -0.2006655\n",
" free sulfu -0.2827354 -0.3525573 0.13312580 0.40287064 -0.1950447 1.00000000 0.72093408 0.02571684 -0.1458538 -0.1884572 -0.1798384 0.05546305\n",
" total sulf -0.3290539 -0.4144761 0.19524197 0.49548158 -0.2796304 0.72093408 1.0 0.03239451 -0.2384131 -0.2757268 -0.2657396 -0.0413854\n",
" density 0.45890998 0.27129564 0.09615392 0.55251695 0.36261465 0.02571684 0.03239451 1.0 0.01168608 0.25947849 -0.6867454 -0.3058579\n",
" pH -0.2527004 0.26145440 -0.3298081 -0.2673198 0.04470797 -0.1458538 -0.2384131 0.01168608 1.00000000 0.19212340 0.12124846 0.01950570\n",
" sulphates 0.29956774 0.22598367 0.05619730 -0.1859274 0.39559330 -0.1884572 -0.2757268 0.25947849 0.19212340 0.99999999 -0.0030291 0.03848544\n",
" alcohol -0.0954515 -0.0376403 -0.0104934 -0.3594147 -0.2569155 -0.1798384 -0.2657396 -0.6867454 0.12124846 -0.0030291 1.0 0.44431852\n",
" quality -0.0767432 -0.2656994 0.08553171 -0.0369804 -0.2006655 0.05546305 -0.0413854 -0.3058579 0.01950570 0.03848544 0.44431852 1.0"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wine.corr"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
""
],
"text/plain": [
"#[\"fixed acidity\", \"volatile acidity\", \"citric acid\", \"residual sugar\", \"chlorides\", \"free sulfur dioxide\", \"total sulfur dioxide\", \"density\", \"pH\", \"sulphates\", \"alcohol\", \"quality\"], :type=>:heatmap, :z=>[[1.0, 0.21900825635100266, 0.32443572544730104, -0.11198128107823678, 0.29819477170273795, -0.28273542836956794, -0.32905390129522527, 0.45890998228044255, -0.2527004683162333, 0.29956774438249995, -0.09545152256332995, -0.07674320790962286], [0.21900825635100266, 1.0000000000000002, -0.37798131705526566, -0.19601117434765503, 0.3771242764338664, -0.35255730641340716, -0.4144761946507196, 0.2712956478511821, 0.261454402742256, 0.2259836797410744, -0.03764038583468137, -0.26569947761148033], [0.32443572544730104, -0.37798131705526566, 1.0, 0.14245122598675725, 0.038998014089851825, 0.13312580951823125, 0.19524197598145304, 0.09615392906417021, -0.32980819113172016, 0.0561973001349725, -0.01049349217337923, 0.08553171718367827], [-0.11198128107823678, -0.19601117434765503, 0.14245122598675725, 0.9999999999999999, -0.12894049990326722, 0.4028706400566557, 0.4954815870066449, 0.552516950293483, -0.2673198368768104, -0.1859274052901841, -0.3594147708159969, -0.03698048458576987], [0.29819477170273795, 0.3771242764338664, 0.038998014089851825, -0.12894049990326722, 1.0000000000000002, -0.1950447852077002, -0.27963044744333765, 0.3626146565578091, 0.04470797955050543, 0.395593306547331, -0.2569155799729125, -0.20066550043510553], [-0.28273542836956794, -0.35255730641340716, 0.13312580951823125, 0.4028706400566557, -0.1950447852077002, 1.0000000000000002, 0.7209340813785245, 0.025716842144663805, -0.14585389640016552, -0.18845724880121598, -0.1798384348893394, 0.05546305861663346], [-0.32905390129522527, -0.4144761946507196, 0.19524197598145304, 0.4954815870066449, -0.27963044744333765, 0.7209340813785245, 1.0, 0.03239451234680212, -0.23841310290340784, -0.27572681991620573, -0.26573963910715914, -0.04138545385560974], [0.45890998228044255, 0.2712956478511821, 0.09615392906417021, 0.552516950293483, 0.3626146565578091, 0.025716842144663805, 0.03239451234680212, 1.0, 0.011686080687174244, 0.25947849534575335, -0.6867454216813362, -0.3058579060694189], [-0.2527004683162333, 0.261454402742256, -0.32980819113172016, -0.2673198368768104, 0.04470797955050543, -0.14585389640016552, -0.23841310290340784, 0.011686080687174244, 1.0000000000000002, 0.19212340657115304, 0.12124846709464465, 0.019505703714435736], [0.29956774438249995, 0.2259836797410744, 0.0561973001349725, -0.1859274052901841, 0.395593306547331, -0.18845724880121598, -0.27572681991620573, 0.25947849534575335, 0.19212340657115304, 0.9999999999999999, -0.003029194944255261, 0.038485445876515374], [-0.09545152256332995, -0.03764038583468137, -0.01049349217337923, -0.3594147708159969, -0.2569155799729125, -0.1798384348893394, -0.26573963910715914, -0.6867454216813362, 0.12124846709464465, -0.003029194944255261, 1.0, 0.44431852000752226], [-0.07674320790962286, -0.26569947761148033, 0.08553171718367827, -0.03698048458576987, -0.20066550043510553, 0.05546305861663346, -0.04138545385560974, -0.3058579060694189, 0.019505703714435736, 0.038485445876515374, 0.44431852000752226, 1.0]], :y=>[\"fixed acidity\", \"volatile acidity\", \"citric acid\", \"residual sugar\", \"chlorides\", \"free sulfur dioxide\", \"total sulfur dioxide\", \"density\", \"pH\", \"sulphates\", \"alcohol\", \"quality\"]}], @layout={:width=>1000, :height=>500}, @config={:linkText=>\"Export to plot.ly\", :showLink=>true}, @embedded=true>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"#"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(wine.corr, type: :heatmap).show"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[DataFrame#corrのベンチマーク](./corration_benchmark/Benchmark.md)より\n",
"\n",
"Daru:\n",
"```shell\n",
"> ruby corr.rb\n",
" user system total real\n",
"correlation 5.330000 0.100000 5.430000 ( 5.613104)\n",
"```\n",
"\n",
"pandas:\n",
"```shell\n",
"> python3 corr.py\n",
"## benchmarker: release 4.0.1 (for python)\n",
"## python version: 3.5.2\n",
"## python compiler: GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)\n",
"## python platform: Darwin-16.4.0-x86_64-i386-64bit\n",
"## python executable: /usr/local/opt/python3/bin/python3.5\n",
"## cpu model: Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz\n",
"## parameters: loop=1, cycle=1, extra=0\n",
"\n",
"## real (total = user + sys)\n",
"corr 0.0032 0.0000 0.0000 0.0000\n",
"\n",
"## Ranking real\n",
"corr 0.0032 (100.0) ********************\n",
"\n",
"## Matrix real [01]\n",
"[01] corr 0.0032 100.0\n",
"\n",
"```\n",
"\n",
"pandasでは0.0032秒で終わる処理が、daruでは5.33秒もかかる。\n",
"$ \\because $ **cython**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 操作性\n",
"\n",
"### `DataFrame#where`\n",
"\n",
"pandas:\n",
"```python\n",
"df[df['quality'] >= 6 && df['alcohol'] <= 10] # qualityが3以上でalcoholが10以下の行を抽出\n",
"\n",
"df[df['quality'] >= 6 && df['alcohol'] <= 10]['pH'] = 0 # 上の条件の行のpHを0にする\n",
"\n",
"df # pHが上書きされている\n",
"```\n",
"\n",
"daru:\n",
"```ruby\n",
"df[df['quality'] >= 6 && df['alcohol'] <= 10] # qualityが3以上でalcoholが10以下の行を抽出\n",
"\n",
"df[df['quality'] >= 6 && df['alcohol'] <= 10]['pH'] = 0 # fails!\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 他にも細かい不便はたくさんある\n",
"\n",
"`pandas` と比較すると\n",
"\n",
"- スカラーからDataFrameが生成できない\n",
"- ランダムな値で初期化できない\n",
"- Universal Functionが足りない\n",
"- 二項演算を、row-wiseにするのかcolumn-wiseにやるのか選べない\n",
"- DataFrame#stackメソッドがない\n",
"- fill_valueを指定できない\n",
"- 用語の不統一\n",
"- Vectorにkeyの追加ができない\n",
"- locに相当するセレクタがない\n",
"- positionとindexの混同\n",
"\n",
"など"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## じゃあPRすればいいじゃない\n",
"\n",
"- ソースコードが汚い&量が多いので理解に時間がかかる\n",
" - Daru::DataFrameクラスが責務を抱え込みすぎ?\n",
" - \"Move Fast and Break Things\" の代償?\n",
" - ちなみにpandasのソースコードも汚くてつらい感じ\n",
" - 根本的に複雑になる?\n",
" - 開発者数でカバーしているのではないか?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## そもそも\n",
"\n",
"- pandasと同じものを目指すなら同じ程度の労力が必要だが、pandasほどのユーザー数は見込めない?\n",
" - 普通にデータサイエンスしたい人はPythonかRを使う\n",
" - 「Rubyist & データサイエンスしたい人」 はそこまで多くない\n",
" - 開発する人材が足りないので機能が不足する\n",
"\n",
"- pandasに対抗するためには、Rubyの魅力を活かす必要がある。\n",
" - Rubyの魅力\n",
"\t- open classでガンガンカスタマイズ\n",
" - メタプログラミングで楽できる\n",
" - Railsやsinatraと結合\n",
" - ActiveRecordとdaru\n",
" - erbにグラフ埋め込み\n",
" - サポートする機能を減らして、コードの理解しやすさ・カスタマイズしやすさを重視するアプローチでもよいのでは\n",
"\n",
"- Rubyでシュッとグラフを書くみたいなことができるだけでも十分?\n",
" - このへんはRubyistの意見調査みたいなのが必要な気がする\n",
"\n",
"※個人の感想です"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Ruby 2.4.1",
"language": "ruby",
"name": "ruby"
},
"language_info": {
"file_extension": ".rb",
"mimetype": "application/x-ruby",
"name": "ruby",
"version": "2.4.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}