Classifying Authenticity of Banknotes using Machine Learning
Machine learning is the art of giving a computer data, and having it learn trends from that data and then make predictions based on new data. Machine learning is a subfield of artificial intelligence. Its goal is to enable computers to learn on their own. Machine learning is an application of artificial intelligence (AI) that provides systems the ability to automatically learn and improve from experience without being explicitly programmed. Machine learning focuses on the development of computer programs that can access data and use it to learn for themselves.The process of learning begins with observations or data, such as examples, direct experience, or instruction, in order to look for patterns in data and make better decisions in the future based on the examples that we provide.
Myself Happy khatun.
I am a student of city university. And this blog is a part of our AI
(Artificial Intelligence) Lab Course conducted by our most honorable teacher
Nuruzzaman Faruqui.
Here we will discuss and implement machine learning algorithm in order to detecting fake or real Banknotes.
Now we are going to train a machine on a dataset and then put it on testing.There are five-section and the last section depends on the first four sections. In the last sections, it will find the notes is real or fake. The first section is variance, the second is skewness, the third is kurtosis, fourth is entropy. we'll use 40% of our dataset in our programme.we will use perceptron learning, SVM, K-nearest neighbor, and GaussianNB to check which classification model performs well on our data.
For this we will need this following code
# pip install scikit-learn
import csv
import random
from sklearn import svm
from sklearn.linear_model import Perceptron
from sklearn.naive_bayes import GaussianNB
from sklearn.neighbors import KNeighborsClassifier
model = Perceptron()
# model = svm.SVC()
# model = KNeighborsClassifier(n_neighbors=1)
# model = GaussianNB()
# Read data in from file
with open("banknotes.csv") as f:
reader = csv.reader(f)
next(reader)
data = []
for row in reader:
data.append({
"evidence": [float(cell) for cell in row[:4]],
"label": "Authentic" if row[4] == "0" else "Counterfeit"
})
# Separate data into training and testing groups
holdout = int(0.40 * len(data))
random.shuffle(data)
testing = data[:holdout]
training = data[holdout:]
# Train model on training set
X_training = [row["evidence"] for row in training]
y_training = [row["label"] for row in training]
model.fit(X_training, y_training)
# Make predictions on the testing set
X_testing = [row["evidence"] for row in testing]
y_testing = [row["label"] for row in testing]
predictions = model.predict(X_testing)
# Compute how well we performed
correct = 0
incorrect = 0
total = 0
for actual, predicted in zip(y_testing, predictions):
total += 1
if actual == predicted:
correct += 1
else:
incorrect += 1
# Print results
print(f"Results for model {type(model).__name__}")
print(f"Correct: {correct}")
print(f"Incorrect: {incorrect}")
print(f"Accuracy: {100 * correct / total:.2f}%")
|
Model |
correct |
Incorrect |
Accuracy |
|
Perceptron |
539 |
9 |
98.36% |
|
SVM |
545 |
3 |
99.45% |
|
KNN |
548 |
0 |
100% |
|
GaussianNB |
457 |
91 |
83.39% |
Here we can see that KNN has the hihgest accuracy among Perceptron, SVM, GaussianNB. And GaussianNB has the lowest accuracy.
Modern day machine learning has two objectives, one is to classify data based on models which have been developed, the other purpose is to make predictions for future outcomes based on these models.
In this blog we discuss about the implementation of machine learning in detecting Banknotes in a easiest way.so, this is the easiest way to learn python programming.

No comments:
Post a Comment