Site icon Machine Learning Projects

Bank Note Authentication using Random Forest – with source code – easy project – 2023

Machine Learning Projects

In today’s blog, we will see how we can perform Bank Note Authentication or how we can classify Bank Notes into fake or authentic classes based on numeric features like variance, skewness, kurtosis, and entropy. This is going to be a very short blog, so without any further due, Let’s do it…

Code for Bank Note Authentication…

import pandas as pd
import pickle
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score

df = pd.read_csv('data/BankNote_Authentication.csv')

print(df.head())

X = df.iloc[:,:-1]
y = df.iloc[:,-1]

print(X.head())
print(y.head())

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)

rf = RandomForestClassifier()
rf.fit(X_train,y_train)

pred = rf.predict(X_test)

score = accuracy_score(y_test,pred)

print(score)

with open('classifier.pkl','wb') as file:
    pickle.dump(rf,file)

print('Model saved!!!')

#Let's test a random set of values
print(rf.predict([[-2,-3,1,1]]))
Whole data
X data
y data
Score out of 1
Output is 1(authentic)

Download the Source Code…

Do let me know if there’s any query regarding Bank Note Authentication by contacting me on email or LinkedIn.

So this is all for this blog folks, thanks for reading it and I hope you are taking something with you after reading this and till the next time ?…

Read my previous post: HOW TO FIND THE MOST DOMINANT COLORS IN AN IMAGE IN PYTHON USING KMEANS CLUSTERING

Check out my other machine learning projectsdeep learning projectscomputer vision projectsNLP projectsFlask projects at machinelearningprojects.net.

Exit mobile version