# 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

1. Exploratory data analysis.
2. Calculate correlation value between each attribute.
3. Partition data into training and validation sets.
4. Create the neural network layout.
5. 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.
6. Train the neural network and SVM on these patterns
7. 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.

![PE](/img/PE.png)

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

#### Usage:

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

#### Used R Packages:

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

#### Functions

The script contains the code for:

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