# Presidential Election

- Date: Dec 2017
- Category: Data Science
- Key Tags: Supervised Regression, SVM, Neural Network

A machine learning Supervised Regression project about presidential prediction.

# Introduction

It is a Machine Learning Supervised Regression project. Check project code: Source Code

Team Members: Binhan Wang, Runze Zhang, Lingyao Meng, Dimeng Deng.

By assembling past 20 years’ data, this R project can forecast Democratic and Republican support rates in each states during the elections. functions:

- Calculate correlation value between each attribute.
- Training Neural Network and SVM to do the prediction and calculate RMSE to show the performance.

#### Proposed solution and methods

- Exploratory data analysis.
- Calculate correlation value between each attribute.
- Partition data into training and validation sets.
- Create the neural network layout.
- Create the training patterns: Each training pattern will be four values, with the first three corresponding to the input nodes and the last one defining what the correct value is for the output node.
- Train the neural network and SVM on these patterns
- Test the network on the validation set: Here we pass in the three values the neural network needs for the input layer and see what the output node gets set to.

#### Result

- Nnet: standard deviation(Hillary): 0.037 standard deviation(Trump): 0.065
- Nn: standard deviation(Hillary): 0.044 standard deviation(Trump): 0.054
- SVM: standard deviation(Hillary): 0.078 standard deviation(Trump): 0.078

Based on the experimental result, neural net has less standard deviation than SVM. The neural net model which has two hidden layers will be the most appropriate result in our project.

This Script has been tested on MacOS 10.11.6 and R-Studio Version 0.99.903

#### Usage:

- Run the script in R-Studio using “Source”.
- Follow the prompt to select the “data.csv” come with the code.
- See the output from console.

#### Used R Packages:

```
require(corrplot)
require(nnet)
require(neuralnet)
require(e1071)
```

#### Functions

The script contains the code for:

- Calculate correlation value between each attribute.
- Pre-processing the data for training leaners to do time serial forecast.
- Training Neural Network and SVM to do the prediction and calculate RMSE to show the performance.