To develop a neural network regression model for the given dataset.
The Neural network model contains input layer,two hidden layers and output layer.Input layer contains a single neuron.Output layer also contains single neuron.First hidden layer contains six neurons and second hidden layer contains five neurons.A neuron in input layer is connected with every neurons in a first hidden layer.Similarly,each neurons in first hidden layer is connected with all neurons in second hidden layer.All neurons in second hidden layer is connected with output layered neuron.Relu activation function is used here .It is linear neural network model(single input neuron forms single output neuron).Explain the problem statement
Loading the dataset
Split the dataset into training and testing
Create MinMaxScalar objects ,fit the model and transform the data.
Build the Neural Network Model and compile the model.
Train the model with the training data.
Plot the performance plot
Evaluate the model with the testing data.
# Developed By : Dineshkumar V
# Register Number : 212220230013
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
df=pd.read_csv("data.csv")
df.head()
x=df[['input']].values
x
y=df[['output']].values
y
xtrain,xtest,ytrain,ytest=train_test_split(x,y,test_size=0.3,random_state=40)
scaler=MinMaxScaler()
scaler.fit(xtrain)
scaler.fit(xtest)
xtrain1=scaler.transform(xtrain)
xtest1=scaler.transform(xtest)
model=Sequential([
Dense(6,activation='relu'),
Dense(5,activation='relu'),
Dense(1),
])
model.compile(optimizer='rmsprop',loss='mse')
model.fit(xtrain1,ytrain,epochs=5000)
lossmodel=pd.DataFrame(model.history.history)
lossmodel.plot()
model.evaluate(xtest1,ytest)
xn1=[[30]]
xn11=scaler.transform(xn1)
model.predict(xn11)
Thus, the neural network model regression model for the given dataset is developed.