{ "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", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", "
Daru::DataFrame(10x13)
typefixed acidityvolatile aciditycitric acidresidual sugarchloridesfree sulfur dioxidetotal sulfur dioxidedensitypHsulphatesalcoholquality
0red7.40.701.90.07611340.99783.510.569.45
1red7.80.8802.60.09825670.99683.20.689.85
2red7.80.760.042.30.09215540.9973.260.659.85
3red11.20.280.561.90.07517600.9983.160.589.86
4red7.40.701.90.07611340.99783.510.569.45
5red7.40.6601.80.07513400.99783.510.569.45
6red7.90.60.061.60.06915590.99643.30.469.45
7red7.30.6501.20.06515210.99463.390.47107
8red7.80.580.0220.0739180.99683.360.579.57
9red7.50.50.366.10.071171020.99783.350.810.55
" ], "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", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", "
Daru::DataFrame(10x13)
typefixed acidityvolatile aciditycitric acidresidual sugarchloridesfree sulfur dioxidetotal sulfur dioxidedensitypHsulphatesalcoholquality
0red7.40.701.90.07611340.99783.510.569.45
1red7.80.8802.60.09825670.99683.20.689.85
2red7.80.760.042.30.09215540.9973.260.659.85
3red11.20.280.561.90.07517600.9983.160.589.86
4red7.40.701.90.07611340.99783.510.569.45
5red7.40.6601.80.07513400.99783.510.569.45
6red7.90.60.061.60.06915590.99643.30.469.45
7red7.30.6501.20.06515210.99463.390.47107
8red7.80.580.0220.0739180.99683.360.579.57
9red7.50.50.366.10.071171020.99783.350.810.55
" ], "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", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", "
Daru::DataFrame(10x13)
typefixed acidityvolatile aciditycitric acidresidual sugarchloridesfree sulfur dioxidetotal sulfur dioxidedensitypHsulphatesalcoholquality
1599white70.270.3620.70.045451701.00130.458.86
1600white6.30.30.341.60.049141320.9943.30.499.56
1601white8.10.280.46.90.0530970.99513.260.4410.16
1602white7.20.230.328.50.058471860.99563.190.49.96
1603white7.20.230.328.50.058471860.99563.190.49.96
1604white8.10.280.46.90.0530970.99513.260.4410.16
1605white6.20.320.1670.045301360.99493.180.479.66
1606white70.270.3620.70.045451701.00130.458.86
1607white6.30.30.341.60.049141320.9943.30.499.56
1608white8.10.220.431.50.044281290.99383.220.45116
" ], "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,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6, 6, 6, 6, 5, 6, 7, 4, 6, 5, 5, 5, 5, 7, 5, 7, 7, 5, 6, 7, 7, 6, 6, 5, 6, 6, 6, 7, 7, 7, 6, 6, 6, 6, 5, 6, 5, 6, 6, 6, 7, 6, 6, 7, 7, 7, 5, 5, 5, 7, 5, 7, 7, 7, 7, 7, 6, 6, 6, 5, 6, 7, 7, 6, 5, 7, 7, 5, 6, 5, 5, 7, 7, 6, 6, 7, 6, 5, 4, 6, 6, 6, 6, 5, 4, 6, 6, 6, 6, 7, 5, 6, 7, 7, 6, 7, 6, 5, 5, 6, 6, 7, 6, 6, 7, 6, 6, 6, 7, 6, 6, 6, 7, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 6, 6, 6, 6, 6, 6, 7, 6, 6, 5, 6, 6, 5, 5, 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", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", "
Daru::DataFrame(12x12)
fixed acidityvolatile aciditycitric acidresidual sugarchloridesfree sulfur dioxidetotal sulfur dioxidedensitypHsulphatesalcoholquality
fixed acidity1.00.219008256351002660.32443572544730104-0.111981281078236780.29819477170273795-0.28273542836956794-0.329053901295225270.45890998228044255-0.25270046831623330.29956774438249995-0.09545152256332995-0.07674320790962286
volatile acidity0.219008256351002661.0000000000000002-0.37798131705526566-0.196011174347655030.3771242764338664-0.35255730641340716-0.41447619465071960.27129564785118210.2614544027422560.2259836797410744-0.03764038583468137-0.26569947761148033
citric acid0.32443572544730104-0.377981317055265661.00.142451225986757250.0389980140898518250.133125809518231250.195241975981453040.09615392906417021-0.329808191131720160.0561973001349725-0.010493492173379230.08553171718367827
residual sugar-0.11198128107823678-0.196011174347655030.142451225986757250.9999999999999999-0.128940499903267220.40287064005665570.49548158700664490.552516950293483-0.2673198368768104-0.1859274052901841-0.3594147708159969-0.03698048458576987
chlorides0.298194771702737950.37712427643386640.038998014089851825-0.128940499903267221.0000000000000002-0.1950447852077002-0.279630447443337650.36261465655780910.044707979550505430.395593306547331-0.2569155799729125-0.20066550043510553
free sulfur dioxide-0.28273542836956794-0.352557306413407160.133125809518231250.4028706400566557-0.19504478520770021.00000000000000020.72093408137852450.025716842144663805-0.14585389640016552-0.18845724880121598-0.17983843488933940.05546305861663346
total sulfur dioxide-0.32905390129522527-0.41447619465071960.195241975981453040.4954815870066449-0.279630447443337650.72093408137852451.00.03239451234680212-0.23841310290340784-0.27572681991620573-0.26573963910715914-0.04138545385560974
density0.458909982280442550.27129564785118210.096153929064170210.5525169502934830.36261465655780910.0257168421446638050.032394512346802121.00.0116860806871742440.25947849534575335-0.6867454216813362-0.3058579060694189
pH-0.25270046831623330.261454402742256-0.32980819113172016-0.26731983687681040.04470797955050543-0.14585389640016552-0.238413102903407840.0116860806871742441.00000000000000020.192123406571153040.121248467094644650.019505703714435736
sulphates0.299567744382499950.22598367974107440.0561973001349725-0.18592740529018410.395593306547331-0.18845724880121598-0.275726819916205730.259478495345753350.192123406571153040.9999999999999999-0.0030291949442552610.038485445876515374
alcohol-0.09545152256332995-0.03764038583468137-0.01049349217337923-0.3594147708159969-0.2569155799729125-0.1798384348893394-0.26573963910715914-0.68674542168133620.12124846709464465-0.0030291949442552611.00.44431852000752226
quality-0.07674320790962286-0.265699477611480330.08553171718367827-0.03698048458576987-0.200665500435105530.05546305861663346-0.04138545385560974-0.30585790606941890.0195057037144357360.0384854458765153740.444318520007522261.0
" ], "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 }