Professional Documents
Culture Documents
Experiment 9
Experiment 9
The backpropagation algorithm is a type of supervised learning algorithm for artificial neural networks
where we fine-tune the weight functions and improve the accuracy of the model. It employs the
gradient descent method to reduce the cost function. It reduces the mean-squared distance between
the predicted and the actual data. This type of algorithm is generally used for training feed-forward
neural networks for a given data whose classifications are known to us.
You can also think of backward propagation as the backward spread of errors in order to achieve more
accuracy. If we have received a prediction from a neural network model which has a huge difference
from the actual output, we need to apply the backpropagation algorithm to achieve higher accuracy.
Note: Feed-forward neural networks are generally multi-layered neural networks (MLN). The data travels
from the input layer to the hidden layer to the output layer.
''' Implement the finite words classification system using Back-propagation algorithm
=================================
Explanation:
=================================
===> To run this program you need to install the pandas Module
===> To install, Open Command propmt and then execute the following command
===> Open Command propmt and then execute the following command to install sklearn-neuralnetwork
Module
Source Code:
import pandas as pd
X = msglbl_data["Message"]
Y = msglbl_data.labelnum
count_vect = CountVectorizer()
Xtrain_dims = count_vect.fit_transform(Xtrain)
Xtest_dims = count_vect.transform(Xtest)
df = pd.DataFrame(Xtrain_dims.toarray(),columns=count_vect.get_feature_names_out())
clf.fit(Xtrain_dims, Ytrain)
prediction = clf.predict(Xtest_dims)
print(10*"-")
test_dims = count_vect.transform(test_stmt)
pred = clf.predict(test_dims)
if lbl == 1:
print("Statement is Positive")
else:
print("Statement is Negative")
Dataset Creation :
create :
Statements_data.csv in notepad
My place is horrible,neg
I love to sing,pos
I love to dance,pos
OUTPUT: