Code Monkey home page Code Monkey logo

basic-nn-model's Introduction

Developing a Neural Network Regression Model

AIM

To develop a neural network regression model for the given dataset.

THEORY

This dataset presents a captivating challenge due to the intricate relationship between the input and output columns. The complex nature of this connection suggests that there may be underlying patterns or hidden factors that are not readily apparent.

Neural Network Model

dl0

DESIGN STEPS

Step 1: Loading the Dataset

  1. Load the dataset containing features and target variables into memory.
  2. Check for data consistency and handle any missing values or anomalies.

Step 2: Splitting the Dataset

  1. Divide the dataset into training and testing subsets, ensuring a representative distribution of data in each subset.
  2. Shuffle the data before splitting to avoid any inherent ordering bias.

Step 3: Data Normalization

  1. Normalize the features using MinMaxScaler to scale them within a predefined range, typically [0, 1].
  2. Fit the scaler to the training data and transform both training and testing data accordingly.

Step 4: Building the Neural Network Model

  1. Design the architecture of the neural network model, specifying the number of layers and neurons per layer.
  2. Compile the model by defining the loss function, optimizer, and any additional metrics to monitor during training.

Step 5: Training the Model

  1. Train the neural network model using the training data, specifying the number of epochs and batch size.
  2. Monitor the training process for convergence and potential overfitting by observing the loss on both training and validation data.

Step 6: Plotting Performance

  1. Visualize the training process by plotting the training and validation loss over epochs.
  2. Plot any additional metrics such as accuracy or precision to assess the model's performance.

Step 7: Evaluating the Model

  1. Evaluate the trained model's performance using the testing data.
  2. Compute relevant metrics such as accuracy, precision, recall, and F1-score to assess the model's effectiveness.

PROGRAM

Name: Praneet S

Register Number: 212221230078

DEPENDENCIES:

import pandas as pd
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense,Dropout

DATA FROM SHEETS:

from google.colab import auth
import gspread
from google.auth import default
import pandas as pd
auth.authenticate_user()
creds, _ = default()
gc = gspread.authorize(creds)
worksheet = gc.open('exp1').sheet1
rows = worksheet.get_all_values()
df = pd.DataFrame(rows[1:], columns=rows[0])

DATA VISUALIZATION:

import pandas as pd
import seaborn as sns
df['Input 1 (Number)'] = pd.to_numeric(df['Input 1 (Number)'])
sns.pairplot(df)

df['Input 1 (Number)'] = pd.to_numeric(df['Input 1 (Number)'])
df['Output'] = pd.to_numeric(df['Output'])
X = df['Input 1 (Number)']
y=df['Output']

DATA SPLIT AND PREPROCESSING:

from sklearn.model_selection import train_test_split
x_train,x_test,y_train,y_test = train_test_split(X,y,test_size=0.2,random_state=42)

x_train = x_train.values.reshape(-1, 1)
x_test = x_test.values.reshape(-1, 1)

from sklearn.preprocessing import MinMaxScaler
M = MinMaxScaler()
x_train = M.fit_transform(x_train)

REGRESSIVE MODEL:

model = Sequential()
model.add(Dense(15,activation='relu',input_shape=x_train.shape))
model.add(Dense(10,activation='relu'))
model.add(Dense(1))

model.summary()

model.compile(optimizer='rmsprop',loss='mse')
model.fit(x_train,y_train,epochs=80)
model.history

LOSS CALCULATION:

loss_df = pd.DataFrame(model.history.history)
loss_df.plot()

PREDICTION:

y_pred=model.predict(x_test)
y_pred

Dataset Information

dl1

OUTPUT

Pairplot(data)

dl2

ARCHITECTURE AND TRAINING:

dl3

dl4

Training Loss Vs Iteration Plot

dl5

Test Data Root Mean Squared Error

dl6

New Sample Data Prediction

dl7

RESULT

Summarize the overall performance of the model based on the evaluation metrics obtained from testing data as a regressive neural network based prediction has been obtained.

basic-nn-model's People

Contributors

etjabajasphin avatar joeljebitto avatar obedotto avatar praneet002 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.