{"nbformat":4,"nbformat_minor":0,"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.7.6"},"colab":{"name":"5_決定木・ランダムフォレスト.ipynb","provenance":[],"collapsed_sections":[],"toc_visible":true}},"cells":[{"cell_type":"markdown","metadata":{"id":"u90hwTC5wj7Z"},"source":["## 5.決定木・ランダムフォレスト"]},{"cell_type":"markdown","metadata":{"id":"Tzf9pC-Ewj7v"},"source":["### 決定木分析"]},{"cell_type":"code","metadata":{"id":"9swVSJ4Xwj7z"},"source":["import numpy as np\n","import pandas as pd\n","import matplotlib.pyplot as plt\n","%matplotlib inline"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"x-vWLIGU5LqZ"},"source":["データを読み込みます。"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":416},"id":"qTlymyCutXTJ","outputId":"6964ad49-2631-4f4f-c584-68b5f3635b99"},"source":["#データの読み込み\n","cancer = pd.read_csv(\"decision.csv\",index_col=0)\n","cancer"],"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/html":["
\n"," | regular_customer | \n","number_of_visits | \n","point_card | \n","total_purchase_amount | \n","
---|---|---|---|---|
0 | \n","0 | \n","18 | \n","0 | \n","10380 | \n","
1 | \n","0 | \n","21 | \n","0 | \n","17770 | \n","
2 | \n","0 | \n","20 | \n","0 | \n","21250 | \n","
3 | \n","0 | \n","11 | \n","0 | \n","20380 | \n","
4 | \n","0 | \n","20 | \n","0 | \n","14340 | \n","
... | \n","... | \n","... | \n","... | \n","... | \n","
564 | \n","0 | \n","22 | \n","0 | \n","22390 | \n","
565 | \n","0 | \n","20 | \n","0 | \n","28250 | \n","
566 | \n","0 | \n","17 | \n","0 | \n","28080 | \n","
567 | \n","0 | \n","21 | \n","0 | \n","29330 | \n","
568 | \n","1 | \n","8 | \n","1 | \n","24540 | \n","
569 rows × 4 columns
\n","\n"," | なる | \n","ならない | \n","
---|---|---|
なる | \n","56 | \n","7 | \n","
ならない | \n","8 | \n","100 | \n","