Giter Club home page Giter Club logo

basic-nn-model's Introduction

EX 1 - Developing a Neural Network Regression Model

AIM

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

THEORY

A neural network can be used to solve a problem by Data collection and Preprocessing,choosing a appropriate neural network architecture ,Train the neural network using the collected and preprocessed data,Assess the performance of the trained model using evaluation metrics,Depending on the performance of the model, you might need to fine-tune hyperparameters or adjust the architecture to achieve better results,Once you're satisfied with the model's performance, you can deploy it to production where it can be used to make predictions on new, unseen data

For the problem statement we have dealt with , we have developed a neural network with three hidden layers. First hidden layer consists of 4 neurons ,second hidden layer with 8 neurons , third layer with 5 neurons . The input and output layer contain 1 neuron . The Activation Function used is 'relu'.

Neural Network Model

image

DESIGN STEPS

STEP 1:

Loading the dataset

STEP 2:

Split the dataset into training and testing

STEP 3:

Create MinMaxScalar objects ,fit the model and transform the data.

STEP 4:

Build the Neural Network Model and compile the model.

STEP 5:

Train the model with the training data.

STEP 6:

Plot the performance plot

STEP 7:

Evaluate the model with the testing data.

PROGRAM

Name: Dhivyapriya.R

Register Number: 212222230032

Dependencies

import numpy as np

import pandas as pd

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

DATA 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('DL').sheet1
rows = worksheet.get_all_values()

DATA PROCESSING

df = pd.DataFrame(rows[1:], columns=rows[0])

df.head()
df['Input']=pd.to_numeric(df['Input'])

df['Output']=pd.to_numeric(df['Output'])
X = df[['Input']].values

y = df[['Output']].values
x_train,x_test,y_train,y_test = train_test_split(X,y,test_size = 0.33,random_state = 33)
Scaler = MinMaxScaler()

Scaler.fit(x_train)
x_train.shape

x_train1 = Scaler.transform(x_train)

x_train1.shape

MODEL ARCHITECTURE AND TRAINING

model = Sequential([
Dense(units = 5,activation = 'relu',input_shape=[1]),
Dense(units = 2, activation = 'relu'),
Dense(units = 1)
])
model.compile(optimizer='rmsprop', loss = 'mae')

model.fit(x_train1,y_train,epochs = 2000)

model.summary()

LOSS CALCULATION

x_test1 = Scaler.transform(x_test)

model.evaluate(x_test1,y_test)
x_n = [[21]]

x_n1 = Scaler.transform(x_n)

model.predict(x_n1)

OUTPUT

DATASET INFORMATION

image

Training Loss Vs Iteration Plot

image

Test Data Root Mean Squared Error

image

New Sample Data Prediction

image

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 dhivyapriyar avatar obedotto 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.