総合実験（４日目）Jupyter Notebookを使った機械学習

2016年に作った資料を公開します。もう既にいろいろ古くなってる可能性が高いです。

### Jupyter Notebook (IPython Notebook) とは
* Python という名のプログラミング言語が使えるプログラミング環境。計算コードと計算結果を同じ場所に時系列で保存できるので、実験系における実験ノートのように、いつどんな処理を行って何を得たのか記録して再現するのに便利。


* 本実習では、人工知能の一分野である「機械学習」のうち、サポートベクトルマシン（SVM: Support Vector Machine）を使います。
   * 機械学習とは→ [コンピューターに"学習"させる](http://image.slidesharecdn.com/deepvision-141031063609-conversion-gate01/95/deep-learning-4-638.jpg) 
   * [サポートベクターマシン](http://image.slidesharecdn.com/shen2007-120927221259-phpapp01/95/proteinprotein-interaction-prediction-8-728.jpg) ・ [サポートベクターマシンとは](http://qiita.com/pesuchin/items/c55f40b69aa1aec2bd19)
* 各自の画面中の IPython Notebook のセルに順次入力して（コピペ可）、「Shift + Enter」してください。
* 最後に、課題を解いてもらいます。課題の結果を、指定する方法で指定するメールアドレスまで送信してください。


```python
import matplotlib.pyplot as plt # 図やグラフを図示するためのライブラリ
import pylab as pl # これも図やグラフを図示するためのライブラリ

#　Jupyter Notebook 上で表示させるための呪文
%matplotlib inline 

import urllib # URL によるリソースへのアクセスを提供するライブラリ

import random #乱数を発生させるライブラリ
import numpy as np # 数値計算ライブラリ

import pandas as pd # データフレームワーク処理のライブラリ
from pandas.tools import plotting # 高度なプロットを行うツールのインポート

#機械学習のためのいろんなライブラリ
import sklearn.svm as svm
from sklearn.svm import SVC
from sklearn.cross_validation import train_test_split
from sklearn.metrics import roc_curve, precision_recall_curve, auc, classification_report, confusion_matrix
from sklearn import cross_validation as cv
from sklearn import svm, grid_search, datasets
```

総合実験１日目でも用いたデータをまた使います。


```python
# ウェブ上のリソースを指定する
url = 'https://raw.githubusercontent.com/maskot1977/ipython_notebook/master/toydata/iris.txt'
# 指定したURLからリソースをダウンロードし、名前をつける。
urllib.urlretrieve(url, 'iris.txt')
```




    ('iris.txt', <httplib.HTTPMessage instance at 0x116ed0908>)



とりあえずデータを確認するには、こんな方法もあります


```python
# 先頭N行を表示する。カラムのタイトルも確認する。
pd.DataFrame(pd.read_csv('iris.txt', sep='\t', na_values=".")).head() 
```




<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Unnamed: 0</th>
      <th>Sepal.Length</th>
      <th>Sepal.Width</th>
      <th>Petal.Length</th>
      <th>Petal.Width</th>
      <th>Species</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>1</td>
      <td>5.1</td>
      <td>3.5</td>
      <td>1.4</td>
      <td>0.2</td>
      <td>setosa</td>
    </tr>
    <tr>
      <th>1</th>
      <td>2</td>
      <td>4.9</td>
      <td>3.0</td>
      <td>1.4</td>
      <td>0.2</td>
      <td>setosa</td>
    </tr>
    <tr>
      <th>2</th>
      <td>3</td>
      <td>4.7</td>
      <td>3.2</td>
      <td>1.3</td>
      <td>0.2</td>
      <td>setosa</td>
    </tr>
    <tr>
      <th>3</th>
      <td>4</td>
      <td>4.6</td>
      <td>3.1</td>
      <td>1.5</td>
      <td>0.2</td>
      <td>setosa</td>
    </tr>
    <tr>
      <th>4</th>
      <td>5</td>
      <td>5.0</td>
      <td>3.6</td>
      <td>1.4</td>
      <td>0.2</td>
      <td>setosa</td>
    </tr>
  </tbody>
</table>
</div>



### 色分けした Scatter Matrix を描く
* 今回は、"Species" 毎に色を変えてプロットしたいと思います。
* カラーコードが分からない人は右記リンク参照→ [カラーコード表](http://www5.plala.or.jp/vaio0630/hp/c_code.htm)・[カラーコード](http://www.finitojapan.com/cltable.html)


```python
# "Species" 列の値を重複を除いて全てリストアップする。
print list(set(pd.read_csv('iris.txt', sep='\t', na_values=".")["Species"]))
```

    ['setosa', 'versicolor', 'virginica']



```python
# それぞれに与える色を決める。
color_codes = {'setosa':'#00FF00', 'versicolor':'#FF0000', 'virginica':'#0000FF'}
```


```python
# サンプル毎に色を与える。
colors = [color_codes[x] for x in list(pd.read_csv('iris.txt', sep='\t', na_values=".")["Species"])]
```


```python
# 色分けした Scatter Matrix を描く。
df = pd.read_csv('iris.txt', sep='\t', na_values=".") # データの読み込み
plotting.scatter_matrix(df[['Sepal.Length', 'Sepal.Width', 'Petal.Length', 'Petal.Width']], figsize=(10, 10), color=colors)   #データのプロット
plt.show()
```


![output_14_0.png](https://qiita-image-store.s3.amazonaws.com/0/211162/1e2effab-6751-a043-074a-70d514f10ab4.png)


### データの整形
Nをサンプル数、Mを特徴量の数とする。__data__から__target__を予測する問題を解く。
* __feature_names__ : 特徴量の名前（M次元のベクトル）
* __sample_names__ : サンプルの名前（N次元のベクトル）
* __target_names__ : 目的変数の名前（N次元のベクトル）
* __data__ : 説明変数（N行M列の行列）
* __target__ : 目的変数（N次元のベクトル）


```python
# 説明変数と目的変数に分ける。
data = []
target = []
feature_names = []
sample_names = []
target_names = []
for i, line in enumerate(open("iris.txt")):
    a = line.replace("\n", "").split("\t")
    if i == 0:
        for j, word in enumerate(a):
            if j == 0:
                continue
            elif j == len(a) - 1:
                continue
            else:
                feature_names.append(word)
    else:
        vec = []
        for j, word in enumerate(a):
            if j == 0:
                sample_names.append(word)
            elif j == len(a) - 1:
                word = word.strip()
                if word not in target_names:
                    target_names.append(word)
                target.append(target_names.index(word))
            else:
                vec.append(float(word))
        data.append(vec)
```


```python
# 名前の確認
print feature_names
print sample_names
print target_names
```

    ['Sepal.Length', 'Sepal.Width', 'Petal.Length', 'Petal.Width']
    ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100', '101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '111', '112', '113', '114', '115', '116', '117', '118', '119', '120', '121', '122', '123', '124', '125', '126', '127', '128', '129', '130', '131', '132', '133', '134', '135', '136', '137', '138', '139', '140', '141', '142', '143', '144', '145', '146', '147', '148', '149', '150']
    ['setosa', 'versicolor', 'virginica']



```python
# 説明変数の確認
print data
```

    [[5.1, 3.5, 1.4, 0.2], [4.9, 3.0, 1.4, 0.2], [4.7, 3.2, 1.3, 0.2], [4.6, 3.1, 1.5, 0.2], [5.0, 3.6, 1.4, 0.2], [5.4, 3.9, 1.7, 0.4], [4.6, 3.4, 1.4, 0.3], [5.0, 3.4, 1.5, 0.2], [4.4, 2.9, 1.4, 0.2], [4.9, 3.1, 1.5, 0.1], [5.4, 3.7, 1.5, 0.2], [4.8, 3.4, 1.6, 0.2], [4.8, 3.0, 1.4, 0.1], [4.3, 3.0, 1.1, 0.1], [5.8, 4.0, 1.2, 0.2], [5.7, 4.4, 1.5, 0.4], [5.4, 3.9, 1.3, 0.4], [5.1, 3.5, 1.4, 0.3], [5.7, 3.8, 1.7, 0.3], [5.1, 3.8, 1.5, 0.3], [5.4, 3.4, 1.7, 0.2], [5.1, 3.7, 1.5, 0.4], [4.6, 3.6, 1.0, 0.2], [5.1, 3.3, 1.7, 0.5], [4.8, 3.4, 1.9, 0.2], [5.0, 3.0, 1.6, 0.2], [5.0, 3.4, 1.6, 0.4], [5.2, 3.5, 1.5, 0.2], [5.2, 3.4, 1.4, 0.2], [4.7, 3.2, 1.6, 0.2], [4.8, 3.1, 1.6, 0.2], [5.4, 3.4, 1.5, 0.4], [5.2, 4.1, 1.5, 0.1], [5.5, 4.2, 1.4, 0.2], [4.9, 3.1, 1.5, 0.2], [5.0, 3.2, 1.2, 0.2], [5.5, 3.5, 1.3, 0.2], [4.9, 3.6, 1.4, 0.1], [4.4, 3.0, 1.3, 0.2], [5.1, 3.4, 1.5, 0.2], [5.0, 3.5, 1.3, 0.3], [4.5, 2.3, 1.3, 0.3], [4.4, 3.2, 1.3, 0.2], [5.0, 3.5, 1.6, 0.6], [5.1, 3.8, 1.9, 0.4], [4.8, 3.0, 1.4, 0.3], [5.1, 3.8, 1.6, 0.2], [4.6, 3.2, 1.4, 0.2], [5.3, 3.7, 1.5, 0.2], [5.0, 3.3, 1.4, 0.2], [7.0, 3.2, 4.7, 1.4], [6.4, 3.2, 4.5, 1.5], [6.9, 3.1, 4.9, 1.5], [5.5, 2.3, 4.0, 1.3], [6.5, 2.8, 4.6, 1.5], [5.7, 2.8, 4.5, 1.3], [6.3, 3.3, 4.7, 1.6], [4.9, 2.4, 3.3, 1.0], [6.6, 2.9, 4.6, 1.3], [5.2, 2.7, 3.9, 1.4], [5.0, 2.0, 3.5, 1.0], [5.9, 3.0, 4.2, 1.5], [6.0, 2.2, 4.0, 1.0], [6.1, 2.9, 4.7, 1.4], [5.6, 2.9, 3.6, 1.3], [6.7, 3.1, 4.4, 1.4], [5.6, 3.0, 4.5, 1.5], [5.8, 2.7, 4.1, 1.0], [6.2, 2.2, 4.5, 1.5], [5.6, 2.5, 3.9, 1.1], [5.9, 3.2, 4.8, 1.8], [6.1, 2.8, 4.0, 1.3], [6.3, 2.5, 4.9, 1.5], [6.1, 2.8, 4.7, 1.2], [6.4, 2.9, 4.3, 1.3], [6.6, 3.0, 4.4, 1.4], [6.8, 2.8, 4.8, 1.4], [6.7, 3.0, 5.0, 1.7], [6.0, 2.9, 4.5, 1.5], [5.7, 2.6, 3.5, 1.0], [5.5, 2.4, 3.8, 1.1], [5.5, 2.4, 3.7, 1.0], [5.8, 2.7, 3.9, 1.2], [6.0, 2.7, 5.1, 1.6], [5.4, 3.0, 4.5, 1.5], [6.0, 3.4, 4.5, 1.6], [6.7, 3.1, 4.7, 1.5], [6.3, 2.3, 4.4, 1.3], [5.6, 3.0, 4.1, 1.3], [5.5, 2.5, 4.0, 1.3], [5.5, 2.6, 4.4, 1.2], [6.1, 3.0, 4.6, 1.4], [5.8, 2.6, 4.0, 1.2], [5.0, 2.3, 3.3, 1.0], [5.6, 2.7, 4.2, 1.3], [5.7, 3.0, 4.2, 1.2], [5.7, 2.9, 4.2, 1.3], [6.2, 2.9, 4.3, 1.3], [5.1, 2.5, 3.0, 1.1], [5.7, 2.8, 4.1, 1.3], [6.3, 3.3, 6.0, 2.5], [5.8, 2.7, 5.1, 1.9], [7.1, 3.0, 5.9, 2.1], [6.3, 2.9, 5.6, 1.8], [6.5, 3.0, 5.8, 2.2], [7.6, 3.0, 6.6, 2.1], [4.9, 2.5, 4.5, 1.7], [7.3, 2.9, 6.3, 1.8], [6.7, 2.5, 5.8, 1.8], [7.2, 3.6, 6.1, 2.5], [6.5, 3.2, 5.1, 2.0], [6.4, 2.7, 5.3, 1.9], [6.8, 3.0, 5.5, 2.1], [5.7, 2.5, 5.0, 2.0], [5.8, 2.8, 5.1, 2.4], [6.4, 3.2, 5.3, 2.3], [6.5, 3.0, 5.5, 1.8], [7.7, 3.8, 6.7, 2.2], [7.7, 2.6, 6.9, 2.3], [6.0, 2.2, 5.0, 1.5], [6.9, 3.2, 5.7, 2.3], [5.6, 2.8, 4.9, 2.0], [7.7, 2.8, 6.7, 2.0], [6.3, 2.7, 4.9, 1.8], [6.7, 3.3, 5.7, 2.1], [7.2, 3.2, 6.0, 1.8], [6.2, 2.8, 4.8, 1.8], [6.1, 3.0, 4.9, 1.8], [6.4, 2.8, 5.6, 2.1], [7.2, 3.0, 5.8, 1.6], [7.4, 2.8, 6.1, 1.9], [7.9, 3.8, 6.4, 2.0], [6.4, 2.8, 5.6, 2.2], [6.3, 2.8, 5.1, 1.5], [6.1, 2.6, 5.6, 1.4], [7.7, 3.0, 6.1, 2.3], [6.3, 3.4, 5.6, 2.4], [6.4, 3.1, 5.5, 1.8], [6.0, 3.0, 4.8, 1.8], [6.9, 3.1, 5.4, 2.1], [6.7, 3.1, 5.6, 2.4], [6.9, 3.1, 5.1, 2.3], [5.8, 2.7, 5.1, 1.9], [6.8, 3.2, 5.9, 2.3], [6.7, 3.3, 5.7, 2.5], [6.7, 3.0, 5.2, 2.3], [6.3, 2.5, 5.0, 1.9], [6.5, 3.0, 5.2, 2.0], [6.2, 3.4, 5.4, 2.3], [5.9, 3.0, 5.1, 1.8]]



```python
# 目的変数の確認
print target
```

    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]


### データのシャッフル
* 今のままだと、同じ目的変数同士でサンプルが固まっているので、サンプルの順番をランダムに入れ替えます。


```python
# データをシャッフルする
p = range(len(sample_names)) # Python 2 の場合
# p = list(range(len(sample_names))) # Python 3 の場合
random.seed(0)
random.shuffle(p)
sample_names = list(np.array(sample_names)[p])
data = np.array(data)[p]
target = list(np.array(target)[p])
```


```python
# シャッフル後のデータを確認
print sample_names
```

    ['137', '29', '14', '142', '99', '138', '111', '125', '118', '40', '80', '91', '9', '70', '4', '139', '101', '55', '30', '17', '23', '3', '130', '135', '26', '61', '120', '108', '78', '73', '121', '21', '110', '100', '19', '33', '22', '115', '28', '144', '150', '143', '79', '105', '10', '6', '133', '12', '42', '69', '102', '114', '5', '43', '77', '62', '88', '72', '106', '90', '36', '56', '109', '134', '18', '47', '132', '123', '140', '148', '126', '67', '65', '57', '7', '37', '84', '82', '15', '16', '24', '48', '97', '86', '38', '51', '53', '136', '96', '74', '50', '66', '52', '11', '89', '49', '32', '8', '45', '81', '98', '25', '145', '20', '92', '35', '27', '94', '124', '1', '146', '93', '46', '141', '2', '64', '129', '31', '103', '58', '117', '112', '76', '54', '13', '60', '87', '116', '95', '41', '119', '107', '131', '122', '34', '85', '104', '147', '71', '128', '83', '68', '44', '149', '59', '75', '39', '63', '113', '127']



```python
# シャッフル後のデータを確認
print data
```

    [[ 6.3  3.4  5.6  2.4]
     [ 5.2  3.4  1.4  0.2]
     [ 4.3  3.   1.1  0.1]
     [ 6.9  3.1  5.1  2.3]
     [ 5.1  2.5  3.   1.1]
     [ 6.4  3.1  5.5  1.8]
     [ 6.5  3.2  5.1  2. ]
     [ 6.7  3.3  5.7  2.1]
     [ 7.7  3.8  6.7  2.2]
     [ 5.1  3.4  1.5  0.2]
     [ 5.7  2.6  3.5  1. ]
     [ 5.5  2.6  4.4  1.2]
     [ 4.4  2.9  1.4  0.2]
     [ 5.6  2.5  3.9  1.1]
     [ 4.6  3.1  1.5  0.2]
     [ 6.   3.   4.8  1.8]
     [ 6.3  3.3  6.   2.5]
     [ 6.5  2.8  4.6  1.5]
     [ 4.7  3.2  1.6  0.2]
     [ 5.4  3.9  1.3  0.4]
     [ 4.6  3.6  1.   0.2]
     [ 4.7  3.2  1.3  0.2]
     [ 7.2  3.   5.8  1.6]
     [ 6.1  2.6  5.6  1.4]
     [ 5.   3.   1.6  0.2]
     [ 5.   2.   3.5  1. ]
     [ 6.   2.2  5.   1.5]
     [ 7.3  2.9  6.3  1.8]
     [ 6.7  3.   5.   1.7]
     [ 6.3  2.5  4.9  1.5]
     [ 6.9  3.2  5.7  2.3]
     [ 5.4  3.4  1.7  0.2]
     [ 7.2  3.6  6.1  2.5]
     [ 5.7  2.8  4.1  1.3]
     [ 5.7  3.8  1.7  0.3]
     [ 5.2  4.1  1.5  0.1]
     [ 5.1  3.7  1.5  0.4]
     [ 5.8  2.8  5.1  2.4]
     [ 5.2  3.5  1.5  0.2]
     [ 6.8  3.2  5.9  2.3]
     [ 5.9  3.   5.1  1.8]
     [ 5.8  2.7  5.1  1.9]
     [ 6.   2.9  4.5  1.5]
     [ 6.5  3.   5.8  2.2]
     [ 4.9  3.1  1.5  0.1]
     [ 5.4  3.9  1.7  0.4]
     [ 6.4  2.8  5.6  2.2]
     [ 4.8  3.4  1.6  0.2]
     [ 4.5  2.3  1.3  0.3]
     [ 6.2  2.2  4.5  1.5]
     [ 5.8  2.7  5.1  1.9]
     [ 5.7  2.5  5.   2. ]
     [ 5.   3.6  1.4  0.2]
     [ 4.4  3.2  1.3  0.2]
     [ 6.8  2.8  4.8  1.4]
     [ 5.9  3.   4.2  1.5]
     [ 6.3  2.3  4.4  1.3]
     [ 6.1  2.8  4.   1.3]
     [ 7.6  3.   6.6  2.1]
     [ 5.5  2.5  4.   1.3]
     [ 5.   3.2  1.2  0.2]
     [ 5.7  2.8  4.5  1.3]
     [ 6.7  2.5  5.8  1.8]
     [ 6.3  2.8  5.1  1.5]
     [ 5.1  3.5  1.4  0.3]
     [ 5.1  3.8  1.6  0.2]
     [ 7.9  3.8  6.4  2. ]
     [ 7.7  2.8  6.7  2. ]
     [ 6.9  3.1  5.4  2.1]
     [ 6.5  3.   5.2  2. ]
     [ 7.2  3.2  6.   1.8]
     [ 5.6  3.   4.5  1.5]
     [ 5.6  2.9  3.6  1.3]
     [ 6.3  3.3  4.7  1.6]
     [ 4.6  3.4  1.4  0.3]
     [ 5.5  3.5  1.3  0.2]
     [ 6.   2.7  5.1  1.6]
     [ 5.5  2.4  3.7  1. ]
     [ 5.8  4.   1.2  0.2]
     [ 5.7  4.4  1.5  0.4]
     [ 5.1  3.3  1.7  0.5]
     [ 4.6  3.2  1.4  0.2]
     [ 5.7  2.9  4.2  1.3]
     [ 6.   3.4  4.5  1.6]
     [ 4.9  3.6  1.4  0.1]
     [ 7.   3.2  4.7  1.4]
     [ 6.9  3.1  4.9  1.5]
     [ 7.7  3.   6.1  2.3]
     [ 5.7  3.   4.2  1.2]
     [ 6.1  2.8  4.7  1.2]
     [ 5.   3.3  1.4  0.2]
     [ 6.7  3.1  4.4  1.4]
     [ 6.4  3.2  4.5  1.5]
     [ 5.4  3.7  1.5  0.2]
     [ 5.6  3.   4.1  1.3]
     [ 5.3  3.7  1.5  0.2]
     [ 5.4  3.4  1.5  0.4]
     [ 5.   3.4  1.5  0.2]
     [ 5.1  3.8  1.9  0.4]
     [ 5.5  2.4  3.8  1.1]
     [ 6.2  2.9  4.3  1.3]
     [ 4.8  3.4  1.9  0.2]
     [ 6.7  3.3  5.7  2.5]
     [ 5.1  3.8  1.5  0.3]
     [ 6.1  3.   4.6  1.4]
     [ 4.9  3.1  1.5  0.2]
     [ 5.   3.4  1.6  0.4]
     [ 5.   2.3  3.3  1. ]
     [ 6.3  2.7  4.9  1.8]
     [ 5.1  3.5  1.4  0.2]
     [ 6.7  3.   5.2  2.3]
     [ 5.8  2.6  4.   1.2]
     [ 4.8  3.   1.4  0.3]
     [ 6.7  3.1  5.6  2.4]
     [ 4.9  3.   1.4  0.2]
     [ 6.1  2.9  4.7  1.4]
     [ 6.4  2.8  5.6  2.1]
     [ 4.8  3.1  1.6  0.2]
     [ 7.1  3.   5.9  2.1]
     [ 4.9  2.4  3.3  1. ]
     [ 6.5  3.   5.5  1.8]
     [ 6.4  2.7  5.3  1.9]
     [ 6.6  3.   4.4  1.4]
     [ 5.5  2.3  4.   1.3]
     [ 4.8  3.   1.4  0.1]
     [ 5.2  2.7  3.9  1.4]
     [ 6.7  3.1  4.7  1.5]
     [ 6.4  3.2  5.3  2.3]
     [ 5.6  2.7  4.2  1.3]
     [ 5.   3.5  1.3  0.3]
     [ 7.7  2.6  6.9  2.3]
     [ 4.9  2.5  4.5  1.7]
     [ 7.4  2.8  6.1  1.9]
     [ 5.6  2.8  4.9  2. ]
     [ 5.5  4.2  1.4  0.2]
     [ 5.4  3.   4.5  1.5]
     [ 6.3  2.9  5.6  1.8]
     [ 6.3  2.5  5.   1.9]
     [ 5.9  3.2  4.8  1.8]
     [ 6.1  3.   4.9  1.8]
     [ 5.8  2.7  3.9  1.2]
     [ 5.8  2.7  4.1  1. ]
     [ 5.   3.5  1.6  0.6]
     [ 6.2  3.4  5.4  2.3]
     [ 6.6  2.9  4.6  1.3]
     [ 6.4  2.9  4.3  1.3]
     [ 4.4  3.   1.3  0.2]
     [ 6.   2.2  4.   1. ]
     [ 6.8  3.   5.5  2.1]
     [ 6.2  2.8  4.8  1.8]]



```python
# シャッフル後のデータを確認
print target
```

    [2, 0, 0, 2, 1, 2, 2, 2, 2, 0, 1, 1, 0, 1, 0, 2, 2, 1, 0, 0, 0, 0, 2, 2, 0, 1, 2, 2, 1, 1, 2, 0, 2, 1, 0, 0, 0, 2, 0, 2, 2, 2, 1, 2, 0, 0, 2, 0, 0, 1, 2, 2, 0, 0, 1, 1, 1, 1, 2, 1, 0, 1, 2, 2, 0, 0, 2, 2, 2, 2, 2, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 2, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 2, 0, 1, 0, 0, 1, 2, 0, 2, 1, 0, 2, 0, 1, 2, 0, 2, 1, 2, 2, 1, 1, 0, 1, 1, 2, 1, 0, 2, 2, 2, 2, 0, 1, 2, 2, 1, 2, 1, 1, 0, 2, 1, 1, 0, 1, 2, 2]


### データの分割
交差検定をするため、データを学習用とテスト用に分割します。
* __data_train__ :  説明変数（学習用）
* __data_test__ : 説明変数（テスト用）
* __target_train__ : 目的変数（学習用）
* __target_test__ :  目的変数（テスト用）

交差検定 (cross-validation) とは → [交差検定](http://image.slidesharecdn.com/scikit-learn-141201042924-conversion-gate01/95/scikit-learn-15-638.jpg)
* 現在取得できているデータを「学習用」と「テスト用」に分け、「学習用」だけを使って予測モデルを構築し、「評価用」を使ってモデルの性能を評価する。


```python
# データを分割。test_size=0.8 は、学習：テスト のデータ量比が 2:8 であることを指す。
data_train, data_test, target_train, target_test, sample_names_train, sample_names_test = train_test_split(
    data, target, sample_names, test_size=0.8, random_state=0)
```


```python
# 分割後のデータの確認（学習用）
print sample_names_train
print target_train
print data_train
```

    ['4', '76', '17', '73', '119', '69', '104', '81', '97', '16', '64', '75', '65', '82', '61', '48', '83', '44', '144', '106', '96', '126', '136', '22', '3', '40', '20', '123', '31', '12']
    [0, 1, 0, 1, 2, 1, 2, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 2, 2, 1, 2, 2, 0, 0, 0, 0, 2, 0, 0]
    [[ 4.6  3.1  1.5  0.2]
     [ 6.6  3.   4.4  1.4]
     [ 5.4  3.9  1.3  0.4]
     [ 6.3  2.5  4.9  1.5]
     [ 7.7  2.6  6.9  2.3]
     [ 6.2  2.2  4.5  1.5]
     [ 6.3  2.9  5.6  1.8]
     [ 5.5  2.4  3.8  1.1]
     [ 5.7  2.9  4.2  1.3]
     [ 5.7  4.4  1.5  0.4]
     [ 6.1  2.9  4.7  1.4]
     [ 6.4  2.9  4.3  1.3]
     [ 5.6  2.9  3.6  1.3]
     [ 5.5  2.4  3.7  1. ]
     [ 5.   2.   3.5  1. ]
     [ 4.6  3.2  1.4  0.2]
     [ 5.8  2.7  3.9  1.2]
     [ 5.   3.5  1.6  0.6]
     [ 6.8  3.2  5.9  2.3]
     [ 7.6  3.   6.6  2.1]
     [ 5.7  3.   4.2  1.2]
     [ 7.2  3.2  6.   1.8]
     [ 7.7  3.   6.1  2.3]
     [ 5.1  3.7  1.5  0.4]
     [ 4.7  3.2  1.3  0.2]
     [ 5.1  3.4  1.5  0.2]
     [ 5.1  3.8  1.5  0.3]
     [ 7.7  2.8  6.7  2. ]
     [ 4.8  3.1  1.6  0.2]
     [ 4.8  3.4  1.6  0.2]]



```python
# 分割後のデータの確認（テスト用）
print sample_names_test
print target_test
print data_test
```

    ['2', '109', '100', '94', '125', '98', '150', '53', '84', '67', '34', '114', '57', '77', '134', '115', '15', '50', '6', '101', '112', '132', '26', '118', '87', '130', '10', '8', '11', '120', '147', '38', '108', '116', '131', '90', '30', '86', '56', '52', '46', '14', '68', '105', '80', '36', '129', '59', '58', '124', '148', '85', '88', '24', '54', '122', '27', '39', '102', '63', '51', '121', '25', '89', '18', '74', '66', '60', '42', '70', '93', '49', '23', '139', '5', '142', '127', '45', '111', '140', '1', '32', '9', '145', '117', '92', '95', '133', '91', '146', '13', '143', '113', '29', '141', '128', '79', '99', '41', '55', '28', '138', '43', '149', '35', '137', '19', '78', '62', '37', '33', '135', '7', '21', '103', '72', '107', '47', '110', '71']
    [0, 2, 1, 1, 2, 1, 2, 1, 1, 1, 0, 2, 1, 1, 2, 2, 0, 0, 0, 2, 2, 2, 0, 2, 1, 2, 0, 0, 0, 2, 2, 0, 2, 2, 2, 1, 0, 1, 1, 1, 0, 0, 1, 2, 1, 0, 2, 1, 1, 2, 2, 1, 1, 0, 1, 2, 0, 0, 2, 1, 1, 2, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 2, 0, 2, 2, 0, 2, 2, 0, 0, 0, 2, 2, 1, 1, 2, 1, 2, 0, 2, 2, 0, 2, 2, 1, 1, 0, 1, 0, 2, 0, 2, 0, 2, 0, 1, 1, 0, 0, 2, 0, 0, 2, 1, 2, 0, 2, 1]
    [[ 4.9  3.   1.4  0.2]
     [ 6.7  2.5  5.8  1.8]
     [ 5.7  2.8  4.1  1.3]
     [ 5.   2.3  3.3  1. ]
     [ 6.7  3.3  5.7  2.1]
     [ 6.2  2.9  4.3  1.3]
     [ 5.9  3.   5.1  1.8]
     [ 6.9  3.1  4.9  1.5]
     [ 6.   2.7  5.1  1.6]
     [ 5.6  3.   4.5  1.5]
     [ 5.5  4.2  1.4  0.2]
     [ 5.7  2.5  5.   2. ]
     [ 6.3  3.3  4.7  1.6]
     [ 6.8  2.8  4.8  1.4]
     [ 6.3  2.8  5.1  1.5]
     [ 5.8  2.8  5.1  2.4]
     [ 5.8  4.   1.2  0.2]
     [ 5.   3.3  1.4  0.2]
     [ 5.4  3.9  1.7  0.4]
     [ 6.3  3.3  6.   2.5]
     [ 6.4  2.7  5.3  1.9]
     [ 7.9  3.8  6.4  2. ]
     [ 5.   3.   1.6  0.2]
     [ 7.7  3.8  6.7  2.2]
     [ 6.7  3.1  4.7  1.5]
     [ 7.2  3.   5.8  1.6]
     [ 4.9  3.1  1.5  0.1]
     [ 5.   3.4  1.5  0.2]
     [ 5.4  3.7  1.5  0.2]
     [ 6.   2.2  5.   1.5]
     [ 6.3  2.5  5.   1.9]
     [ 4.9  3.6  1.4  0.1]
     [ 7.3  2.9  6.3  1.8]
     [ 6.4  3.2  5.3  2.3]
     [ 7.4  2.8  6.1  1.9]
     [ 5.5  2.5  4.   1.3]
     [ 4.7  3.2  1.6  0.2]
     [ 6.   3.4  4.5  1.6]
     [ 5.7  2.8  4.5  1.3]
     [ 6.4  3.2  4.5  1.5]
     [ 4.8  3.   1.4  0.3]
     [ 4.3  3.   1.1  0.1]
     [ 5.8  2.7  4.1  1. ]
     [ 6.5  3.   5.8  2.2]
     [ 5.7  2.6  3.5  1. ]
     [ 5.   3.2  1.2  0.2]
     [ 6.4  2.8  5.6  2.1]
     [ 6.6  2.9  4.6  1.3]
     [ 4.9  2.4  3.3  1. ]
     [ 6.3  2.7  4.9  1.8]
     [ 6.5  3.   5.2  2. ]
     [ 5.4  3.   4.5  1.5]
     [ 6.3  2.3  4.4  1.3]
     [ 5.1  3.3  1.7  0.5]
     [ 5.5  2.3  4.   1.3]
     [ 5.6  2.8  4.9  2. ]
     [ 5.   3.4  1.6  0.4]
     [ 4.4  3.   1.3  0.2]
     [ 5.8  2.7  5.1  1.9]
     [ 6.   2.2  4.   1. ]
     [ 7.   3.2  4.7  1.4]
     [ 6.9  3.2  5.7  2.3]
     [ 4.8  3.4  1.9  0.2]
     [ 5.6  3.   4.1  1.3]
     [ 5.1  3.5  1.4  0.3]
     [ 6.1  2.8  4.7  1.2]
     [ 6.7  3.1  4.4  1.4]
     [ 5.2  2.7  3.9  1.4]
     [ 4.5  2.3  1.3  0.3]
     [ 5.6  2.5  3.9  1.1]
     [ 5.8  2.6  4.   1.2]
     [ 5.3  3.7  1.5  0.2]
     [ 4.6  3.6  1.   0.2]
     [ 6.   3.   4.8  1.8]
     [ 5.   3.6  1.4  0.2]
     [ 6.9  3.1  5.1  2.3]
     [ 6.2  2.8  4.8  1.8]
     [ 5.1  3.8  1.9  0.4]
     [ 6.5  3.2  5.1  2. ]
     [ 6.9  3.1  5.4  2.1]
     [ 5.1  3.5  1.4  0.2]
     [ 5.4  3.4  1.5  0.4]
     [ 4.4  2.9  1.4  0.2]
     [ 6.7  3.3  5.7  2.5]
     [ 6.5  3.   5.5  1.8]
     [ 6.1  3.   4.6  1.4]
     [ 5.6  2.7  4.2  1.3]
     [ 6.4  2.8  5.6  2.2]
     [ 5.5  2.6  4.4  1.2]
     [ 6.7  3.   5.2  2.3]
     [ 4.8  3.   1.4  0.1]
     [ 5.8  2.7  5.1  1.9]
     [ 6.8  3.   5.5  2.1]
     [ 5.2  3.4  1.4  0.2]
     [ 6.7  3.1  5.6  2.4]
     [ 6.1  3.   4.9  1.8]
     [ 6.   2.9  4.5  1.5]
     [ 5.1  2.5  3.   1.1]
     [ 5.   3.5  1.3  0.3]
     [ 6.5  2.8  4.6  1.5]
     [ 5.2  3.5  1.5  0.2]
     [ 6.4  3.1  5.5  1.8]
     [ 4.4  3.2  1.3  0.2]
     [ 6.2  3.4  5.4  2.3]
     [ 4.9  3.1  1.5  0.2]
     [ 6.3  3.4  5.6  2.4]
     [ 5.7  3.8  1.7  0.3]
     [ 6.7  3.   5.   1.7]
     [ 5.9  3.   4.2  1.5]
     [ 5.5  3.5  1.3  0.2]
     [ 5.2  4.1  1.5  0.1]
     [ 6.1  2.6  5.6  1.4]
     [ 4.6  3.4  1.4  0.3]
     [ 5.4  3.4  1.7  0.2]
     [ 7.1  3.   5.9  2.1]
     [ 6.1  2.8  4.   1.3]
     [ 4.9  2.5  4.5  1.7]
     [ 5.1  3.8  1.6  0.2]
     [ 7.2  3.6  6.1  2.5]
     [ 5.9  3.2  4.8  1.8]]


### SVMで学習・予測
学習用データ（ __data_train__ と __target_train__ ) の関係を学習して、テスト用データ( __data_test__ )から正解( __target_test__ ) を予測する、という流れになります。


```python
# Linear SVM で学習・予測
classifier = svm.SVC(kernel='linear', probability=True)
#probas = classifier.fit(data_train, target_train).predict_proba(data_test)
pred = classifier.fit(data_train, target_train).predict(data_test)
```


```python
# 予測結果
pd.DataFrame(pred).T
```




<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>0</th>
      <th>1</th>
      <th>2</th>
      <th>3</th>
      <th>4</th>
      <th>5</th>
      <th>6</th>
      <th>7</th>
      <th>8</th>
      <th>9</th>
      <th>...</th>
      <th>110</th>
      <th>111</th>
      <th>112</th>
      <th>113</th>
      <th>114</th>
      <th>115</th>
      <th>116</th>
      <th>117</th>
      <th>118</th>
      <th>119</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>0</td>
      <td>2</td>
      <td>1</td>
      <td>1</td>
      <td>2</td>
      <td>1</td>
      <td>1</td>
      <td>1</td>
      <td>1</td>
      <td>1</td>
      <td>...</td>
      <td>0</td>
      <td>1</td>
      <td>0</td>
      <td>0</td>
      <td>2</td>
      <td>1</td>
      <td>1</td>
      <td>0</td>
      <td>2</td>
      <td>1</td>
    </tr>
  </tbody>
</table>
<p>1 rows × 120 columns</p>
</div>




```python
#正解
pd.DataFrame(target_test).T
```




<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>0</th>
      <th>1</th>
      <th>2</th>
      <th>3</th>
      <th>4</th>
      <th>5</th>
      <th>6</th>
      <th>7</th>
      <th>8</th>
      <th>9</th>
      <th>...</th>
      <th>110</th>
      <th>111</th>
      <th>112</th>
      <th>113</th>
      <th>114</th>
      <th>115</th>
      <th>116</th>
      <th>117</th>
      <th>118</th>
      <th>119</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>0</td>
      <td>2</td>
      <td>1</td>
      <td>1</td>
      <td>2</td>
      <td>1</td>
      <td>2</td>
      <td>1</td>
      <td>1</td>
      <td>1</td>
      <td>...</td>
      <td>0</td>
      <td>2</td>
      <td>0</td>
      <td>0</td>
      <td>2</td>
      <td>1</td>
      <td>2</td>
      <td>0</td>
      <td>2</td>
      <td>1</td>
    </tr>
  </tbody>
</table>
<p>1 rows × 120 columns</p>
</div>



### 予測モデルの評価
性能評価の指標はたくさんありますが、とりあえず以下の５つは覚えておいてください。
* 正解率 (Accuracy) = (TP + TN) / (TP + FP + FN + TN)
* 適合率 (Precision) = TP / (TP + FP)
* 再現率 (Recall) = TP / (TP + FN)
* 特異度 (Specificity) = TN / (TN + FP)
* F値 (F-measure) = 2 x Precision x Recall / (Precision + Recall)

参考資料は右記→ [モデルの評価](http://image.slidesharecdn.com/random-140419010313-phpapp02/95/-23-638.jpg)

### 混同行列 (confusion matrix)
データの分類で、うまくできた・できなかった回数を数えた表


```python
# 予測と正解の比較。第一引数が行、第二引数が列を表す。
pd.DataFrame(confusion_matrix(pred, target_test))
```




<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>0</th>
      <th>1</th>
      <th>2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>39</td>
      <td>0</td>
      <td>0</td>
    </tr>
    <tr>
      <th>1</th>
      <td>0</td>
      <td>38</td>
      <td>18</td>
    </tr>
    <tr>
      <th>2</th>
      <td>0</td>
      <td>0</td>
      <td>25</td>
    </tr>
  </tbody>
</table>
</div>



### 正解率 (Accuracy) の計算


```python
# cv=5 で５分割クロスバリデーションし精度を計算
score=cv.cross_val_score(classifier,data,target,cv=5,n_jobs=-1)
print("Accuracy: {0:04.4f} (+/- {1:04.4f})".format(score.mean(),score.std()))
```

    Accuracy: 0.9667 (+/- 0.0365)


### AUPRスコア と AUCスコア
性能評価によく使われるのがAUPRスコアとAUCスコア
* __AUPRスコア__ : Precision-Recallカーブ下の面積。 → [Precision-Recallカーブの例](http://image.slidesharecdn.com/prmu201512slideshare-151222104106/95/201512prmu-80-638.jpg)
* __AUCスコア__ : ROCカーブ下の面積。→ [ROC曲線](http://image.slidesharecdn.com/collaborativefilteringwithr-130416090214-phpapp02/95/collaborativefilteringwith-r-29-638.jpg)・[ROC曲線](http://image.slidesharecdn.com/iir08ver-1-0-090405123213-phpapp02/95/iir-08-ver10-28-728.jpg)


```python
# AUPR や AUC スコアを出そうと思ったらターゲットをバイナリ（二値）にしないといけないっぽい。
# そこで、ラベルが2のものを無視して、ラベル0のものとラベル1のものを区別する。
data2 = []
target2 = []
for da, ta in zip(data, target):
    if ta == 2:
        continue
    data2.append(da)
    target2.append(ta)
```


```python
# 二値になっていることを確認
print target2
```

    [0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1]



```python
# データをシャッフル
p = range(len(data2))
random.seed(0)
random.shuffle(p)
sample_names = list(np.array(sample_names)[p])
data2 = np.array(data2)[p]
target2 = list(np.array(target2)[p])
```


```python
# データを分割。test_size=0.8 は、学習：テスト のデータ量比が 2:8 であることを指す。
data_train, data_test, target_train, target_test, sample_names_train, sample_names_test = train_test_split(
    data2, target2, sample_names, test_size=0.8, random_state=0)
```


```python
# Linear SVM で学習・予測
classifier = svm.SVC(kernel='linear', probability=True)
probas = classifier.fit(data_train, target_train).predict_proba(data_test)
pred = classifier.fit(data_train, target_train).predict(data_test)
```


```python
# AUPR score を出す。ラベル0とラベル1の区別は簡単
precision, recall, thresholds = precision_recall_curve(target_test, probas[:, 1])
area = auc(recall, precision)
print "AUPR score: %0.2f" % area
```

    AUPR score: 1.00



```python
# AUC scoreを出す。ラベル0とラベル1の区別は簡単
fpr, tpr, thresholds = roc_curve(target_test, probas[:, 1])
roc_auc = auc(fpr, tpr)
print "AUC score: %f" % roc_auc
```

    AUC score: 1.000000


### 予測が簡単すぎてツマラナイので、もう少し難しくします。


```python
# ラベルが0のものを無視して、ラベル1のものとラベル2のものを区別する。
# ラベルはバイナリ(0か1)でないといけないので、ここでは1のものを0と呼び、2のものを1と呼ぶように変換する。
data2 = []
target2 = []
for da, ta in zip(data, target):
    if ta == 0:
        continue
    data2.append(da)
    target2.append(ta - 1)
```


```python
# データをシャッフル
p = range(len(data2))
random.seed(0)
random.shuffle(p)
shuffled_sample_names = list(np.array(sample_names)[p])
shuffled_data = np.array(data2)[p]
shuffled_target = list(np.array(target2)[p])
```


```python
# データを分割。test_size=0.8 は、学習：テスト のデータ量比が 2:8 であることを指す。
data_train, data_test, target_train, target_test, sample_names_train, sample_names_test = train_test_split(
    data2, target2, sample_names, test_size=0.8, random_state=0)
```


```python
# Linear SVM で学習・予測
classifier = svm.SVC(kernel='linear', probability=True)
probas = classifier.fit(data_train, target_train).predict_proba(data_test)
pred = classifier.fit(data_train, target_train).predict(data_test)
```


```python
# AUPRスコアを出す
precision, recall, thresholds = precision_recall_curve(target_test, probas[:, 1])
area = auc(recall, precision)
print "AUPR score: %0.2f" % area
```

    AUPR score: 0.99



```python
# AUCスコアを出す。
fpr, tpr, thresholds = roc_curve(target_test, probas[:, 1])
roc_auc = auc(fpr, tpr)
print "ROC score : %f" % roc_auc
```

    ROC score : 0.988743



```python
# PR curve を描く
pl.clf()
pl.plot(recall, precision, label='Precision-Recall curve')
pl.xlabel('Recall')
pl.ylabel('Precision')
pl.ylim([0.0, 1.05])
pl.xlim([0.0, 1.0])
pl.title('Precision-Recall example: AUPR=%0.2f' % area)
pl.legend(loc="lower left")
pl.show()
```


![output_53_0.png](https://qiita-image-store.s3.amazonaws.com/0/211162/e1f82bee-6b7d-ffd3-f0d1-fd45b0b5ab78.png)



```python
# ROC curve を描く
pl.clf()
pl.plot(fpr, tpr, label='ROC curve (area = %0.2f)' % roc_auc)
pl.plot([0, 1], [0, 1], 'k--')
pl.xlim([0.0, 1.0])
pl.ylim([0.0, 1.0])
pl.xlabel('False Positive Rate')
pl.ylabel('True Positive Rate')
pl.title('Receiver operating characteristic example')
pl.legend(loc="lower right")
pl.show()
```


![output_54_0.png](https://qiita-image-store.s3.amazonaws.com/0/211162/9b6e6791-9149-ef47-b4a8-6cdfb2083e5c.png)


### まだ予測が簡単すぎてツマラナイので、さらに難しくします。


```python
# 予測を難しくするため、不要な特徴量（ノイズ）を加える
np.random.seed(0)
data2 = np.c_[data2, np.random.randn(len(target2), 96)]
```


```python
# 新しいデータを確認。
# 左の４列は元々のデータにあった数字なので、正しい分類に使える数字のはず。
# 右の96列はランダムなノイズなので、正しい分類には使えない数字のはず。
pd.DataFrame(data2)
```




<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>0</th>
      <th>1</th>
      <th>2</th>
      <th>3</th>
      <th>4</th>
      <th>5</th>
      <th>6</th>
      <th>7</th>
      <th>8</th>
      <th>9</th>
      <th>...</th>
      <th>90</th>
      <th>91</th>
      <th>92</th>
      <th>93</th>
      <th>94</th>
      <th>95</th>
      <th>96</th>
      <th>97</th>
      <th>98</th>
      <th>99</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>6.3</td>
      <td>3.4</td>
      <td>5.6</td>
      <td>2.4</td>
      <td>1.764052</td>
      <td>0.400157</td>
      <td>0.978738</td>
      <td>2.240893</td>
      <td>1.867558</td>
      <td>-0.977278</td>
      <td>...</td>
      <td>1.178780</td>
      <td>-0.179925</td>
      <td>-1.070753</td>
      <td>1.054452</td>
      <td>-0.403177</td>
      <td>1.222445</td>
      <td>0.208275</td>
      <td>0.976639</td>
      <td>0.356366</td>
      <td>0.706573</td>
    </tr>
    <tr>
      <th>1</th>
      <td>6.9</td>
      <td>3.1</td>
      <td>5.1</td>
      <td>2.3</td>
      <td>0.010500</td>
      <td>1.785870</td>
      <td>0.126912</td>
      <td>0.401989</td>
      <td>1.883151</td>
      <td>-1.347759</td>
      <td>...</td>
      <td>-0.643618</td>
      <td>-2.223403</td>
      <td>0.625231</td>
      <td>-1.602058</td>
      <td>-1.104383</td>
      <td>0.052165</td>
      <td>-0.739563</td>
      <td>1.543015</td>
      <td>-1.292857</td>
      <td>0.267051</td>
    </tr>
    <tr>
      <th>2</th>
      <td>5.1</td>
      <td>2.5</td>
      <td>3.0</td>
      <td>1.1</td>
      <td>-0.039283</td>
      <td>-1.168093</td>
      <td>0.523277</td>
      <td>-0.171546</td>
      <td>0.771791</td>
      <td>0.823504</td>
      <td>...</td>
      <td>-2.030684</td>
      <td>2.064493</td>
      <td>-0.110541</td>
      <td>1.020173</td>
      <td>-0.692050</td>
      <td>1.536377</td>
      <td>0.286344</td>
      <td>0.608844</td>
      <td>-1.045253</td>
      <td>1.211145</td>
    </tr>
    <tr>
      <th>3</th>
      <td>6.4</td>
      <td>3.1</td>
      <td>5.5</td>
      <td>1.8</td>
      <td>0.689818</td>
      <td>1.301846</td>
      <td>-0.628088</td>
      <td>-0.481027</td>
      <td>2.303917</td>
      <td>-1.060016</td>
      <td>...</td>
      <td>0.049495</td>
      <td>0.493837</td>
      <td>0.643314</td>
      <td>-1.570623</td>
      <td>-0.206904</td>
      <td>0.880179</td>
      <td>-1.698106</td>
      <td>0.387280</td>
      <td>-2.255564</td>
      <td>-1.022507</td>
    </tr>
    <tr>
      <th>4</th>
      <td>6.5</td>
      <td>3.2</td>
      <td>5.1</td>
      <td>2.0</td>
      <td>0.038631</td>
      <td>-1.656715</td>
      <td>-0.985511</td>
      <td>-1.471835</td>
      <td>1.648135</td>
      <td>0.164228</td>
      <td>...</td>
      <td>-2.016407</td>
      <td>-0.539455</td>
      <td>-0.275671</td>
      <td>-0.709728</td>
      <td>1.738873</td>
      <td>0.994394</td>
      <td>1.319137</td>
      <td>-0.882419</td>
      <td>1.128594</td>
      <td>0.496001</td>
    </tr>
    <tr>
      <th>5</th>
      <td>6.7</td>
      <td>3.3</td>
      <td>5.7</td>
      <td>2.1</td>
      <td>0.771406</td>
      <td>1.029439</td>
      <td>-0.908763</td>
      <td>-0.424318</td>
      <td>0.862596</td>
      <td>-2.655619</td>
      <td>...</td>
      <td>0.354758</td>
      <td>0.616887</td>
      <td>0.008628</td>
      <td>0.527004</td>
      <td>0.453782</td>
      <td>-1.829740</td>
      <td>0.037006</td>
      <td>0.767902</td>
      <td>0.589880</td>
      <td>-0.363859</td>
    </tr>
    <tr>
      <th>6</th>
      <td>7.7</td>
      <td>3.8</td>
      <td>6.7</td>
      <td>2.2</td>
      <td>-0.805627</td>
      <td>-1.118312</td>
      <td>-0.131054</td>
      <td>1.133080</td>
      <td>-1.951804</td>
      <td>-0.659892</td>
      <td>...</td>
      <td>0.452489</td>
      <td>0.097896</td>
      <td>-0.448165</td>
      <td>-0.649338</td>
      <td>-0.023423</td>
      <td>1.079195</td>
      <td>-2.004216</td>
      <td>0.376877</td>
      <td>-0.545712</td>
      <td>-1.884586</td>
    </tr>
    <tr>
      <th>7</th>
      <td>5.7</td>
      <td>2.6</td>
      <td>3.5</td>
      <td>1.0</td>
      <td>-1.945703</td>
      <td>-0.912783</td>
      <td>0.219510</td>
      <td>0.393063</td>
      <td>-0.938982</td>
      <td>1.017021</td>
      <td>...</td>
      <td>0.039767</td>
      <td>-1.566995</td>
      <td>-0.451303</td>
      <td>0.265688</td>
      <td>0.723100</td>
      <td>0.024612</td>
      <td>0.719984</td>
      <td>-1.102906</td>
      <td>-0.101697</td>
      <td>0.019279</td>
    </tr>
    <tr>
      <th>8</th>
      <td>5.5</td>
      <td>2.6</td>
      <td>4.4</td>
      <td>1.2</td>
      <td>1.849591</td>
      <td>-0.214167</td>
      <td>-0.499017</td>
      <td>0.021351</td>
      <td>-0.919113</td>
      <td>0.192754</td>
      <td>...</td>
      <td>-1.032643</td>
      <td>-0.436748</td>
      <td>-1.642965</td>
      <td>-0.406072</td>
      <td>-0.535270</td>
      <td>0.025405</td>
      <td>1.154184</td>
      <td>0.172504</td>
      <td>0.021062</td>
      <td>0.099454</td>
    </tr>
    <tr>
      <th>9</th>
      <td>5.6</td>
      <td>2.5</td>
      <td>3.9</td>
      <td>1.1</td>
      <td>0.227393</td>
      <td>-1.016739</td>
      <td>-0.114775</td>
      <td>0.308751</td>
      <td>-1.370760</td>
      <td>0.865653</td>
      <td>...</td>
      <td>-0.947489</td>
      <td>0.244443</td>
      <td>1.401345</td>
      <td>-0.410382</td>
      <td>0.528944</td>
      <td>0.246148</td>
      <td>0.863520</td>
      <td>-0.804754</td>
      <td>2.346647</td>
      <td>-1.279161</td>
    </tr>
    <tr>
      <th>10</th>
      <td>6.0</td>
      <td>3.0</td>
      <td>4.8</td>
      <td>1.8</td>
      <td>-0.365551</td>
      <td>0.938093</td>
      <td>0.296733</td>
      <td>0.829986</td>
      <td>-0.496102</td>
      <td>-0.074805</td>
      <td>...</td>
      <td>0.435546</td>
      <td>-0.599224</td>
      <td>0.033090</td>
      <td>-0.854161</td>
      <td>-0.719941</td>
      <td>-0.893574</td>
      <td>-0.156024</td>
      <td>1.049093</td>
      <td>3.170975</td>
      <td>0.189500</td>
    </tr>
    <tr>
      <th>11</th>
      <td>6.3</td>
      <td>3.3</td>
      <td>6.0</td>
      <td>2.5</td>
      <td>-1.348413</td>
      <td>1.264983</td>
      <td>-0.300784</td>
      <td>-0.660609</td>
      <td>0.209849</td>
      <td>-1.240625</td>
      <td>...</td>
      <td>1.518759</td>
      <td>-1.171160</td>
      <td>0.764497</td>
      <td>-0.268373</td>
      <td>-0.169758</td>
      <td>-0.134133</td>
      <td>1.221385</td>
      <td>-0.192842</td>
      <td>-0.033319</td>
      <td>-1.530803</td>
    </tr>
    <tr>
      <th>12</th>
      <td>6.5</td>
      <td>2.8</td>
      <td>4.6</td>
      <td>1.5</td>
      <td>0.206691</td>
      <td>0.531043</td>
      <td>0.239146</td>
      <td>1.397896</td>
      <td>0.055171</td>
      <td>0.298977</td>
      <td>...</td>
      <td>-0.549499</td>
      <td>-1.098571</td>
      <td>2.320800</td>
      <td>0.117091</td>
      <td>0.534201</td>
      <td>0.317885</td>
      <td>0.434808</td>
      <td>0.540094</td>
      <td>0.732424</td>
      <td>-0.375222</td>
    </tr>
    <tr>
      <th>13</th>
      <td>7.2</td>
      <td>3.0</td>
      <td>5.8</td>
      <td>1.6</td>
      <td>-0.291642</td>
      <td>-1.741023</td>
      <td>-0.780304</td>
      <td>0.271113</td>
      <td>1.045023</td>
      <td>0.599040</td>
      <td>...</td>
      <td>-0.612626</td>
      <td>-0.822828</td>
      <td>-1.490265</td>
      <td>1.496140</td>
      <td>-0.972403</td>
      <td>1.346221</td>
      <td>-0.467493</td>
      <td>-0.862493</td>
      <td>0.622519</td>
      <td>-0.631192</td>
    </tr>
    <tr>
      <th>14</th>
      <td>6.1</td>
      <td>2.6</td>
      <td>5.6</td>
      <td>1.4</td>
      <td>0.568459</td>
      <td>-0.332812</td>
      <td>0.480424</td>
      <td>-0.968186</td>
      <td>0.831351</td>
      <td>0.487973</td>
      <td>...</td>
      <td>0.665967</td>
      <td>-2.534554</td>
      <td>-1.375184</td>
      <td>0.500992</td>
      <td>-0.480249</td>
      <td>0.936108</td>
      <td>0.809180</td>
      <td>-1.198093</td>
      <td>0.406657</td>
      <td>1.201698</td>
    </tr>
    <tr>
      <th>15</th>
      <td>5.0</td>
      <td>2.0</td>
      <td>3.5</td>
      <td>1.0</td>
      <td>0.147434</td>
      <td>-0.977465</td>
      <td>0.879390</td>
      <td>0.635425</td>
      <td>0.542611</td>
      <td>0.715939</td>
      <td>...</td>
      <td>-0.104980</td>
      <td>1.367415</td>
      <td>-1.655344</td>
      <td>0.153644</td>
      <td>-1.584474</td>
      <td>0.844454</td>
      <td>-1.212868</td>
      <td>0.283770</td>
      <td>-0.282196</td>
      <td>-1.158203</td>
    </tr>
    <tr>
      <th>16</th>
      <td>6.0</td>
      <td>2.2</td>
      <td>5.0</td>
      <td>1.5</td>
      <td>-1.619360</td>
      <td>-0.511040</td>
      <td>1.740629</td>
      <td>-0.293485</td>
      <td>0.917222</td>
      <td>-0.057043</td>
      <td>...</td>
      <td>-0.796775</td>
      <td>1.548067</td>
      <td>-0.061743</td>
      <td>-0.446836</td>
      <td>-0.183756</td>
      <td>0.824618</td>
      <td>-1.312850</td>
      <td>1.414874</td>
      <td>0.156476</td>
      <td>-0.216344</td>
    </tr>
    <tr>
      <th>17</th>
      <td>7.3</td>
      <td>2.9</td>
      <td>6.3</td>
      <td>1.8</td>
      <td>0.442846</td>
      <td>0.218397</td>
      <td>-0.344196</td>
      <td>-0.252711</td>
      <td>-0.868863</td>
      <td>0.656391</td>
      <td>...</td>
      <td>0.246649</td>
      <td>0.607993</td>
      <td>-0.839632</td>
      <td>-1.368245</td>
      <td>1.561280</td>
      <td>-0.940270</td>
      <td>-0.659943</td>
      <td>0.213017</td>
      <td>0.599369</td>
      <td>-0.256317</td>
    </tr>
    <tr>
      <th>18</th>
      <td>6.7</td>
      <td>3.0</td>
      <td>5.0</td>
      <td>1.7</td>
      <td>0.460794</td>
      <td>-0.400986</td>
      <td>-0.971171</td>
      <td>1.426317</td>
      <td>2.488442</td>
      <td>1.695970</td>
      <td>...</td>
      <td>-0.762362</td>
      <td>-1.446940</td>
      <td>2.620574</td>
      <td>-0.747473</td>
      <td>-1.300347</td>
      <td>-0.803850</td>
      <td>-0.774295</td>
      <td>-0.269390</td>
      <td>0.825372</td>
      <td>-0.298323</td>
    </tr>
    <tr>
      <th>19</th>
      <td>6.3</td>
      <td>2.5</td>
      <td>4.9</td>
      <td>1.5</td>
      <td>-0.922823</td>
      <td>-1.451338</td>
      <td>0.021857</td>
      <td>0.042539</td>
      <td>1.530932</td>
      <td>0.092448</td>
      <td>...</td>
      <td>1.257744</td>
      <td>-2.086635</td>
      <td>0.040071</td>
      <td>-0.327755</td>
      <td>1.455808</td>
      <td>0.055492</td>
      <td>1.484926</td>
      <td>-2.123890</td>
      <td>0.459585</td>
      <td>0.280058</td>
    </tr>
    <tr>
      <th>20</th>
      <td>6.9</td>
      <td>3.2</td>
      <td>5.7</td>
      <td>2.3</td>
      <td>1.390534</td>
      <td>-1.641349</td>
      <td>-0.155036</td>
      <td>0.066060</td>
      <td>-0.495795</td>
      <td>1.216578</td>
      <td>...</td>
      <td>-0.770784</td>
      <td>-0.480845</td>
      <td>0.703586</td>
      <td>0.929145</td>
      <td>0.371173</td>
      <td>-0.989823</td>
      <td>0.643631</td>
      <td>0.688897</td>
      <td>0.274647</td>
      <td>-0.603620</td>
    </tr>
    <tr>
      <th>21</th>
      <td>7.2</td>
      <td>3.6</td>
      <td>6.1</td>
      <td>2.5</td>
      <td>0.708860</td>
      <td>0.422819</td>
      <td>-3.116857</td>
      <td>0.644452</td>
      <td>-1.913743</td>
      <td>0.663562</td>
      <td>...</td>
      <td>0.409552</td>
      <td>-0.799593</td>
      <td>1.511639</td>
      <td>1.706468</td>
      <td>0.701783</td>
      <td>0.073285</td>
      <td>-0.461894</td>
      <td>-0.626490</td>
      <td>1.710837</td>
      <td>1.414415</td>
    </tr>
    <tr>
      <th>22</th>
      <td>5.7</td>
      <td>2.8</td>
      <td>4.1</td>
      <td>1.3</td>
      <td>-0.063661</td>
      <td>-1.579931</td>
      <td>-2.832012</td>
      <td>-1.083427</td>
      <td>-0.130620</td>
      <td>1.400689</td>
      <td>...</td>
      <td>-1.098289</td>
      <td>0.572613</td>
      <td>-0.861216</td>
      <td>-0.509595</td>
      <td>1.098582</td>
      <td>-0.127067</td>
      <td>0.813452</td>
      <td>0.473291</td>
      <td>0.753866</td>
      <td>-0.888188</td>
    </tr>
    <tr>
      <th>23</th>
      <td>5.8</td>
      <td>2.8</td>
      <td>5.1</td>
      <td>2.4</td>
      <td>-0.221574</td>
      <td>0.424253</td>
      <td>-0.849073</td>
      <td>1.629500</td>
      <td>-0.777228</td>
      <td>-0.300004</td>
      <td>...</td>
      <td>2.464322</td>
      <td>0.193832</td>
      <td>1.132005</td>
      <td>-0.560981</td>
      <td>-1.362941</td>
      <td>-0.791757</td>
      <td>-0.268010</td>
      <td>-0.496608</td>
      <td>1.336386</td>
      <td>-0.120041</td>
    </tr>
    <tr>
      <th>24</th>
      <td>6.8</td>
      <td>3.2</td>
      <td>5.9</td>
      <td>2.3</td>
      <td>0.461469</td>
      <td>-0.046481</td>
      <td>-0.433554</td>
      <td>0.037996</td>
      <td>1.714051</td>
      <td>-0.767949</td>
      <td>...</td>
      <td>-0.110591</td>
      <td>-0.432432</td>
      <td>1.077037</td>
      <td>-0.224827</td>
      <td>-0.576242</td>
      <td>0.574609</td>
      <td>-0.489828</td>
      <td>0.658802</td>
      <td>-0.596917</td>
      <td>-0.222959</td>
    </tr>
    <tr>
      <th>25</th>
      <td>5.9</td>
      <td>3.0</td>
      <td>5.1</td>
      <td>1.8</td>
      <td>0.152177</td>
      <td>-0.374126</td>
      <td>-0.013451</td>
      <td>0.815472</td>
      <td>0.410602</td>
      <td>0.480970</td>
      <td>...</td>
      <td>0.704643</td>
      <td>0.155591</td>
      <td>0.936795</td>
      <td>0.770331</td>
      <td>0.140811</td>
      <td>0.473488</td>
      <td>1.855246</td>
      <td>1.415656</td>
      <td>-0.302746</td>
      <td>0.989679</td>
    </tr>
    <tr>
      <th>26</th>
      <td>5.8</td>
      <td>2.7</td>
      <td>5.1</td>
      <td>1.9</td>
      <td>0.585851</td>
      <td>1.136388</td>
      <td>0.671617</td>
      <td>-0.974167</td>
      <td>-1.619685</td>
      <td>0.572627</td>
      <td>...</td>
      <td>0.295779</td>
      <td>0.842589</td>
      <td>0.245616</td>
      <td>-0.032996</td>
      <td>-1.562014</td>
      <td>1.006107</td>
      <td>-0.044045</td>
      <td>1.959562</td>
      <td>0.942314</td>
      <td>-2.005125</td>
    </tr>
    <tr>
      <th>27</th>
      <td>6.0</td>
      <td>2.9</td>
      <td>4.5</td>
      <td>1.5</td>
      <td>0.755050</td>
      <td>-1.396535</td>
      <td>-0.759495</td>
      <td>-0.250757</td>
      <td>-0.094062</td>
      <td>0.397565</td>
      <td>...</td>
      <td>-0.875155</td>
      <td>-0.593520</td>
      <td>0.662005</td>
      <td>-0.340874</td>
      <td>-1.519974</td>
      <td>-0.216533</td>
      <td>-0.784221</td>
      <td>0.731294</td>
      <td>-0.343235</td>
      <td>0.070774</td>
    </tr>
    <tr>
      <th>28</th>
      <td>6.5</td>
      <td>3.0</td>
      <td>5.8</td>
      <td>2.2</td>
      <td>-0.405472</td>
      <td>0.433939</td>
      <td>-0.183591</td>
      <td>0.325199</td>
      <td>-2.593389</td>
      <td>0.097251</td>
      <td>...</td>
      <td>0.100564</td>
      <td>-0.954943</td>
      <td>-1.470402</td>
      <td>1.010428</td>
      <td>0.496179</td>
      <td>0.576956</td>
      <td>-1.107647</td>
      <td>0.234977</td>
      <td>0.629000</td>
      <td>0.314034</td>
    </tr>
    <tr>
      <th>29</th>
      <td>6.4</td>
      <td>2.8</td>
      <td>5.6</td>
      <td>2.2</td>
      <td>-0.745023</td>
      <td>1.012261</td>
      <td>-1.527632</td>
      <td>0.928742</td>
      <td>1.081056</td>
      <td>1.572330</td>
      <td>...</td>
      <td>0.826126</td>
      <td>-0.057757</td>
      <td>-0.726712</td>
      <td>-0.217163</td>
      <td>0.136031</td>
      <td>-0.838311</td>
      <td>0.561450</td>
      <td>-1.259596</td>
      <td>-0.332759</td>
      <td>-0.204008</td>
    </tr>
    <tr>
      <th>...</th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
    <tr>
      <th>70</th>
      <td>6.7</td>
      <td>3.1</td>
      <td>5.6</td>
      <td>2.4</td>
      <td>-0.881016</td>
      <td>-0.676689</td>
      <td>0.071754</td>
      <td>-0.094366</td>
      <td>-0.881015</td>
      <td>1.513925</td>
      <td>...</td>
      <td>-0.306563</td>
      <td>0.367911</td>
      <td>1.268154</td>
      <td>0.065453</td>
      <td>0.834569</td>
      <td>-1.115651</td>
      <td>0.847658</td>
      <td>0.238571</td>
      <td>-0.463588</td>
      <td>-1.145754</td>
    </tr>
    <tr>
      <th>71</th>
      <td>6.1</td>
      <td>2.9</td>
      <td>4.7</td>
      <td>1.4</td>
      <td>-0.018751</td>
      <td>0.538716</td>
      <td>0.254868</td>
      <td>-0.091577</td>
      <td>1.068479</td>
      <td>1.085213</td>
      <td>...</td>
      <td>-0.194306</td>
      <td>-1.368116</td>
      <td>-1.163993</td>
      <td>0.430824</td>
      <td>0.133907</td>
      <td>-0.811671</td>
      <td>-0.528279</td>
      <td>0.462801</td>
      <td>1.313237</td>
      <td>0.833175</td>
    </tr>
    <tr>
      <th>72</th>
      <td>6.4</td>
      <td>2.8</td>
      <td>5.6</td>
      <td>2.1</td>
      <td>-0.201892</td>
      <td>0.093311</td>
      <td>-1.009972</td>
      <td>0.417053</td>
      <td>0.433208</td>
      <td>-0.200063</td>
      <td>...</td>
      <td>-1.032532</td>
      <td>-0.901072</td>
      <td>-0.514878</td>
      <td>0.417854</td>
      <td>-2.048833</td>
      <td>-0.989744</td>
      <td>-0.338294</td>
      <td>1.503827</td>
      <td>-0.258209</td>
      <td>-0.154596</td>
    </tr>
    <tr>
      <th>73</th>
      <td>7.1</td>
      <td>3.0</td>
      <td>5.9</td>
      <td>2.1</td>
      <td>-1.655827</td>
      <td>-0.093555</td>
      <td>-1.090081</td>
      <td>0.778008</td>
      <td>2.168954</td>
      <td>0.587482</td>
      <td>...</td>
      <td>-0.178279</td>
      <td>0.923813</td>
      <td>0.714544</td>
      <td>-1.021254</td>
      <td>0.232299</td>
      <td>-0.154917</td>
      <td>-0.399993</td>
      <td>-2.658387</td>
      <td>-1.003429</td>
      <td>1.389284</td>
    </tr>
    <tr>
      <th>74</th>
      <td>4.9</td>
      <td>2.4</td>
      <td>3.3</td>
      <td>1.0</td>
      <td>-0.071352</td>
      <td>0.138888</td>
      <td>-0.096762</td>
      <td>0.403115</td>
      <td>0.628149</td>
      <td>0.567997</td>
      <td>...</td>
      <td>-0.426025</td>
      <td>-0.869334</td>
      <td>0.332105</td>
      <td>-0.223230</td>
      <td>0.185918</td>
      <td>0.075560</td>
      <td>0.481256</td>
      <td>0.080554</td>
      <td>-0.188178</td>
      <td>-1.311192</td>
    </tr>
    <tr>
      <th>75</th>
      <td>6.5</td>
      <td>3.0</td>
      <td>5.5</td>
      <td>1.8</td>
      <td>-0.088724</td>
      <td>1.512770</td>
      <td>0.573708</td>
      <td>-0.541004</td>
      <td>0.101177</td>
      <td>0.994552</td>
      <td>...</td>
      <td>-1.214615</td>
      <td>-0.363353</td>
      <td>-1.016375</td>
      <td>0.816155</td>
      <td>-2.642065</td>
      <td>-0.999590</td>
      <td>-0.684297</td>
      <td>-1.378620</td>
      <td>-0.116662</td>
      <td>-0.500927</td>
    </tr>
    <tr>
      <th>76</th>
      <td>6.4</td>
      <td>2.7</td>
      <td>5.3</td>
      <td>1.9</td>
      <td>1.304927</td>
      <td>-1.170061</td>
      <td>0.427337</td>
      <td>-0.486877</td>
      <td>-0.939968</td>
      <td>0.193671</td>
      <td>...</td>
      <td>-0.243211</td>
      <td>-0.137261</td>
      <td>0.523465</td>
      <td>-1.265604</td>
      <td>0.480674</td>
      <td>3.003123</td>
      <td>-0.151272</td>
      <td>-0.724395</td>
      <td>0.038790</td>
      <td>-0.119819</td>
    </tr>
    <tr>
      <th>77</th>
      <td>6.6</td>
      <td>3.0</td>
      <td>4.4</td>
      <td>1.4</td>
      <td>0.820849</td>
      <td>-1.007497</td>
      <td>-0.667793</td>
      <td>0.048303</td>
      <td>0.175038</td>
      <td>0.208316</td>
      <td>...</td>
      <td>-1.266621</td>
      <td>1.586552</td>
      <td>0.061099</td>
      <td>-0.177095</td>
      <td>-0.585432</td>
      <td>-0.438535</td>
      <td>0.017596</td>
      <td>1.331462</td>
      <td>1.584075</td>
      <td>-0.323664</td>
    </tr>
    <tr>
      <th>78</th>
      <td>5.5</td>
      <td>2.3</td>
      <td>4.0</td>
      <td>1.3</td>
      <td>2.341122</td>
      <td>-0.613557</td>
      <td>0.924924</td>
      <td>-0.223781</td>
      <td>0.891121</td>
      <td>0.145156</td>
      <td>...</td>
      <td>0.142588</td>
      <td>0.887803</td>
      <td>1.384392</td>
      <td>-2.063531</td>
      <td>0.418131</td>
      <td>-1.678002</td>
      <td>2.865602</td>
      <td>-0.675515</td>
      <td>-1.213975</td>
      <td>-1.723544</td>
    </tr>
    <tr>
      <th>79</th>
      <td>5.2</td>
      <td>2.7</td>
      <td>3.9</td>
      <td>1.4</td>
      <td>-0.011559</td>
      <td>-1.283446</td>
      <td>0.660915</td>
      <td>-0.115704</td>
      <td>0.300711</td>
      <td>-0.961867</td>
      <td>...</td>
      <td>1.438354</td>
      <td>-1.400189</td>
      <td>-1.954720</td>
      <td>-0.758857</td>
      <td>0.119426</td>
      <td>0.736410</td>
      <td>-0.665872</td>
      <td>-0.052111</td>
      <td>0.142015</td>
      <td>-1.200824</td>
    </tr>
    <tr>
      <th>80</th>
      <td>6.7</td>
      <td>3.1</td>
      <td>4.7</td>
      <td>1.5</td>
      <td>-0.014129</td>
      <td>0.172282</td>
      <td>1.018502</td>
      <td>0.362555</td>
      <td>-0.219281</td>
      <td>0.685341</td>
      <td>...</td>
      <td>1.654254</td>
      <td>-1.763229</td>
      <td>-1.941552</td>
      <td>-1.190738</td>
      <td>-0.004849</td>
      <td>0.422242</td>
      <td>0.034198</td>
      <td>1.521315</td>
      <td>-0.176605</td>
      <td>0.224400</td>
    </tr>
    <tr>
      <th>81</th>
      <td>6.4</td>
      <td>3.2</td>
      <td>5.3</td>
      <td>2.3</td>
      <td>0.728263</td>
      <td>0.115932</td>
      <td>-1.415487</td>
      <td>0.316568</td>
      <td>0.878322</td>
      <td>-1.156103</td>
      <td>...</td>
      <td>-0.142926</td>
      <td>-0.014118</td>
      <td>-0.541292</td>
      <td>0.915340</td>
      <td>0.768111</td>
      <td>0.101635</td>
      <td>0.809442</td>
      <td>0.000456</td>
      <td>-0.226717</td>
      <td>1.281717</td>
    </tr>
    <tr>
      <th>82</th>
      <td>5.6</td>
      <td>2.7</td>
      <td>4.2</td>
      <td>1.3</td>
      <td>-0.073499</td>
      <td>1.069635</td>
      <td>0.792015</td>
      <td>0.339708</td>
      <td>0.633513</td>
      <td>-0.312690</td>
      <td>...</td>
      <td>1.193671</td>
      <td>0.142021</td>
      <td>0.990304</td>
      <td>1.024855</td>
      <td>0.781983</td>
      <td>-1.515585</td>
      <td>-0.120473</td>
      <td>-0.264603</td>
      <td>-0.478156</td>
      <td>-1.257802</td>
    </tr>
    <tr>
      <th>83</th>
      <td>7.7</td>
      <td>2.6</td>
      <td>6.9</td>
      <td>2.3</td>
      <td>-0.887962</td>
      <td>0.883404</td>
      <td>0.368100</td>
      <td>-0.345552</td>
      <td>-0.108353</td>
      <td>0.836264</td>
      <td>...</td>
      <td>-0.774274</td>
      <td>1.214965</td>
      <td>0.760617</td>
      <td>0.317108</td>
      <td>-0.167219</td>
      <td>0.123047</td>
      <td>-0.534006</td>
      <td>-0.062328</td>
      <td>0.499380</td>
      <td>-0.611262</td>
    </tr>
    <tr>
      <th>84</th>
      <td>4.9</td>
      <td>2.5</td>
      <td>4.5</td>
      <td>1.7</td>
      <td>0.227978</td>
      <td>-1.263296</td>
      <td>-1.077302</td>
      <td>0.360745</td>
      <td>-0.257662</td>
      <td>0.781847</td>
      <td>...</td>
      <td>-2.124691</td>
      <td>1.672370</td>
      <td>-0.716988</td>
      <td>-0.534827</td>
      <td>0.357596</td>
      <td>-0.239539</td>
      <td>1.992326</td>
      <td>0.198205</td>
      <td>-1.463027</td>
      <td>-0.505329</td>
    </tr>
    <tr>
      <th>85</th>
      <td>7.4</td>
      <td>2.8</td>
      <td>6.1</td>
      <td>1.9</td>
      <td>0.865052</td>
      <td>-1.306580</td>
      <td>-0.652815</td>
      <td>1.701400</td>
      <td>0.220198</td>
      <td>-1.617604</td>
      <td>...</td>
      <td>0.653622</td>
      <td>0.117515</td>
      <td>-1.226595</td>
      <td>0.284589</td>
      <td>-0.334194</td>
      <td>-0.903473</td>
      <td>0.381607</td>
      <td>-0.052080</td>
      <td>1.359030</td>
      <td>0.240198</td>
    </tr>
    <tr>
      <th>86</th>
      <td>5.6</td>
      <td>2.8</td>
      <td>4.9</td>
      <td>2.0</td>
      <td>-0.510340</td>
      <td>1.403989</td>
      <td>1.009901</td>
      <td>-0.468205</td>
      <td>-0.190315</td>
      <td>0.227571</td>
      <td>...</td>
      <td>-0.379471</td>
      <td>0.595397</td>
      <td>-0.891139</td>
      <td>1.254901</td>
      <td>1.070941</td>
      <td>1.368118</td>
      <td>0.754042</td>
      <td>-1.361790</td>
      <td>0.214890</td>
      <td>0.766670</td>
    </tr>
    <tr>
      <th>87</th>
      <td>5.4</td>
      <td>3.0</td>
      <td>4.5</td>
      <td>1.5</td>
      <td>-0.572147</td>
      <td>-0.932604</td>
      <td>-1.346319</td>
      <td>-1.058354</td>
      <td>0.308220</td>
      <td>0.126306</td>
      <td>...</td>
      <td>-0.318538</td>
      <td>-1.872091</td>
      <td>0.072127</td>
      <td>0.291206</td>
      <td>-0.278348</td>
      <td>0.604955</td>
      <td>0.670609</td>
      <td>0.728398</td>
      <td>1.335929</td>
      <td>-0.872750</td>
    </tr>
    <tr>
      <th>88</th>
      <td>6.3</td>
      <td>2.9</td>
      <td>5.6</td>
      <td>1.8</td>
      <td>-0.182048</td>
      <td>-0.276649</td>
      <td>0.538549</td>
      <td>-1.242191</td>
      <td>-0.648934</td>
      <td>-0.894170</td>
      <td>...</td>
      <td>0.017709</td>
      <td>-1.055375</td>
      <td>0.053726</td>
      <td>0.892005</td>
      <td>-0.143683</td>
      <td>0.542886</td>
      <td>2.615181</td>
      <td>0.908922</td>
      <td>-0.670107</td>
      <td>0.146299</td>
    </tr>
    <tr>
      <th>89</th>
      <td>6.3</td>
      <td>2.5</td>
      <td>5.0</td>
      <td>1.9</td>
      <td>-0.417750</td>
      <td>-0.307175</td>
      <td>0.270318</td>
      <td>0.006145</td>
      <td>-0.041413</td>
      <td>1.252048</td>
      <td>...</td>
      <td>0.853689</td>
      <td>0.661952</td>
      <td>0.194043</td>
      <td>1.251985</td>
      <td>1.454035</td>
      <td>-1.487691</td>
      <td>-0.528628</td>
      <td>-0.561362</td>
      <td>0.459419</td>
      <td>0.461485</td>
    </tr>
    <tr>
      <th>90</th>
      <td>5.9</td>
      <td>3.2</td>
      <td>4.8</td>
      <td>1.8</td>
      <td>-0.841556</td>
      <td>-2.404757</td>
      <td>-1.494455</td>
      <td>-2.204729</td>
      <td>-0.710470</td>
      <td>-0.686504</td>
      <td>...</td>
      <td>-0.017775</td>
      <td>1.537601</td>
      <td>1.584035</td>
      <td>-1.507334</td>
      <td>0.066576</td>
      <td>0.377961</td>
      <td>0.902158</td>
      <td>0.017875</td>
      <td>-0.106061</td>
      <td>0.949775</td>
    </tr>
    <tr>
      <th>91</th>
      <td>6.1</td>
      <td>3.0</td>
      <td>4.9</td>
      <td>1.8</td>
      <td>1.145574</td>
      <td>1.176222</td>
      <td>-0.837864</td>
      <td>-0.506493</td>
      <td>-0.500535</td>
      <td>0.074223</td>
      <td>...</td>
      <td>-1.391425</td>
      <td>1.187411</td>
      <td>0.136741</td>
      <td>0.446020</td>
      <td>-1.261147</td>
      <td>0.038625</td>
      <td>-0.964237</td>
      <td>0.414514</td>
      <td>-0.175222</td>
      <td>-2.575418</td>
    </tr>
    <tr>
      <th>92</th>
      <td>5.8</td>
      <td>2.7</td>
      <td>3.9</td>
      <td>1.2</td>
      <td>-1.654025</td>
      <td>-0.034928</td>
      <td>0.044896</td>
      <td>-0.401898</td>
      <td>-0.718010</td>
      <td>-0.079427</td>
      <td>...</td>
      <td>-0.647734</td>
      <td>-0.563837</td>
      <td>0.104988</td>
      <td>-0.084172</td>
      <td>-0.506115</td>
      <td>-1.237672</td>
      <td>-1.230211</td>
      <td>-0.241843</td>
      <td>-0.047562</td>
      <td>0.347055</td>
    </tr>
    <tr>
      <th>93</th>
      <td>5.8</td>
      <td>2.7</td>
      <td>4.1</td>
      <td>1.0</td>
      <td>-0.790745</td>
      <td>0.082979</td>
      <td>-0.965247</td>
      <td>-0.895353</td>
      <td>0.756129</td>
      <td>0.493720</td>
      <td>...</td>
      <td>0.726356</td>
      <td>1.206265</td>
      <td>-1.037853</td>
      <td>-0.245858</td>
      <td>-1.389653</td>
      <td>-0.078631</td>
      <td>0.979513</td>
      <td>-0.207132</td>
      <td>-0.494727</td>
      <td>-1.672523</td>
    </tr>
    <tr>
      <th>94</th>
      <td>6.2</td>
      <td>3.4</td>
      <td>5.4</td>
      <td>2.3</td>
      <td>0.215002</td>
      <td>-0.672310</td>
      <td>-0.216854</td>
      <td>-0.900317</td>
      <td>-1.247777</td>
      <td>-0.177184</td>
      <td>...</td>
      <td>-1.147052</td>
      <td>0.719630</td>
      <td>-0.939569</td>
      <td>-1.248523</td>
      <td>0.977258</td>
      <td>-0.974969</td>
      <td>-0.919455</td>
      <td>0.155265</td>
      <td>-1.340796</td>
      <td>1.057030</td>
    </tr>
    <tr>
      <th>95</th>
      <td>6.6</td>
      <td>2.9</td>
      <td>4.6</td>
      <td>1.3</td>
      <td>-0.077869</td>
      <td>1.703830</td>
      <td>-0.273921</td>
      <td>-0.310248</td>
      <td>-1.754890</td>
      <td>0.419147</td>
      <td>...</td>
      <td>-0.356165</td>
      <td>-2.244161</td>
      <td>0.572133</td>
      <td>-0.042063</td>
      <td>0.833380</td>
      <td>-0.129480</td>
      <td>0.218202</td>
      <td>0.362546</td>
      <td>-0.340090</td>
      <td>-1.353757</td>
    </tr>
    <tr>
      <th>96</th>
      <td>6.4</td>
      <td>2.9</td>
      <td>4.3</td>
      <td>1.3</td>
      <td>-1.295209</td>
      <td>0.772378</td>
      <td>-0.064841</td>
      <td>-1.240077</td>
      <td>1.682795</td>
      <td>1.140158</td>
      <td>...</td>
      <td>0.471884</td>
      <td>1.167628</td>
      <td>-1.280400</td>
      <td>-1.577651</td>
      <td>0.437270</td>
      <td>-1.103348</td>
      <td>0.647573</td>
      <td>0.447371</td>
      <td>-0.146771</td>
      <td>0.779457</td>
    </tr>
    <tr>
      <th>97</th>
      <td>6.0</td>
      <td>2.2</td>
      <td>4.0</td>
      <td>1.0</td>
      <td>-0.680326</td>
      <td>0.962252</td>
      <td>-0.858723</td>
      <td>1.217500</td>
      <td>0.289700</td>
      <td>-2.598197</td>
      <td>...</td>
      <td>0.135432</td>
      <td>-0.434221</td>
      <td>0.835055</td>
      <td>-1.538043</td>
      <td>2.201508</td>
      <td>-1.292014</td>
      <td>1.650376</td>
      <td>0.437087</td>
      <td>-0.692241</td>
      <td>-1.832737</td>
    </tr>
    <tr>
      <th>98</th>
      <td>6.8</td>
      <td>3.0</td>
      <td>5.5</td>
      <td>2.1</td>
      <td>-0.117562</td>
      <td>0.018905</td>
      <td>-0.107093</td>
      <td>-1.765298</td>
      <td>0.571350</td>
      <td>-0.833247</td>
      <td>...</td>
      <td>0.646027</td>
      <td>-0.456958</td>
      <td>1.722247</td>
      <td>0.248672</td>
      <td>-0.594782</td>
      <td>-0.572446</td>
      <td>-1.292801</td>
      <td>0.351857</td>
      <td>-0.276844</td>
      <td>0.174488</td>
    </tr>
    <tr>
      <th>99</th>
      <td>6.2</td>
      <td>2.8</td>
      <td>4.8</td>
      <td>1.8</td>
      <td>0.771581</td>
      <td>-0.315522</td>
      <td>-0.601200</td>
      <td>-0.077892</td>
      <td>0.654753</td>
      <td>-1.526880</td>
      <td>...</td>
      <td>-0.776623</td>
      <td>-0.248674</td>
      <td>-1.735269</td>
      <td>-0.049026</td>
      <td>0.382293</td>
      <td>0.736216</td>
      <td>0.776332</td>
      <td>-0.152795</td>
      <td>1.248565</td>
      <td>0.223998</td>
    </tr>
  </tbody>
</table>
<p>100 rows × 100 columns</p>
</div>




```python
# データをシャッフル
p = range(len(data2))
random.seed(0)
random.shuffle(p)
shuffled_sample_names = list(np.array(sample_names)[p])
shuffled_data = np.array(data2)[p]
shuffled_target = list(np.array(target2)[p])
```


```python
# データを分割。test_size=0.8 は、学習：テスト のデータ量比が 2:8 であることを指す。
data_train, data_test, target_train, target_test, sample_names_train, sample_names_test = train_test_split(
    data2, target2, sample_names, test_size=0.8, random_state=0)
```


```python
# Linear SVM で学習・予測
classifier = svm.SVC(kernel='linear', probability=True)
probas = classifier.fit(data_train, target_train).predict_proba(data_test)
pred = classifier.fit(data_train, target_train).predict(data_test)
```


```python
# AUPRスコアを出す
precision, recall, thresholds = precision_recall_curve(target_test, probas[:, 1])
area = auc(recall, precision)
print "AUPR score: %0.2f" % area
```

    AUPR score: 0.69



```python
# AUCスコアを出す
fpr, tpr, thresholds = roc_curve(target_test, probas[:, 1])
roc_auc = auc(fpr, tpr)
print "AUC curve : %f" % roc_auc
```

    AUC curve : 0.689806



```python
# PR curve を描く
pl.clf()
pl.plot(recall, precision, label='Precision-Recall curve')
pl.xlabel('Recall')
pl.ylabel('Precision')
pl.ylim([0.0, 1.05])
pl.xlim([0.0, 1.0])
pl.title('Precision-Recall curve: AUPR=%0.2f' % area)
pl.legend(loc="lower left")
pl.show()
```


![output_63_0.png](https://qiita-image-store.s3.amazonaws.com/0/211162/4ccb863e-cf44-ebed-4342-5414d26fe8d6.png)



```python
# ROC curve を描く
pl.clf()
pl.plot(fpr, tpr, label='ROC curve (area = %0.2f)' % roc_auc)
pl.plot([0, 1], [0, 1], 'k--')
pl.xlim([0.0, 1.0])
pl.ylim([0.0, 1.0])
pl.xlabel('False Positive Rate')
pl.ylabel('True Positive Rate')
pl.title('ROC curve: AUC=%0.2f' % roc_auc)
pl.legend(loc="lower right")
pl.show()
```


![output_64_0.png](https://qiita-image-store.s3.amazonaws.com/0/211162/38e48545-395c-f189-2b11-0bfc18f6e1d1.png)


ということで、分類に寄与しない余計な成分が増えると、分類が難しくなることが分かりましたね。
### グリッドサーチによるパラメータ最適化
グリッドサーチとは、機械学習モデルのハイパーパラメータをいろいろ変えながら予測と評価を繰り返し、最適なものを探す手法。


```python
# グリッドサーチを行うためのパラメーター
parameters = [{'kernel': ['rbf'], 'gamma': [1e-3, 1e-4],
                     'C': [1, 10, 100, 1000]},
                    {'kernel': ['linear'], 'C': [1, 10, 100, 1000]}]
```


```python
# ベストなパラメーターを探し当てるためのグリッドサーチ
clf = grid_search.GridSearchCV(SVC(C=1), parameters, cv=5, n_jobs=-1)
clf.fit(data_train, target_train)
print(clf.best_estimator_)
```

    SVC(C=10, cache_size=200, class_weight=None, coef0=0.0,
      decision_function_shape=None, degree=3, gamma=0.001, kernel='rbf',
      max_iter=-1, probability=False, random_state=None, shrinking=True,
      tol=0.001, verbose=False)



```python
# 結果発表
scores = ['accuracy', 'precision', 'recall']

for score in scores:
    print '\n' + '='*50
    print score
    print '='*50

    clf = grid_search.GridSearchCV(SVC(C=1), parameters, cv=5, scoring=score, n_jobs=-1)
    clf.fit(data_train, target_train)

    print "\n+ ベストパラメータ:\n"
    print clf.best_estimator_

    print"\n+ トレーニングデータでCVした時の平均スコア:\n"
    for params, mean_score, all_scores in clf.grid_scores_:
        print "{:.3f} (+/- {:.3f}) for {}".format(mean_score, all_scores.std() / 2, params)

    print "\n+ テストデータでの識別結果:\n"
    target_true, target_pred = target_test, clf.predict(data_test)
    print classification_report(target_true, target_pred)
```

    
    ==================================================
    accuracy
    ==================================================
    
    + ベストパラメータ:
    
    SVC(C=10, cache_size=200, class_weight=None, coef0=0.0,
      decision_function_shape=None, degree=3, gamma=0.001, kernel='rbf',
      max_iter=-1, probability=False, random_state=None, shrinking=True,
      tol=0.001, verbose=False)
    
    + トレーニングデータでCVした時の平均スコア:
    
    0.550 (+/- 0.034) for {'kernel': 'rbf', 'C': 1, 'gamma': 0.001}
    0.550 (+/- 0.034) for {'kernel': 'rbf', 'C': 1, 'gamma': 0.0001}
    0.700 (+/- 0.096) for {'kernel': 'rbf', 'C': 10, 'gamma': 0.001}
    0.550 (+/- 0.034) for {'kernel': 'rbf', 'C': 10, 'gamma': 0.0001}
    0.700 (+/- 0.096) for {'kernel': 'rbf', 'C': 100, 'gamma': 0.001}
    0.700 (+/- 0.096) for {'kernel': 'rbf', 'C': 100, 'gamma': 0.0001}
    0.700 (+/- 0.096) for {'kernel': 'rbf', 'C': 1000, 'gamma': 0.001}
    0.700 (+/- 0.096) for {'kernel': 'rbf', 'C': 1000, 'gamma': 0.0001}
    0.700 (+/- 0.096) for {'kernel': 'linear', 'C': 1}
    0.700 (+/- 0.096) for {'kernel': 'linear', 'C': 10}
    0.700 (+/- 0.096) for {'kernel': 'linear', 'C': 100}
    0.700 (+/- 0.096) for {'kernel': 'linear', 'C': 1000}
    
    + テストデータでの識別結果:
    
                 precision    recall  f1-score   support
    
              0       0.66      0.66      0.66        41
              1       0.64      0.64      0.64        39
    
    avg / total       0.65      0.65      0.65        80
    
    
    ==================================================
    precision
    ==================================================
    
    + ベストパラメータ:
    
    SVC(C=10, cache_size=200, class_weight=None, coef0=0.0,
      decision_function_shape=None, degree=3, gamma=0.001, kernel='rbf',
      max_iter=-1, probability=False, random_state=None, shrinking=True,
      tol=0.001, verbose=False)
    
    + トレーニングデータでCVした時の平均スコア:
    
    0.550 (+/- 0.034) for {'kernel': 'rbf', 'C': 1, 'gamma': 0.001}
    0.550 (+/- 0.034) for {'kernel': 'rbf', 'C': 1, 'gamma': 0.0001}
    0.808 (+/- 0.105) for {'kernel': 'rbf', 'C': 10, 'gamma': 0.001}
    0.550 (+/- 0.034) for {'kernel': 'rbf', 'C': 10, 'gamma': 0.0001}
    0.808 (+/- 0.105) for {'kernel': 'rbf', 'C': 100, 'gamma': 0.001}
    0.808 (+/- 0.105) for {'kernel': 'rbf', 'C': 100, 'gamma': 0.0001}
    0.808 (+/- 0.105) for {'kernel': 'rbf', 'C': 1000, 'gamma': 0.001}
    0.808 (+/- 0.105) for {'kernel': 'rbf', 'C': 1000, 'gamma': 0.0001}
    0.808 (+/- 0.105) for {'kernel': 'linear', 'C': 1}
    0.808 (+/- 0.105) for {'kernel': 'linear', 'C': 10}
    0.808 (+/- 0.105) for {'kernel': 'linear', 'C': 100}
    0.808 (+/- 0.105) for {'kernel': 'linear', 'C': 1000}
    
    + テストデータでの識別結果:
    
                 precision    recall  f1-score   support
    
              0       0.66      0.66      0.66        41
              1       0.64      0.64      0.64        39
    
    avg / total       0.65      0.65      0.65        80
    
    
    ==================================================
    recall
    ==================================================
    
    + ベストパラメータ:
    
    SVC(C=1, cache_size=200, class_weight=None, coef0=0.0,
      decision_function_shape=None, degree=3, gamma=0.001, kernel='rbf',
      max_iter=-1, probability=False, random_state=None, shrinking=True,
      tol=0.001, verbose=False)
    
    + トレーニングデータでCVした時の平均スコア:
    
    1.000 (+/- 0.000) for {'kernel': 'rbf', 'C': 1, 'gamma': 0.001}
    1.000 (+/- 0.000) for {'kernel': 'rbf', 'C': 1, 'gamma': 0.0001}
    0.717 (+/- 0.113) for {'kernel': 'rbf', 'C': 10, 'gamma': 0.001}
    1.000 (+/- 0.000) for {'kernel': 'rbf', 'C': 10, 'gamma': 0.0001}
    0.717 (+/- 0.113) for {'kernel': 'rbf', 'C': 100, 'gamma': 0.001}
    0.717 (+/- 0.113) for {'kernel': 'rbf', 'C': 100, 'gamma': 0.0001}
    0.717 (+/- 0.113) for {'kernel': 'rbf', 'C': 1000, 'gamma': 0.001}
    0.717 (+/- 0.113) for {'kernel': 'rbf', 'C': 1000, 'gamma': 0.0001}
    0.717 (+/- 0.113) for {'kernel': 'linear', 'C': 1}
    0.717 (+/- 0.113) for {'kernel': 'linear', 'C': 10}
    0.717 (+/- 0.113) for {'kernel': 'linear', 'C': 100}
    0.717 (+/- 0.113) for {'kernel': 'linear', 'C': 1000}
    
    + テストデータでの識別結果:
    
                 precision    recall  f1-score   support
    
              0       0.00      0.00      0.00        41
              1       0.49      1.00      0.66        39
    
    avg / total       0.24      0.49      0.32        80
    


----------
## 課題
新しいノートを開いて、以下の課題を解いてください。

* __課題1__：下記リンクのデータを用い、図1のような Scatter Matrix を描いてください。ただしこのとき、真札を青色、偽札を赤色にしてプロットすること。
   * https://raw.githubusercontent.com/maskot1977/ipython_notebook/master/toydata/sbnote_dataJt.txt
   
      ここでは、以下の列を使います。
       * 'Note' : スイスフラン紙幣のID番号
       * 'length' : 横幅長
       * 'left': 左縦幅長
       * 'right': 右縦幅長
       * 'bottom': 下枠内長
       * 'top': 上枠内長
       * 'diagonal': 対角長
       * 'class': 0 = 真札、1= 偽札

* __課題2__： 上記のデータを使って学習し、サポートベクトルマシンを使って真札と偽札を区別する予測モデルを構築し、その性能を正解率 (Accuracy) で評価してください。

# 総合実験（Pythonプログラミング）４日間コース

本稿は「総合実験（Pythonプログラミング）４日間コース」シリーズ記事です。興味ある方は以下の記事も合わせてお読みください。
* <a href="https://qiita.com/drafts/02841501f1fe1cbbd9ad">総合実験（１日目）Jupyter Notebook を使った基本統計量の計算と可視化</a>
* <a href="https://qiita.com/maskot1977/items/44639231bed5fedfb4c9">総合実験（２日目）Jupyter Notebook を使った大規模データの可視化</a>
* <a href="https://qiita.com/maskot1977/items/ba4030c0c909b665278c">総合実験（３日目）Jupyter Notebookを使った多変量解析</a>
* <a href="https://qiita.com/maskot1977/items/849090dac7fd906faab6">総合実験（４日目）Jupyter Notebookを使った機械学習</a>