├── LICENSE ├── README.md ├── eeg_emotion_python.ipynb ├── featuresdb6.csv ├── outputs_main.csv └── pcdb6.csv /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Shivam Chaudhary 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python Emotion Recognition using EEG Signals 2 | This repository contains the code for emotion recognition using wavelet transform and svm classifiers' rbf kernel. 3 | 4 | ## Abstract: ## 5 | This paper aims to propose emotion recognition using electroencephalography (EEG) techniques.​ ​An electroencephalogram (EEG) is a machine that detects electrical activity in a human brain using small metal discs (electrodes) attached to the scalp. The brain cells communicate via electrical impulses and are active all the time, even when we are asleep. This activity shows up as wavy lines on an EEG recording. 6 | 7 | ## Dataset Summary ## 8 | 9 | The data set contains downsampled signal, preprocessed and segmented versions of the EEG data in Matlab (.mat file). The data was downsampled to 200Hz. A bandpass frequency filter from 0-75Hz was applied. EEG segments were extracted according to the duration of clips. There are a total of 45 .mat (Matlab) files, one for each experiment. Each subject performed the experiment three times with an interval of about one week. Each subject file contains 16 arrays. 15 arrays contain segmented preprocessed EEG data of 15 trials in one experiment (eeg_1~eeg_15, channel×data). An array named ‘labels’ contains the label of the corresponding emotional labels (-1 for negative, 0 for neutral and +1 for positive). The detailed order of the channels is included in the dataset. 10 | 11 | ## Steps involved ## 12 | **Preprocessing:** 13 | The ‘preprocess’ function consists of filtering data to between 0 to 75 Hz. It returns a new matrix with sampling frequency as 200Hz and between 0 to 75Hz. We used Finite Impulse Response ‘Low pass filter’. Bandpass was not used as it would make the eeg data unstable after processing. Filter order = 5 (or 10 if desired results are not obtained). 14 | 15 | **Feature Extraction:** 16 | In the feature extraction phase, we divide the eeg pre-processed input into 5 frequency sub bands using wavelet filter banks technique. 17 | In order to separate the five types of signal in the eeg recording i.e., alpha, beta, gamma, delta and theta as explained above, we use wavelet transform’s filter banks to separate the different frequencies. In the lower level, there is a filter that separates the frequency band in half and gives us high pass (detail coefficient) and low pass (approximation coefficient). We further take the approximation coefficient and pass it through the filter. We do this until the desired frequency ranges are not achieved. Since the filters are successively applied, they are known as filter banks. 18 | We repeat the process for each channel. In each iteration for 62 channels, we extract entropy and energy for each sub-band i.e., 10 features for each channel. The feature extraction is complete with each eeg pre processed signal having output of 620 features. 19 | 20 | **1. Entropy:** Entropy measures quantify the uncertainty in the EEG, which roughly equates to the possible configurations or their predictability. 21 | 22 | **2. Energy:** Wavelet energy reflects the distribution of the principal lines, wrinkles and ridges in different resolutions(scales). 23 | 24 | **Feature Reduction:** 25 | In the feature reduction phase, we use Principal Component Analysis or PCA. PCA is an eigenvector-based statistical mechanism, which employs singular value decomposition, that transforms a set of correlated features into mutually uncorrelated training features, principal components or PCs. 26 | Steps to perform Principal Components Analysis: 27 | 1. Mean normalisation of features. 28 | 2. Calculating Covariance Matrix. 29 | 3. Calculate EigenVectors. 30 | 4. Get the reduced features or principal components. 31 | 32 | After this process, we receive principal components PCs. 33 | 34 | **Classification:** 35 | 36 | The PCs from the previous step will be fed into the SVM classifier for output into emotions. 37 | 38 | 39 | **This project would not have been possible without:** 40 | 1. [Wavelet transform](http://users.rowan.edu/~polikar/WTtutorial.html). 41 | 2. [Principal Components Analysis](https://www.coursera.org/learn/machine-learning). 42 | 3. [Support Vector Machines](https://www.coursera.org/learn/machine-learning). 43 | 4. [Seed Dataset](http://bcmi.sjtu.edu.cn/~seed/). 44 | 45 | **Note:** Please refer to [this](https://bcmi.sjtu.edu.cn/~seed/downloads.html#seed-access-anchor) link to get access to the dataset. 46 | -------------------------------------------------------------------------------- /eeg_emotion_python.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "eeg-emotion-python.ipynb", 7 | "provenance": [], 8 | "collapsed_sections": [] 9 | }, 10 | "kernelspec": { 11 | "display_name": "Python 3", 12 | "name": "python3" 13 | } 14 | }, 15 | "cells": [ 16 | { 17 | "cell_type": "code", 18 | "metadata": { 19 | "id": "mHy8FWr0Jb01" 20 | }, 21 | "source": [ 22 | "import os\r\n", 23 | "import sys\r\n", 24 | "\r\n", 25 | "import pandas as pd\r\n", 26 | "import numpy as np\r\n", 27 | "\r\n", 28 | "import pywt\r\n", 29 | "import scipy.io as spio\r\n", 30 | "from scipy.stats import entropy\r\n", 31 | "from collections import Counter\r\n", 32 | "\r\n", 33 | "from sklearn import svm\r\n", 34 | "from sklearn.preprocessing import normalize\r\n", 35 | "from sklearn.model_selection import train_test_split\r\n", 36 | "from sklearn.model_selection import GridSearchCV\r\n", 37 | "from sklearn.svm import SVC\r\n", 38 | "from sklearn.metrics import classification_report\r\n", 39 | "\r\n", 40 | "import timeit" 41 | ], 42 | "execution_count": 127, 43 | "outputs": [] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "metadata": { 48 | "id": "xA-SVLx8JrV1", 49 | "colab": { 50 | "base_uri": "https://localhost:8080/", 51 | "height": 90 52 | }, 53 | "outputId": "7f4c850d-7761-44f4-df88-be9964df14c5" 54 | }, 55 | "source": [ 56 | "'''\r\n", 57 | " Authors: Shivam Chaudhary\r\n", 58 | " Centre for Brain and Cognitive Science, Indian Institute of Technology Gandhinagar \r\n", 59 | " In this project we will be recognising Emotion of a Human being from EEG signal.\r\n", 60 | " About the data set : The data set is called the seed data set.\r\n", 61 | " It contains data of 15 people that underwent trails 15 times each thrice.\r\n", 62 | "\r\n", 63 | " Total data items = 15 (subjects) * 15 (trials each) * 3 (sessions each)\r\n", 64 | " = 675 data items\r\n", 65 | "\r\n", 66 | " Our project consists of 4 modules, namely : pre processing, feature extraction, feature reduction and classification,\r\n", 67 | " all of which are mentioned in detail in the black book.\r\n", 68 | "\r\n", 69 | "'''" 70 | ], 71 | "execution_count": 39, 72 | "outputs": [ 73 | { 74 | "output_type": "execute_result", 75 | "data": { 76 | "application/vnd.google.colaboratory.intrinsic+json": { 77 | "type": "string" 78 | }, 79 | "text/plain": [ 80 | "'\\n Authors: Shivam Chaudhary\\n Centre of Behavioural and Cognitive Sciences, Allahabad\\n In this project we will be recognising Emotion of a Human being from EEG signal.\\n About the data set : The data set is called the seed data set.\\n It contains data of 15 people that underwent trails 15 times each thrice.\\n\\n Total data items = 15 (subjects) * 15 (trials each) * 3 (sessions each)\\n = 675 data items\\n\\n Our project consists of 4 modules, namely : pre processing, feature extraction, feature reduction and classification,\\n all of which are mentioned in detail in the black book.\\n\\n'" 81 | ] 82 | }, 83 | "metadata": { 84 | "tags": [] 85 | }, 86 | "execution_count": 39 87 | } 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "metadata": { 93 | "id": "5rjOC6NHclK2" 94 | }, 95 | "source": [ 96 | "WAVELET = \"db6\"\r\n", 97 | "MAX_LEVEL = 5" 98 | ], 99 | "execution_count": 40, 100 | "outputs": [] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "metadata": { 105 | "colab": { 106 | "base_uri": "https://localhost:8080/" 107 | }, 108 | "id": "2TBRe0rNKPOW", 109 | "outputId": "00cf8cf1-5b36-4003-f3e1-e19557ed0f2c" 110 | }, 111 | "source": [ 112 | "# Connecting google drive\r\n", 113 | "from google.colab import drive\r\n", 114 | "drive.mount('/content/drive')\r\n", 115 | "#4/1AY0e-g7fln4EfIjw7IjtOGqkoh3Y0EUpKlncOdTR6o4uuu3XqPjYElTbIwo" 116 | ], 117 | "execution_count": 41, 118 | "outputs": [ 119 | { 120 | "output_type": "stream", 121 | "text": [ 122 | "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n" 123 | ], 124 | "name": "stdout" 125 | } 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "metadata": { 131 | "colab": { 132 | "base_uri": "https://localhost:8080/", 133 | "height": 36 134 | }, 135 | "id": "3lnGMQvTJ9Pq", 136 | "outputId": "29a4b1b2-c61e-4af1-801a-fc54d476673e" 137 | }, 138 | "source": [ 139 | "dir = \"/content/drive/MyDrive/EEG-emotion-python/seed dataset/SEED\"\r\n", 140 | "os.chdir(dir)\r\n", 141 | "os.getcwd()" 142 | ], 143 | "execution_count": 42, 144 | "outputs": [ 145 | { 146 | "output_type": "execute_result", 147 | "data": { 148 | "application/vnd.google.colaboratory.intrinsic+json": { 149 | "type": "string" 150 | }, 151 | "text/plain": [ 152 | "'/content/drive/MyDrive/EEG-emotion-python/seed dataset/SEED'" 153 | ] 154 | }, 155 | "metadata": { 156 | "tags": [] 157 | }, 158 | "execution_count": 42 159 | } 160 | ] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "metadata": { 165 | "id": "OieGOhu9Mp-H" 166 | }, 167 | "source": [ 168 | "# Unzip the data file\r\n", 169 | "# # Do only once\r\n", 170 | "# import zipfile\r\n", 171 | "# with zipfile.ZipFile(\"ExtractedFeatures.zip\", 'r') as zip_ref:\r\n", 172 | "# zip_ref.extractall(os.getcwd() + \"/temp\")\r\n", 173 | "# !unzip -u \"/content/drive/MyDrive/EEG-emotion-python/seed dataset/SEED/Preprocessed_EEG.zip\" -d \"/content/drive/MyDrive/EEG-emotion-python/seed dataset/SEED/temp\"" 174 | ], 175 | "execution_count": null, 176 | "outputs": [] 177 | }, 178 | { 179 | "cell_type": "code", 180 | "metadata": { 181 | "colab": { 182 | "base_uri": "https://localhost:8080/", 183 | "height": 206 184 | }, 185 | "id": "lvo7MF4OLVf_", 186 | "outputId": "f9bda06c-50d4-48db-bdaa-b990c4f984e8" 187 | }, 188 | "source": [ 189 | "# reading the channel order for dataframe\r\n", 190 | "channel_order = pd.read_excel(\"Channel Order.xlsx\", header=None)\r\n", 191 | "channel_order.head()" 192 | ], 193 | "execution_count": 43, 194 | "outputs": [ 195 | { 196 | "output_type": "execute_result", 197 | "data": { 198 | "text/html": [ 199 | "
\n", 200 | "\n", 213 | "\n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | "
0
0FP1
1FPZ
2FP2
3AF3
4AF4
\n", 243 | "
" 244 | ], 245 | "text/plain": [ 246 | " 0\n", 247 | "0 FP1\n", 248 | "1 FPZ\n", 249 | "2 FP2\n", 250 | "3 AF3\n", 251 | "4 AF4" 252 | ] 253 | }, 254 | "metadata": { 255 | "tags": [] 256 | }, 257 | "execution_count": 43 258 | } 259 | ] 260 | }, 261 | { 262 | "cell_type": "code", 263 | "metadata": { 264 | "colab": { 265 | "base_uri": "https://localhost:8080/", 266 | "height": 206 267 | }, 268 | "id": "teYc7UyCLx0g", 269 | "outputId": "4b7b1667-37ea-4974-aa3f-53733e888068" 270 | }, 271 | "source": [ 272 | "# extract labels file\r\n", 273 | "labels = spio.loadmat(\"label.mat\")\r\n", 274 | "labels_df = pd.DataFrame(np.hstack(labels[\"label\"]))\r\n", 275 | "labels_df.head()" 276 | ], 277 | "execution_count": 44, 278 | "outputs": [ 279 | { 280 | "output_type": "execute_result", 281 | "data": { 282 | "text/html": [ 283 | "
\n", 284 | "\n", 297 | "\n", 298 | " \n", 299 | " \n", 300 | " \n", 301 | " \n", 302 | " \n", 303 | " \n", 304 | " \n", 305 | " \n", 306 | " \n", 307 | " \n", 308 | " \n", 309 | " \n", 310 | " \n", 311 | " \n", 312 | " \n", 313 | " \n", 314 | " \n", 315 | " \n", 316 | " \n", 317 | " \n", 318 | " \n", 319 | " \n", 320 | " \n", 321 | " \n", 322 | " \n", 323 | " \n", 324 | " \n", 325 | " \n", 326 | "
0
01
10
2-1
3-1
40
\n", 327 | "
" 328 | ], 329 | "text/plain": [ 330 | " 0\n", 331 | "0 1\n", 332 | "1 0\n", 333 | "2 -1\n", 334 | "3 -1\n", 335 | "4 0" 336 | ] 337 | }, 338 | "metadata": { 339 | "tags": [] 340 | }, 341 | "execution_count": 44 342 | } 343 | ] 344 | }, 345 | { 346 | "cell_type": "code", 347 | "metadata": { 348 | "colab": { 349 | "base_uri": "https://localhost:8080/" 350 | }, 351 | "id": "Ut2BbwkwPx8n", 352 | "outputId": "3381b2c6-30b8-4c09-b7d8-f69675646f0c" 353 | }, 354 | "source": [ 355 | "files = os.listdir(\"temp/Preprocessed_EEG/\")\r\n", 356 | "files" 357 | ], 358 | "execution_count": 45, 359 | "outputs": [ 360 | { 361 | "output_type": "execute_result", 362 | "data": { 363 | "text/plain": [ 364 | "['2_20140404.mat',\n", 365 | " '1_20131030.mat',\n", 366 | " '1_20131107.mat',\n", 367 | " '3_20140603.mat',\n", 368 | " '3_20140611.mat',\n", 369 | " '2_20140419.mat',\n", 370 | " '2_20140413.mat',\n", 371 | " '3_20140629.mat',\n", 372 | " '4_20140705.mat',\n", 373 | " '4_20140702.mat',\n", 374 | " '4_20140621.mat',\n", 375 | " '5_20140506.mat',\n", 376 | " '5_20140418.mat',\n", 377 | " '6_20131113.mat',\n", 378 | " '5_20140411.mat',\n", 379 | " '6_20131016.mat',\n", 380 | " '6_20130712.mat',\n", 381 | " '7_20131106.mat',\n", 382 | " '7_20131027.mat',\n", 383 | " '7_20131030.mat',\n", 384 | " '8_20140521.mat',\n", 385 | " '8_20140514.mat',\n", 386 | " '8_20140511.mat',\n", 387 | " '9_20140620.mat',\n", 388 | " '9_20140627.mat',\n", 389 | " '9_20140704.mat',\n", 390 | " '10_20131211.mat',\n", 391 | " '10_20131130.mat',\n", 392 | " '10_20131204.mat',\n", 393 | " '11_20140618.mat',\n", 394 | " '11_20140625.mat',\n", 395 | " '11_20140630.mat',\n", 396 | " '12_20131207.mat',\n", 397 | " '12_20131201.mat',\n", 398 | " '13_20140603.mat',\n", 399 | " '13_20140610.mat',\n", 400 | " '13_20140527.mat',\n", 401 | " '12_20131127.mat',\n", 402 | " '14_20140601.mat',\n", 403 | " '15_20131016.mat',\n", 404 | " '15_20131105.mat',\n", 405 | " '14_20140615.mat',\n", 406 | " '14_20140627.mat',\n", 407 | " '15_20130709.mat']" 408 | ] 409 | }, 410 | "metadata": { 411 | "tags": [] 412 | }, 413 | "execution_count": 45 414 | } 415 | ] 416 | }, 417 | { 418 | "cell_type": "markdown", 419 | "metadata": { 420 | "id": "Ssmr7iiPdWvg" 421 | }, 422 | "source": [ 423 | "**Feature extraction**" 424 | ] 425 | }, 426 | { 427 | "cell_type": "code", 428 | "metadata": { 429 | "id": "Bnv8OiNcYV8S" 430 | }, 431 | "source": [ 432 | "def calc_wavelet_energy(data_set):\r\n", 433 | " \"\"\"\r\n", 434 | " Input : 1 * N vector\r\n", 435 | " Output: Float with the wavelet energy of the input vector,\r\n", 436 | " rounded to 3 decimal places.\r\n", 437 | " \"\"\"\r\n", 438 | " # p_sqr = [i ** 2 for i in data_set]\r\n", 439 | " wavelet_energy = np.nansum(np.log2(np.square(data_set)))\r\n", 440 | " return round(wavelet_energy, 3)" 441 | ], 442 | "execution_count": 46, 443 | "outputs": [] 444 | }, 445 | { 446 | "cell_type": "code", 447 | "metadata": { 448 | "id": "McEczAds0hn5" 449 | }, 450 | "source": [ 451 | " def calc_shannon_entropy(data_set):\r\n", 452 | " \"\"\"\r\n", 453 | " Input : 1 * N vector\r\n", 454 | " Output: Float with the wavelet entropy of the input vector,\r\n", 455 | " rounded to 3 decimal places.\r\n", 456 | " \"\"\"\r\n", 457 | " # probability = [i ** 2 for i in data_set]\r\n", 458 | " probability = np.square(data_set)\r\n", 459 | " shannon_entropy = -np.nansum(probability * np.log2(probability))\r\n", 460 | " return round(shannon_entropy, 3)" 461 | ], 462 | "execution_count": 47, 463 | "outputs": [] 464 | }, 465 | { 466 | "cell_type": "code", 467 | "metadata": { 468 | "id": "AWNg43Z3XXwP" 469 | }, 470 | "source": [ 471 | "participant_trial = []\r\n", 472 | "features_table = pd.DataFrame(columns=range(620))\r\n", 473 | "for file in files:\r\n", 474 | " mat_file = spio.loadmat(\"temp/Preprocessed_EEG/\" + file)\r\n", 475 | " keys = [key for key, values in mat_file.items() if key != '__header__' and key != '__version__' and key != '__globals__' ]\r\n", 476 | " for data_file in keys:\r\n", 477 | " data_df = pd.DataFrame(mat_file[data_file])\r\n", 478 | " # print(data_df)\r\n", 479 | " M = data_df.shape[0]\r\n", 480 | " N = data_df.shape[1]\r\n", 481 | " # Feature extraction part of the module\r\n", 482 | " Entropy = []\r\n", 483 | " Energy = []\r\n", 484 | " for channel in data_df.iterrows(): # Iterating through the 62 channels\r\n", 485 | " dwt_bands = []\r\n", 486 | " data = channel[1]\r\n", 487 | " int_ent = []\r\n", 488 | " int_eng = []\r\n", 489 | " for band in range(MAX_LEVEL):\r\n", 490 | " (data, coeff_d) = pywt.dwt(data, WAVELET)\r\n", 491 | " dwt_bands.append(coeff_d)\r\n", 492 | " \r\n", 493 | " for band in range(len(dwt_bands)): # DWT_bands = 23504, 11755\r\n", 494 | " int_ent.append(calc_shannon_entropy(dwt_bands[len(dwt_bands) - band - 1]))\r\n", 495 | " int_eng.append(calc_wavelet_energy(dwt_bands[len(dwt_bands) - band - 1]))\r\n", 496 | " \r\n", 497 | " Entropy.append(int_ent)\r\n", 498 | " Energy.append(int_eng)\r\n", 499 | " \r\n", 500 | " unroll_entropy = []\r\n", 501 | " unroll_energy = []\r\n", 502 | " '''\r\n", 503 | " Transforming 2D array into 1D vector of features and then \r\n", 504 | " combining the two 1D arrays.\r\n", 505 | " '''\r\n", 506 | " for i in range(len(Entropy)):\r\n", 507 | " for j in range(len(Entropy[0])):\r\n", 508 | " unroll_entropy.append(Entropy[i][j])\r\n", 509 | " unroll_energy.append(Energy[i][j])\r\n", 510 | "\r\n", 511 | " features = unroll_entropy + unroll_energy\r\n", 512 | " participant_trial.append(features)\r\n", 513 | " features_table.loc[len(features_table.index)] = features\r\n", 514 | " # print(data_file)\r\n", 515 | " # print(features)\r\n", 516 | " print(file)\r\n" 517 | ], 518 | "execution_count": null, 519 | "outputs": [] 520 | }, 521 | { 522 | "cell_type": "code", 523 | "metadata": { 524 | "id": "LlIb4wqid8TX" 525 | }, 526 | "source": [ 527 | "file_dir = dir + \"/temp/analysis/\"" 528 | ], 529 | "execution_count": 63, 530 | "outputs": [] 531 | }, 532 | { 533 | "cell_type": "code", 534 | "metadata": { 535 | "id": "L3mY47GX-tgW" 536 | }, 537 | "source": [ 538 | "features_table.to_csv(file_dir + \"features\" + WAVELET + \".csv\", index=False)" 539 | ], 540 | "execution_count": 60, 541 | "outputs": [] 542 | }, 543 | { 544 | "cell_type": "markdown", 545 | "metadata": { 546 | "id": "JreZ9rFodcEn" 547 | }, 548 | "source": [ 549 | "**Principal Components Analysis**" 550 | ] 551 | }, 552 | { 553 | "cell_type": "code", 554 | "metadata": { 555 | "id": "w32UIkImbd1o" 556 | }, 557 | "source": [ 558 | "data = pd.read_csv(file_dir + \"features\" + WAVELET + \".csv\")" 559 | ], 560 | "execution_count": 64, 561 | "outputs": [] 562 | }, 563 | { 564 | "cell_type": "code", 565 | "metadata": { 566 | "colab": { 567 | "base_uri": "https://localhost:8080/", 568 | "height": 255 569 | }, 570 | "id": "h10DXrmcezSJ", 571 | "outputId": "7584a4dd-778d-4a39-9936-c88249b73923" 572 | }, 573 | "source": [ 574 | "# 1. Normalising data and getting transpose\r\n", 575 | "normalised = pd.DataFrame(normalize(data, axis = 0))\r\n", 576 | "\r\n", 577 | "# 2. Finding covariance matrix\r\n", 578 | "covariance_df = normalised.cov()\r\n", 579 | "\r\n", 580 | "# 3. Eigen Vectors\r\n", 581 | "u, s, v = np.linalg.svd(covariance_df)\r\n", 582 | "\r\n", 583 | "# 4. Principal Components\r\n", 584 | "data_reduced = normalised @ u\r\n", 585 | "data_reduced.head()" 586 | ], 587 | "execution_count": 101, 588 | "outputs": [ 589 | { 590 | "output_type": "execute_result", 591 | "data": { 592 | "text/html": [ 593 | "
\n", 594 | "\n", 607 | "\n", 608 | " \n", 609 | " \n", 610 | " \n", 611 | " \n", 612 | " \n", 613 | " \n", 614 | " \n", 615 | " \n", 616 | " \n", 617 | " \n", 618 | " \n", 619 | " \n", 620 | " \n", 621 | " \n", 622 | " \n", 623 | " \n", 624 | " \n", 625 | " \n", 626 | " \n", 627 | " \n", 628 | " \n", 629 | " \n", 630 | " \n", 631 | " \n", 632 | " \n", 633 | " \n", 634 | " \n", 635 | " \n", 636 | " \n", 637 | " \n", 638 | " \n", 639 | " \n", 640 | " \n", 641 | " \n", 642 | " \n", 643 | " \n", 644 | " \n", 645 | " \n", 646 | " \n", 647 | " \n", 648 | " \n", 649 | " \n", 650 | " \n", 651 | " \n", 652 | " \n", 653 | " \n", 654 | " \n", 655 | " \n", 656 | " \n", 657 | " \n", 658 | " \n", 659 | " \n", 660 | " \n", 661 | " \n", 662 | " \n", 663 | " \n", 664 | " \n", 665 | " \n", 666 | " \n", 667 | " \n", 668 | " \n", 669 | " \n", 670 | " \n", 671 | " \n", 672 | " \n", 673 | " \n", 674 | " \n", 675 | " \n", 676 | " \n", 677 | " \n", 678 | " \n", 679 | " \n", 680 | " \n", 681 | " \n", 682 | " \n", 683 | " \n", 684 | " \n", 685 | " \n", 686 | " \n", 687 | " \n", 688 | " \n", 689 | " \n", 690 | " \n", 691 | " \n", 692 | " \n", 693 | " \n", 694 | " \n", 695 | " \n", 696 | " \n", 697 | " \n", 698 | " \n", 699 | " \n", 700 | " \n", 701 | " \n", 702 | " \n", 703 | " \n", 704 | " \n", 705 | " \n", 706 | " \n", 707 | " \n", 708 | " \n", 709 | " \n", 710 | " \n", 711 | " \n", 712 | " \n", 713 | " \n", 714 | " \n", 715 | " \n", 716 | " \n", 717 | " \n", 718 | " \n", 719 | " \n", 720 | " \n", 721 | " \n", 722 | " \n", 723 | " \n", 724 | " \n", 725 | " \n", 726 | " \n", 727 | " \n", 728 | " \n", 729 | " \n", 730 | " \n", 731 | " \n", 732 | " \n", 733 | " \n", 734 | " \n", 735 | " \n", 736 | " \n", 737 | " \n", 738 | " \n", 739 | " \n", 740 | " \n", 741 | " \n", 742 | " \n", 743 | " \n", 744 | " \n", 745 | " \n", 746 | " \n", 747 | " \n", 748 | " \n", 749 | " \n", 750 | " \n", 751 | " \n", 752 | " \n", 753 | " \n", 754 | " \n", 755 | " \n", 756 | " \n", 757 | " \n", 758 | " \n", 759 | " \n", 760 | " \n", 761 | " \n", 762 | " \n", 763 | " \n", 764 | " \n", 765 | " \n", 766 | " \n", 767 | " \n", 768 | " \n", 769 | " \n", 770 | " \n", 771 | " \n", 772 | " \n", 773 | " \n", 774 | " \n", 775 | " \n", 776 | " \n", 777 | " \n", 778 | " \n", 779 | " \n", 780 | " \n", 781 | " \n", 782 | " \n", 783 | " \n", 784 | " \n", 785 | " \n", 786 | " \n", 787 | " \n", 788 | " \n", 789 | " \n", 790 | " \n", 791 | " \n", 792 | " \n", 793 | " \n", 794 | " \n", 795 | " \n", 796 | " \n", 797 | " \n", 798 | " \n", 799 | " \n", 800 | " \n", 801 | " \n", 802 | " \n", 803 | " \n", 804 | " \n", 805 | " \n", 806 | " \n", 807 | " \n", 808 | " \n", 809 | " \n", 810 | " \n", 811 | " \n", 812 | " \n", 813 | " \n", 814 | " \n", 815 | " \n", 816 | " \n", 817 | " \n", 818 | " \n", 819 | " \n", 820 | " \n", 821 | " \n", 822 | " \n", 823 | " \n", 824 | " \n", 825 | " \n", 826 | " \n", 827 | " \n", 828 | " \n", 829 | " \n", 830 | " \n", 831 | " \n", 832 | " \n", 833 | " \n", 834 | " \n", 835 | " \n", 836 | " \n", 837 | " \n", 838 | " \n", 839 | " \n", 840 | " \n", 841 | " \n", 842 | " \n", 843 | " \n", 844 | " \n", 845 | " \n", 846 | " \n", 847 | " \n", 848 | " \n", 849 | " \n", 850 | " \n", 851 | " \n", 852 | " \n", 853 | " \n", 854 | " \n", 855 | " \n", 856 | " \n", 857 | " \n", 858 | " \n", 859 | " \n", 860 | " \n", 861 | " \n", 862 | " \n", 863 | " \n", 864 | " \n", 865 | " \n", 866 | " \n", 867 | " \n", 868 | " \n", 869 | " \n", 870 | " \n", 871 | " \n", 872 | " \n", 873 | " \n", 874 | " \n", 875 | " \n", 876 | " \n", 877 | " \n", 878 | " \n", 879 | " \n", 880 | " \n", 881 | " \n", 882 | " \n", 883 | " \n", 884 | " \n", 885 | " \n", 886 | " \n", 887 | " \n", 888 | " \n", 889 | " \n", 890 | " \n", 891 | " \n", 892 | " \n", 893 | " \n", 894 | " \n", 895 | " \n", 896 | " \n", 897 | " \n", 898 | " \n", 899 | " \n", 900 | " \n", 901 | " \n", 902 | " \n", 903 | " \n", 904 | " \n", 905 | " \n", 906 | " \n", 907 | " \n", 908 | " \n", 909 | " \n", 910 | " \n", 911 | " \n", 912 | " \n", 913 | " \n", 914 | " \n", 915 | " \n", 916 | " \n", 917 | " \n", 918 | " \n", 919 | " \n", 920 | " \n", 921 | " \n", 922 | " \n", 923 | " \n", 924 | " \n", 925 | " \n", 926 | " \n", 927 | " \n", 928 | " \n", 929 | " \n", 930 | " \n", 931 | " \n", 932 | " \n", 933 | " \n", 934 | " \n", 935 | " \n", 936 | " \n", 937 | " \n", 938 | " \n", 939 | " \n", 940 | " \n", 941 | " \n", 942 | " \n", 943 | " \n", 944 | " \n", 945 | " \n", 946 | " \n", 947 | " \n", 948 | " \n", 949 | " \n", 950 | " \n", 951 | " \n", 952 | " \n", 953 | " \n", 954 | " \n", 955 | " \n", 956 | " \n", 957 | " \n", 958 | " \n", 959 | " \n", 960 | " \n", 961 | " \n", 962 | " \n", 963 | " \n", 964 | " \n", 965 | " \n", 966 | " \n", 967 | " \n", 968 | " \n", 969 | " \n", 970 | " \n", 971 | " \n", 972 | " \n", 973 | " \n", 974 | " \n", 975 | " \n", 976 | " \n", 977 | " \n", 978 | " \n", 979 | " \n", 980 | " \n", 981 | " \n", 982 | " \n", 983 | " \n", 984 | " \n", 985 | " \n", 986 | " \n", 987 | " \n", 988 | " \n", 989 | " \n", 990 | " \n", 991 | " \n", 992 | " \n", 993 | " \n", 994 | " \n", 995 | " \n", 996 | " \n", 997 | " \n", 998 | " \n", 999 | " \n", 1000 | " \n", 1001 | " \n", 1002 | " \n", 1003 | " \n", 1004 | " \n", 1005 | " \n", 1006 | " \n", 1007 | " \n", 1008 | " \n", 1009 | " \n", 1010 | " \n", 1011 | " \n", 1012 | " \n", 1013 | " \n", 1014 | " \n", 1015 | " \n", 1016 | " \n", 1017 | " \n", 1018 | " \n", 1019 | " \n", 1020 | " \n", 1021 | " \n", 1022 | " \n", 1023 | " \n", 1024 | " \n", 1025 | " \n", 1026 | " \n", 1027 | " \n", 1028 | " \n", 1029 | " \n", 1030 | " \n", 1031 | " \n", 1032 | " \n", 1033 | " \n", 1034 | " \n", 1035 | " \n", 1036 | " \n", 1037 | " \n", 1038 | " \n", 1039 | " \n", 1040 | " \n", 1041 | " \n", 1042 | " \n", 1043 | " \n", 1044 | " \n", 1045 | " \n", 1046 | " \n", 1047 | " \n", 1048 | " \n", 1049 | " \n", 1050 | " \n", 1051 | " \n", 1052 | " \n", 1053 | " \n", 1054 | " \n", 1055 | " \n", 1056 | " \n", 1057 | " \n", 1058 | " \n", 1059 | " \n", 1060 | " \n", 1061 | " \n", 1062 | " \n", 1063 | " \n", 1064 | " \n", 1065 | " \n", 1066 | " \n", 1067 | " \n", 1068 | " \n", 1069 | " \n", 1070 | " \n", 1071 | " \n", 1072 | " \n", 1073 | " \n", 1074 | " \n", 1075 | " \n", 1076 | " \n", 1077 | " \n", 1078 | " \n", 1079 | " \n", 1080 | " \n", 1081 | " \n", 1082 | " \n", 1083 | " \n", 1084 | " \n", 1085 | " \n", 1086 | " \n", 1087 | " \n", 1088 | " \n", 1089 | " \n", 1090 | " \n", 1091 | " \n", 1092 | " \n", 1093 | " \n", 1094 | " \n", 1095 | " \n", 1096 | " \n", 1097 | " \n", 1098 | " \n", 1099 | " \n", 1100 | " \n", 1101 | " \n", 1102 | " \n", 1103 | " \n", 1104 | " \n", 1105 | " \n", 1106 | " \n", 1107 | " \n", 1108 | " \n", 1109 | " \n", 1110 | " \n", 1111 | " \n", 1112 | " \n", 1113 | " \n", 1114 | " \n", 1115 | " \n", 1116 | "
0123456789101112131415161718192021222324252627282930313233343536373839...580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
00.0978170.1301650.069822-0.3394190.0129620.0228750.0323190.1545340.0356820.005306-0.063540-0.1020650.086618-0.008909-0.0997540.011716-0.068401-0.0725630.017964-0.0057550.0827020.0996300.1218740.0257970.0296600.0098700.134024-0.0915420.0471390.0292370.042781-0.112607-0.017711-0.0507210.176584-0.0032420.045504-0.097517-0.068512-0.044981...0.0000091.862270e-07-0.000016-0.000013-0.0000020.0000089.287625e-070.0000012.044501e-07-0.0000063.825408e-07-5.865877e-07-3.348752e-073.027798e-071.279925e-070.000001-1.216881e-063.886670e-07-6.618711e-077.504141e-074.407065e-08-4.451369e-071.713568e-071.621219e-073.818677e-074.691840e-08-4.667070e-08-1.047121e-071.437236e-071.539457e-07-2.098129e-08-5.612988e-083.211213e-08-4.723769e-084.073753e-094.360708e-08-7.719521e-08-1.279139e-081.840980e-08-2.671326e-08
10.0791300.1077030.013614-0.3237000.0055150.0152830.0458640.1423070.0477090.004523-0.064133-0.0938970.073178-0.009482-0.0942260.000710-0.050410-0.0682500.021639-0.0039770.0768880.0880810.1174550.0178900.0245360.0148680.114364-0.0888270.0341600.0283240.048997-0.091660-0.030368-0.0494310.159302-0.0012260.051240-0.097318-0.065109-0.037735...0.000001-2.432004e-06-0.000016-0.000011-0.0000030.0000081.278023e-060.0000022.228182e-06-0.0000061.297098e-06-7.741014e-07-3.410565e-07-1.614335e-074.022831e-070.000001-8.737522e-073.870899e-07-4.521406e-076.239186e-072.837787e-08-3.984898e-072.103950e-077.799253e-084.492663e-079.704270e-08-7.896122e-08-9.481077e-081.457714e-071.835170e-07-6.724168e-08-9.023388e-083.039570e-08-2.052639e-08-9.275702e-093.880146e-08-8.299719e-08-5.382707e-091.842500e-08-3.027882e-08
20.0884090.1187770.089460-0.2864530.0088920.0208140.0143770.1472210.0291380.000999-0.051779-0.0744880.067087-0.006247-0.0756560.008401-0.052398-0.0665280.0206730.0029850.0602740.0841710.1092920.0206730.0272630.0156370.112860-0.0742150.0393900.0231400.054142-0.095459-0.013652-0.0554560.135946-0.0083200.040155-0.075728-0.054987-0.025159...0.000004-9.948690e-07-0.000014-0.000012-0.0000030.0000091.189258e-060.0000011.448787e-06-0.0000058.777831e-07-5.567351e-07-2.543641e-071.289873e-071.330648e-070.000001-1.041733e-064.109182e-07-6.141837e-076.911247e-07-4.150120e-08-4.874300e-072.016586e-071.082429e-074.237289e-079.627468e-08-5.019041e-08-1.015426e-071.195451e-071.916321e-07-3.923679e-08-6.696104e-083.048998e-08-3.824638e-08-4.436387e-094.483001e-08-8.183916e-08-1.037805e-082.075966e-08-3.009659e-08
30.0892700.1205940.047669-0.3189600.0129630.0191920.0468410.1544940.0347050.000030-0.060654-0.0932380.075378-0.007603-0.0879170.001959-0.049254-0.0799160.0220410.0080190.0778300.0873660.1260250.0129810.0217790.0195200.122227-0.0996410.0500410.0104580.063402-0.098252-0.033244-0.0501160.1512460.0037560.053185-0.095541-0.069392-0.033584...0.0000061.539661e-06-0.000017-0.000012-0.0000060.0000081.530125e-070.0000028.928652e-07-0.0000054.475700e-07-6.172040e-072.534976e-07-9.811037e-088.963929e-080.000001-7.367891e-075.555980e-07-7.257258e-076.343024e-071.047278e-07-3.759031e-072.353655e-071.287926e-074.991714e-073.138122e-084.562266e-08-1.862962e-071.022220e-072.629627e-07-6.193438e-08-7.203549e-083.924766e-08-2.518006e-083.521498e-092.864041e-08-7.464052e-08-7.413186e-091.996893e-08-3.272369e-08
40.5785830.0768310.016236-0.230923-0.222639-0.0383650.1261820.1507410.017501-0.008049-0.046198-0.0986800.065333-0.012777-0.090030-0.044711-0.069119-0.0670420.041172-0.0216090.0740780.0850640.0941520.0321430.056237-0.0299380.042653-0.1108380.011368-0.0075240.058345-0.157110-0.026012-0.0744660.0860680.0314570.015314-0.093344-0.077370-0.030921...0.0000065.356580e-07-0.000015-0.000012-0.0000030.0000071.467248e-060.0000011.231290e-06-0.0000067.304807e-07-7.374172e-07-1.559129e-078.989781e-081.324989e-070.000001-9.338416e-074.267613e-07-6.008731e-076.108701e-07-6.640622e-09-4.502359e-072.061360e-071.152751e-074.441744e-077.309165e-08-5.875483e-08-1.204628e-071.133269e-071.979997e-07-4.002713e-08-6.928006e-083.225721e-08-3.729608e-08-3.529057e-093.982864e-08-7.999112e-08-8.889159e-091.980401e-08-3.009316e-08
\n", 1117 | "

5 rows × 620 columns

\n", 1118 | "
" 1119 | ], 1120 | "text/plain": [ 1121 | " 0 1 2 ... 617 618 619\n", 1122 | "0 0.097817 0.130165 0.069822 ... -1.279139e-08 1.840980e-08 -2.671326e-08\n", 1123 | "1 0.079130 0.107703 0.013614 ... -5.382707e-09 1.842500e-08 -3.027882e-08\n", 1124 | "2 0.088409 0.118777 0.089460 ... -1.037805e-08 2.075966e-08 -3.009659e-08\n", 1125 | "3 0.089270 0.120594 0.047669 ... -7.413186e-09 1.996893e-08 -3.272369e-08\n", 1126 | "4 0.578583 0.076831 0.016236 ... -8.889159e-09 1.980401e-08 -3.009316e-08\n", 1127 | "\n", 1128 | "[5 rows x 620 columns]" 1129 | ] 1130 | }, 1131 | "metadata": { 1132 | "tags": [] 1133 | }, 1134 | "execution_count": 101 1135 | } 1136 | ] 1137 | }, 1138 | { 1139 | "cell_type": "code", 1140 | "metadata": { 1141 | "id": "OMO99_hsi5RI" 1142 | }, 1143 | "source": [ 1144 | "data_reduced.to_csv(file_dir + \"pc\" + WAVELET + \".csv\", index=False)" 1145 | ], 1146 | "execution_count": 103, 1147 | "outputs": [] 1148 | }, 1149 | { 1150 | "cell_type": "code", 1151 | "metadata": { 1152 | "colab": { 1153 | "base_uri": "https://localhost:8080/", 1154 | "height": 36 1155 | }, 1156 | "id": "k0PvmvQcoa_O", 1157 | "outputId": "d1802b76-8e06-4c24-8264-ad876aaf3880" 1158 | }, 1159 | "source": [ 1160 | "file_dir" 1161 | ], 1162 | "execution_count": 122, 1163 | "outputs": [ 1164 | { 1165 | "output_type": "execute_result", 1166 | "data": { 1167 | "application/vnd.google.colaboratory.intrinsic+json": { 1168 | "type": "string" 1169 | }, 1170 | "text/plain": [ 1171 | "'/content/drive/MyDrive/EEG-emotion-python/seed dataset/SEED/temp/analysis/'" 1172 | ] 1173 | }, 1174 | "metadata": { 1175 | "tags": [] 1176 | }, 1177 | "execution_count": 122 1178 | } 1179 | ] 1180 | }, 1181 | { 1182 | "cell_type": "markdown", 1183 | "metadata": { 1184 | "id": "ZFm_Yb9JkjUZ" 1185 | }, 1186 | "source": [ 1187 | "**Running data through classifiers**\r\n", 1188 | "\r\n", 1189 | "\r\n", 1190 | "1. SVM\r\n", 1191 | "\r\n" 1192 | ] 1193 | }, 1194 | { 1195 | "cell_type": "code", 1196 | "metadata": { 1197 | "id": "6CZIMZlvj4BQ" 1198 | }, 1199 | "source": [ 1200 | "# Reading data and splitting \r\n", 1201 | "pcs = pd.read_csv(file_dir + \"pc\" + WAVELET + \".csv\")\r\n", 1202 | "outputs = pd.read_csv(file_dir + \"outputs_main.csv\", header=None)\r\n", 1203 | "\r\n", 1204 | "X = pcs.iloc[:, :].values\r\n", 1205 | "Y = outputs.iloc[:, :].values\r\n", 1206 | "\r\n", 1207 | "X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.2, random_state=42)" 1208 | ], 1209 | "execution_count": 124, 1210 | "outputs": [] 1211 | }, 1212 | { 1213 | "cell_type": "code", 1214 | "metadata": { 1215 | "colab": { 1216 | "base_uri": "https://localhost:8080/" 1217 | }, 1218 | "id": "uJRxucIelgU1", 1219 | "outputId": "afc64dae-55c2-45ba-9105-6deadcd14333" 1220 | }, 1221 | "source": [ 1222 | "svc = SVC()\r\n", 1223 | "parameters = {\"C\": (100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9), \"gamma\": (1e-08, 1e-7, 1e-6, 1e-5)}\r\n", 1224 | "grid_search = GridSearchCV(svc, parameters, n_jobs=-1, cv=5)\r\n", 1225 | "start_time = timeit.default_timer()\r\n", 1226 | "grid_search.fit(X_train, Y_train)\r\n", 1227 | "print(\"--- {0:.3f} seconds ---\".format(timeit.default_timer() - start_time))\r\n", 1228 | "print(grid_search.best_params_)\r\n", 1229 | "svc_best = grid_search.best_estimator_\r\n", 1230 | "accuracy = svc_best.score(X_test, Y_test)\r\n", 1231 | "print(\"Accuracy on the testing set is: {0:.1f}%\".format(accuracy*100))\r\n", 1232 | "prediction = svc_best.predict(X_test)\r\n", 1233 | "report = classification_report(Y_test, prediction)\r\n", 1234 | "print(report)\r\n" 1235 | ], 1236 | "execution_count": 129, 1237 | "outputs": [ 1238 | { 1239 | "output_type": "stream", 1240 | "text": [ 1241 | "/usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py:760: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n", 1242 | " y = column_or_1d(y, warn=True)\n" 1243 | ], 1244 | "name": "stderr" 1245 | }, 1246 | { 1247 | "output_type": "stream", 1248 | "text": [ 1249 | "--- 22.287 seconds ---\n", 1250 | "{'C': 10000000.0, 'gamma': 1e-05}\n", 1251 | "Accuracy on the testing set is: 69.7%\n", 1252 | " precision recall f1-score support\n", 1253 | "\n", 1254 | " -1 0.59 0.59 0.59 44\n", 1255 | " 0 0.59 0.56 0.57 41\n", 1256 | " 1 0.88 0.91 0.90 47\n", 1257 | "\n", 1258 | " accuracy 0.70 132\n", 1259 | " macro avg 0.69 0.69 0.69 132\n", 1260 | "weighted avg 0.69 0.70 0.69 132\n", 1261 | "\n" 1262 | ], 1263 | "name": "stdout" 1264 | } 1265 | ] 1266 | }, 1267 | { 1268 | "cell_type": "code", 1269 | "metadata": { 1270 | "id": "cUt4ETQuoo5I" 1271 | }, 1272 | "source": [ 1273 | "" 1274 | ], 1275 | "execution_count": null, 1276 | "outputs": [] 1277 | } 1278 | ] 1279 | } 1280 | -------------------------------------------------------------------------------- /outputs_main.csv: -------------------------------------------------------------------------------- 1 | 1 2 | 0 3 | -1 4 | -1 5 | 0 6 | 1 7 | -1 8 | 0 9 | 1 10 | 1 11 | 0 12 | -1 13 | 0 14 | 1 15 | -1 16 | 1 17 | 0 18 | -1 19 | -1 20 | 0 21 | 1 22 | -1 23 | 0 24 | 1 25 | 1 26 | 0 27 | -1 28 | 0 29 | 1 30 | -1 31 | 1 32 | 0 33 | -1 34 | -1 35 | 0 36 | 1 37 | -1 38 | 0 39 | 1 40 | 1 41 | 0 42 | -1 43 | 0 44 | 1 45 | -1 46 | 1 47 | 0 48 | -1 49 | -1 50 | 0 51 | 1 52 | -1 53 | 0 54 | 1 55 | 1 56 | 0 57 | -1 58 | 0 59 | 1 60 | -1 61 | 1 62 | 0 63 | -1 64 | -1 65 | 0 66 | 1 67 | -1 68 | 0 69 | 1 70 | 1 71 | 0 72 | -1 73 | 0 74 | 1 75 | -1 76 | 1 77 | 0 78 | -1 79 | -1 80 | 0 81 | 1 82 | -1 83 | 0 84 | 1 85 | 1 86 | 0 87 | -1 88 | 0 89 | 1 90 | -1 91 | 1 92 | 0 93 | -1 94 | -1 95 | 0 96 | 1 97 | -1 98 | 0 99 | 1 100 | 1 101 | 0 102 | -1 103 | 0 104 | 1 105 | -1 106 | 1 107 | 0 108 | -1 109 | -1 110 | 0 111 | 1 112 | -1 113 | 0 114 | 1 115 | 1 116 | 0 117 | -1 118 | 0 119 | 1 120 | -1 121 | 1 122 | 0 123 | -1 124 | -1 125 | 0 126 | 1 127 | -1 128 | 0 129 | 1 130 | 1 131 | 0 132 | -1 133 | 0 134 | 1 135 | -1 136 | 1 137 | 0 138 | -1 139 | -1 140 | 0 141 | 1 142 | -1 143 | 0 144 | 1 145 | 1 146 | 0 147 | -1 148 | 0 149 | 1 150 | -1 151 | 1 152 | 0 153 | -1 154 | -1 155 | 0 156 | 1 157 | -1 158 | 0 159 | 1 160 | 1 161 | 0 162 | -1 163 | 0 164 | 1 165 | -1 166 | 1 167 | 0 168 | -1 169 | -1 170 | 0 171 | 1 172 | -1 173 | 0 174 | 1 175 | 1 176 | 0 177 | -1 178 | 0 179 | 1 180 | -1 181 | 1 182 | 0 183 | -1 184 | -1 185 | 0 186 | 1 187 | -1 188 | 0 189 | 1 190 | 1 191 | 0 192 | -1 193 | 0 194 | 1 195 | -1 196 | 1 197 | 0 198 | -1 199 | -1 200 | 0 201 | 1 202 | -1 203 | 0 204 | 1 205 | 1 206 | 0 207 | -1 208 | 0 209 | 1 210 | -1 211 | 1 212 | 0 213 | -1 214 | -1 215 | 0 216 | 1 217 | -1 218 | 0 219 | 1 220 | 1 221 | 0 222 | -1 223 | 0 224 | 1 225 | -1 226 | 1 227 | 0 228 | -1 229 | -1 230 | 0 231 | 1 232 | -1 233 | 0 234 | 1 235 | 1 236 | 0 237 | -1 238 | 0 239 | 1 240 | -1 241 | 1 242 | 0 243 | -1 244 | -1 245 | 0 246 | 1 247 | -1 248 | 0 249 | 1 250 | 1 251 | 0 252 | -1 253 | 0 254 | 1 255 | -1 256 | 1 257 | 0 258 | -1 259 | -1 260 | 0 261 | 1 262 | -1 263 | 0 264 | 1 265 | 1 266 | 0 267 | -1 268 | 0 269 | 1 270 | -1 271 | 1 272 | 0 273 | -1 274 | -1 275 | 0 276 | 1 277 | -1 278 | 0 279 | 1 280 | 1 281 | 0 282 | -1 283 | 0 284 | 1 285 | -1 286 | 1 287 | 0 288 | -1 289 | -1 290 | 0 291 | 1 292 | -1 293 | 0 294 | 1 295 | 1 296 | 0 297 | -1 298 | 0 299 | 1 300 | -1 301 | 1 302 | 0 303 | -1 304 | -1 305 | 0 306 | 1 307 | -1 308 | 0 309 | 1 310 | 1 311 | 0 312 | -1 313 | 0 314 | 1 315 | -1 316 | 1 317 | 0 318 | -1 319 | -1 320 | 0 321 | 1 322 | -1 323 | 0 324 | 1 325 | 1 326 | 0 327 | -1 328 | 0 329 | 1 330 | -1 331 | 1 332 | 0 333 | -1 334 | -1 335 | 0 336 | 1 337 | -1 338 | 0 339 | 1 340 | 1 341 | 0 342 | -1 343 | 0 344 | 1 345 | -1 346 | 1 347 | 0 348 | -1 349 | -1 350 | 0 351 | 1 352 | -1 353 | 0 354 | 1 355 | 1 356 | 0 357 | -1 358 | 0 359 | 1 360 | -1 361 | 1 362 | 0 363 | -1 364 | -1 365 | 0 366 | 1 367 | -1 368 | 0 369 | 1 370 | 1 371 | 0 372 | -1 373 | 0 374 | 1 375 | -1 376 | 1 377 | 0 378 | -1 379 | -1 380 | 0 381 | 1 382 | -1 383 | 0 384 | 1 385 | 1 386 | 0 387 | -1 388 | 0 389 | 1 390 | -1 391 | 1 392 | 0 393 | -1 394 | -1 395 | 0 396 | 1 397 | -1 398 | 0 399 | 1 400 | 1 401 | 0 402 | -1 403 | 0 404 | 1 405 | -1 406 | 1 407 | 0 408 | -1 409 | -1 410 | 0 411 | 1 412 | -1 413 | 0 414 | 1 415 | 1 416 | 0 417 | -1 418 | 0 419 | 1 420 | -1 421 | 1 422 | 0 423 | -1 424 | -1 425 | 0 426 | 1 427 | -1 428 | 0 429 | 1 430 | 1 431 | 0 432 | -1 433 | 0 434 | 1 435 | -1 436 | 1 437 | 0 438 | -1 439 | -1 440 | 0 441 | 1 442 | -1 443 | 0 444 | 1 445 | 1 446 | 0 447 | -1 448 | 0 449 | 1 450 | -1 451 | 1 452 | 0 453 | -1 454 | -1 455 | 0 456 | 1 457 | -1 458 | 0 459 | 1 460 | 1 461 | 0 462 | -1 463 | 0 464 | 1 465 | -1 466 | 1 467 | 0 468 | -1 469 | -1 470 | 0 471 | 1 472 | -1 473 | 0 474 | 1 475 | 1 476 | 0 477 | -1 478 | 0 479 | 1 480 | -1 481 | 1 482 | 0 483 | -1 484 | -1 485 | 0 486 | 1 487 | -1 488 | 0 489 | 1 490 | 1 491 | 0 492 | -1 493 | 0 494 | 1 495 | -1 496 | 1 497 | 0 498 | -1 499 | -1 500 | 0 501 | 1 502 | -1 503 | 0 504 | 1 505 | 1 506 | 0 507 | -1 508 | 0 509 | 1 510 | -1 511 | 1 512 | 0 513 | -1 514 | -1 515 | 0 516 | 1 517 | -1 518 | 0 519 | 1 520 | 1 521 | 0 522 | -1 523 | 0 524 | 1 525 | -1 526 | 1 527 | 0 528 | -1 529 | -1 530 | 0 531 | 1 532 | -1 533 | 0 534 | 1 535 | 1 536 | 0 537 | -1 538 | 0 539 | 1 540 | -1 541 | 1 542 | 0 543 | -1 544 | -1 545 | 0 546 | 1 547 | -1 548 | 0 549 | 1 550 | 1 551 | 0 552 | -1 553 | 0 554 | 1 555 | -1 556 | 1 557 | 0 558 | -1 559 | -1 560 | 0 561 | 1 562 | -1 563 | 0 564 | 1 565 | 1 566 | 0 567 | -1 568 | 0 569 | 1 570 | -1 571 | 1 572 | 0 573 | -1 574 | -1 575 | 0 576 | 1 577 | -1 578 | 0 579 | 1 580 | 1 581 | 0 582 | -1 583 | 0 584 | 1 585 | -1 586 | 1 587 | 0 588 | -1 589 | -1 590 | 0 591 | 1 592 | -1 593 | 0 594 | 1 595 | 1 596 | 0 597 | -1 598 | 0 599 | 1 600 | -1 601 | 1 602 | 0 603 | -1 604 | -1 605 | 0 606 | 1 607 | -1 608 | 0 609 | 1 610 | 1 611 | 0 612 | -1 613 | 0 614 | 1 615 | -1 616 | 1 617 | 0 618 | -1 619 | -1 620 | 0 621 | 1 622 | -1 623 | 0 624 | 1 625 | 1 626 | 0 627 | -1 628 | 0 629 | 1 630 | -1 631 | 1 632 | 0 633 | -1 634 | -1 635 | 0 636 | 1 637 | -1 638 | 0 639 | 1 640 | 1 641 | 0 642 | -1 643 | 0 644 | 1 645 | -1 646 | 1 647 | 0 648 | -1 649 | -1 650 | 0 651 | 1 652 | -1 653 | 0 654 | 1 655 | 1 656 | 0 657 | -1 658 | 0 659 | 1 660 | -1 661 | --------------------------------------------------------------------------------