Neural Network

OVERVIEW

A feedforward neural network (FFNN) is a type of artificial neural network (ANN) where information flows in one direction, from the input layer through one or more hidden layers to the output layer, without any feedback loops. This architecture is widely used for various machine learning tasks, including classification, regression, and pattern recognition.

nn1

Input Layer:

The input layer is where data is fed into the network. Each node in the input layer represents a feature or attribute of the input data. Each neuron in this layer corresponds to one feature.

Hidden Layer:

Between the input and output layers, there can be one or more hidden layers. Each hidden layer consists of multiple neurons (nodes), and each neuron applies a weighted sum of inputs followed by an activation function to produce an output. The outputs from the neurons in one hidden layer serve as inputs to the next hidden layer or the output layer.

Output Layer:

The output layer produces the final prediction or classification based on the information processed through the hidden layers. The number of nodes in the output layer depends on the type of problem being solved. For example, in binary classification, there may be one node representing the probability of belonging to one class, while in multi-class classification, there can be multiple nodes representing the probabilities of each class.

Weights and Activation Functions:

The connections between neurons in different layers are associated with weights, which are adjusted during the training process to minimize the error between predicted and actual outputs. Each neuron typically applies an activation function to the weighted sum of its inputs to introduce non-linearity into the network, enabling it to learn complex patterns in the data.

Forward Pass:

During the forward pass, input data is propagated through the network layer by layer, with each layer applying transformations to the input until the final output is obtained. This process is called forward propagation.

Training:

During training, the network learns to adjust its weights based on a loss function that measures the difference between predicted and actual outputs. This is typically done using optimization algorithms such as gradient descent, which iteratively updates the weights to minimize the loss.

Activation Function:

It determines the output of a neuron in a neural network, based on its input. It introduces non-linearity into the network, allowing it to learn complex patterns in the data.

nn6

PLAN

  1. Load the cleaned Denver weather dataset, pre process it to label weather descriptions, convert features into Category/Factor type, and filter data for Denver only.
  2. Split the dataset into training and testing sets using stratified sampling stratified sampling in python and random sampling without replacement in R to ensure proportional representation of each class in both sets.
  3. Train Feed Forward Neural Network model with input layer, one hidden Layer with 3 units, output layer and evaluate accuracy, and generate confusion matrices.

DATA PREPARATION

  1. Feed Forward Neural Network require labeled data for training.
  2. They also require label in binary form i.e., 0 or 1.

  1. Before Transformation:
  2. The below image shows the sample of data before transformation.

    aftercleaning

  3. After Filtering Denver Data:
  4. The below image shows the data after filtering city by Denver.

    Filtering Denver Data

  5. After Transformation (Python):
  6. The below image shows the data after after After labelling (clear/not clear) the data for classification and changing its type to Category.

    labelling

  7. Splitting data into Train and Test set (Python):
  8. The below image shows train and test data created using stratified sampling to ensure that each class is represented proportionally in both sets. Train and test sets are disjoint to ensure that the model is evaluated on data it hasn't seen during training, enabling an unbiased assessment of its performance.

    labelling

  9. Checking the balance of the Train and Test set (Python):
  10. The below image shows the distribution of labels in the Train and Test set. They are well balanced.

    labelling

  11. One Hot Encoding for Label:
  12. The below image displays labels after converting into binary form using one hot encoding.

    labelling

  13. Classification Dataset:
  14. classificationdata.csv

CODE

  1. Neural Network (Python):
  2. NN (py).ipynb

RESULTS

  1. Architecture of the Feed Forward Neural Network:
  2. accuracy (Python)

    The above image displays architecture of the Feed Forward Neural Network model used. It has one input layer, 1 hidden layer with 3 hidden units and with ReLU activation function and an output layer with Sigmoid activation function.

  3. Accuracy:
  4. accuracy (Python)

    Feed Forward Neural Network achieved an accuracy of 55.72%.

  5. Confusion Matrix:
  6. nn4

    The above images displays confusion matrix of Feed Forward Neural Network.

CONCLUSION

This study focuses on clear weather prediction in Denver and its practical consequences for daily life. Understanding when the weather will clear is critical for a wide range of activities. From organizing outside gatherings like picnics and sports games to scheduling building projects and outdoor maintenance jobs. Clear weather also plays an important role in trip planning because it provides safer driving conditions and easier flights. Individuals and organizations can make better informed decisions by properly anticipating clear weather. It results in more efficient and enjoyable experiences in both personal and professional settings. The study's overall findings demonstrate the value of predictive modeling in precisely predicting clear weather, which eventually improves community well-being and resistance to weather-related issues. Through the utilization of these insights, individuals and organizations can enhance their decision-making abilities and guarantee safer and more pleasurable experiences for all stakeholders. Communities may improve their quality of life and resistance to weather-related changes by better understanding and preparing for weather-related concerns. This will create safer, more lively, and more sustainable settings for both locals and visitors.