Python Project: Authenticity and Durability Detector for Devices
Counterfeit electronic devices are an ever-growing challenge in today’s tech-savvy world. With fakes mimicking genuine products to the…
Python Project: Authenticity and Durability Detector for Devices
Counterfeit electronic devices are an ever-growing challenge in today’s tech-savvy world. With fakes mimicking genuine products to the smallest detail, consumers and businesses face the risk of falling victim to substandard devices. This project aims to solve that problem by creating a Python-based solution to identify real vs. fake devices, assess durability, extract key manufacturing details, and provide insights using advanced analytics and visualizations.
Features of the Project
- Authenticity Check: Verify whether the device is genuine or counterfeit using serial numbers, manufacturing codes, and warranty details.
- Durability Assessment: Predict the lifespan of a device using advanced scoring metrics based on hardware health, daily usage, and brand reputation.
- Manufacturing Insights: Extract details such as the date and location of manufacture.
- Usage Recommendations: Provide alerts for fake devices or suggest replacements for devices with low durability.
- Graphical Reports: Visualize insights such as the number of fake devices, average durability by brand, and warranty trends.
- Database Integration: Save analyzed data for future reference in SQLite.
- AI-Powered Recommendations: Use a lightweight machine learning model to offer advanced predictions.
Dataset:

Step-by-Step Implementation
1. Data Loading and Preprocessing
import pandas as pd
# Create DataFrame
data = {
'Device_ID': [1, 2, 3, 4, 5, 6, 7, 8],
'Serial_Number': ['SN123456', 'FAKE1234SN', 'A1B2C3D4E5', 'REALPC789', 'SN0987FAKE', 'GHT98765', 'REAL789123', 'FAKECODE987'],
'Brand': ['Apple', 'Samsung', 'Apple', 'Dell', 'Xiaomi', 'Lenovo', 'Samsung', 'OnePlus'],
'Model': ['iPhone 14 Pro', 'Galaxy S21', 'MacBook Air', 'Inspiron 15', 'Redmi Note 10', 'ThinkPad X1', 'Galaxy Z Fold3', 'OnePlus 9 Pro'],
'Manufacture_Code': ['2023-02-USA', 'N/A', '2021-11-USA', '2022-03-IND', 'N/A', '2020-10-CN', '2022-08-KOR', 'N/A'],
'Warranty_Status': ['Active', 'Invalid', 'Expired', 'Active', 'Invalid', 'Expired', 'Active', 'Invalid'],
'Avg_Daily_Usage': [6.5, 2.0, 8.0, 5.5, 1.0, 7.0, 5.0, 4.0],
'Hardware_Health': [85, 60, 90, 75, 30, 65, 80, 40],
'Purchase_Date': ['2023-02-10', '2021-08-14', '2021-11-20', '2022-03-15', '2020-05-18', '2020-10-05', '2022-08-20', '2021-03-10'],
'User_Region': ['USA', 'India', 'Canada', 'UK', 'India', 'Germany', 'USA', 'India'],
'Reported_Issues': ['None', 'Screen Flickering', 'Overheating', 'None', 'Frequent Shutdowns', 'Keyboard Malfunction', 'None', 'Battery Swelling'],
'Battery_Cycles': [400, 600, 800, 500, 300, 700, 350, 400],
'Device_Type': ['Smartphone', 'Smartphone', 'Laptop', 'Laptop', 'Smartphone', 'Laptop', 'Smartphone', 'Smartphone']
}
df = pd.DataFrame(data)
# Convert Purchase_Date to datetime
df['Purchase_Date'] = pd.to_datetime(df['Purchase_Date'])
2. Advanced Authenticity Check
Expand the authenticity detection logic by checking for valid serial numbers and brand-manufacturer mismatches.
# Authenticity detection
def detect_fake_device(row):
if row['Manufacture_Code'] == 'N/A' or row['Warranty_Status'] == 'Invalid' or "FAKE" in row['Serial_Number']:
return 'Fake'
return 'Real'
df['Authenticity'] = df.apply(detect_fake_device, axis=1)
3. Predict Durability Using Machine Learning
Train a simple regression model to predict durability based on daily usage, hardware health, and battery cycles.
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
# Prepare data
X = df[['Avg_Daily_Usage', 'Hardware_Health', 'Battery_Cycles']]
y = 10 - (df['Avg_Daily_Usage'] * 0.5) + (df['Hardware_Health'] * 0.4) + (df['Battery_Cycles'] * 0.1)
# Train model
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
model = LinearRegression()
model.fit(X_train, y_train)
# Predict durability
df['Predicted_Durability'] = model.predict(X)
4. Notifications for Fake or Low-Durability Devices
Send notifications based on durability and authenticity.
# Notifications
def generate_notification(row):
if row['Authenticity'] == 'Fake':
return f"Device {row['Serial_Number']} is FAKE. Avoid using it."
elif row['Predicted_Durability'] < 5:
return f"Device {row['Serial_Number']} has LOW DURABILITY. Consider replacing it."
return "Device is in GOOD CONDITION."
df['Notification'] = df.apply(generate_notification, axis=1)
5. Data Visualization
Visualize insights like the distribution of fake devices or average durability by brand using matplotlib or seaborn.
import seaborn as sns
import matplotlib.pyplot as plt
# Plot Fake vs Real Devices
sns.countplot(data=df, x='Authenticity', palette='coolwarm')
plt.title('Real vs Fake Devices')
plt.show()
# Plot Average Durability by Brand
sns.barplot(data=df, x='Brand', y='Predicted_Durability', palette='viridis')
plt.title('Average Durability by Brand')
plt.show()

Enhancements to the Project
- Integrate Real-Time API Checks Use APIs from manufacturers (like Apple’s GSX or Google’s device registry) to validate serial numbers, manufacture codes, and warranty details dynamically.
import requests
def check_serial_api(serial_number):
url = f"https://api.manufacturer.com/verify?serial={serial_number}"
response = requests.get(url)
if response.status_code == 200:
return response.json()['authenticity_status']
return "Unknown"
df['API_Authenticity'] = df['Serial_Number'].apply(check_serial_api)
2. Add AI-Powered Fraud Detection Train a machine learning model to classify devices as fake or real based on historical fraud patterns using features like purchase region, reported issues, and hardware health.
from sklearn.ensemble import RandomForestClassifier
# Add a fraud indicator column (1 = fake, 0 = real) for training
df['Fraud_Indicator'] = df['Authenticity'].apply(lambda x: 1 if x == 'Fake' else 0)
# Train a classifier
X = df[['Avg_Daily_Usage', 'Hardware_Health', 'Battery_Cycles']]
y = df['Fraud_Indicator']
model = RandomForestClassifier()
model.fit(X, y)
# Predict fraud
df['AI_Predicted_Authenticity'] = model.predict(X)
3. User Authentication and Dashboard Build a secure user interface using Flask or Django, allowing users to upload their device details and view real-time analysis.
- Admin Dashboard: Monitor fraud trends and view aggregated reports.
- User Reports: Generate and download personalized device health reports in PDF format.
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html')
@app.route('/analyze', methods=['POST'])
def analyze():
serial_number = request.form['serial_number']
# Perform analysis and return results
return render_template('result.html', result="Device is Genuine")
if __name__ == '__main__':
app.run(debug=True)
4. Graphical Enhancements Add interactive dashboards using Plotly Dash or Streamlit. Users can explore:
- Device fraud trends by region
- Average device health per brand
- Top reported issues by device type
import plotly.express as px
# Interactive scatter plot for durability vs daily usage
fig = px.scatter(df, x='Avg_Daily_Usage', y='Predicted_Durability',
color='Authenticity', size='Hardware_Health',
hover_data=['Brand', 'Model'])
fig.show()
5. Add Notifications via Email or SMS Integrate Twilio or SMTP for real-time notifications.
from twilio.rest import Client
def send_notification(serial_number, message):
client = Client('account_sid', 'auth_token')
client.messages.create(
to='+1234567890',
from_='+0987654321',
body=f"Device {serial_number}: {message}"
)
df[df['Authenticity'] == 'Fake'].apply(
lambda row: send_notification(row['Serial_Number'], "Fake Device Alert"), axis=1
)
6. Cloud Integration Store device data in a cloud database (like Firebase or AWS DynamoDB) for centralized access, enabling multiple users to query device authenticity.
import firebase_admin
from firebase_admin import credentials, firestore
cred = credentials.Certificate("path_to_firebase_credentials.json")
firebase_admin.initialize_app(cred)
db = firestore.client()
# Upload each device record to Firestore
for _, row in df.iterrows():
db.collection('devices').add(row.to_dict())
7. Durability Predictions Using Deep Learning Replace traditional regression with deep learning models (e.g., TensorFlow or PyTorch) for more accurate predictions.
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
# Preparing data
X = df[['Avg_Daily_Usage', 'Battery_Health', 'Hardware_Health']]
y = df['Authenticity'].apply(lambda x: 1 if x == 'Real' else 0)
# Train a Random Forest model
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
model = RandomForestRegressor()
model.fit(X_train, y_train)
# Predict durability
df['Durability_Score'] = model.predict(X)
Conclusion
This project demonstrates how Python can be used to analyze device authenticity, durability, and other factors. With advanced features like machine learning predictions, detailed reports, and visualizations, this project can benefit both consumers and businesses alike.
메타데이터
- post_id
- 6becf228be8f
- slug
- python-project-authenticity-and-durability-detector-for-devices-6becf228be8f
- url
- https://medium.com/@abhishekshaw020/python-project-authenticity-and-durability-detector-for-devices-6becf228be8f
- canonical_url
- https://medium.com/@abhishekshaw020/python-project-authenticity-and-durability-detector-for-devices-6becf228be8f
- author_url
- https://medium.com/@abhishekshaw020
- status
- ok
- fetched_at
- 2026-07-29 11:02:05