PROJECT1
PROJECT1
On
CREDIT CARD FRAUD DETECTION
TRANSACTION
Submitted in partial fulfillment of
Diploma In Computer Engineering
Submitted By:
KASHISH MHOVIA (216300307006)
KARINA SHARMA (226300307120)
PRUTHA PANCHAL (226300307078)
HEM PANCHAL (206300307097)
Government Polytechnic, Dahod
CERTIFICATE
Signature of
Course Teacher
Government Polytechnic, Dahod
CERTIFICATE
Signature of
Course Teacher
Government Polytechnic, Dahod
CERTIFICATE
Signature of
Course Teacher
Government Polytechnic, Dahod
CERTIFICATE
Signature of
Course Teacher
Step-by-Step
Explanation
Importing Libraries:
o import pandas as pd
data = {
'transaction_id': [1, 2, 3, 4, 5],
'amount': [100, 1500, 200, 3000,
50],
'location': ['USA', 'USA', 'Canada',
'USA', 'Canada'],
'time': ['2023-10-01 10:00', '2023-
10-01 10:05', '2023-10-01 10:10',
'2023-10-01 10:15', '2023-10-01
10:20'],
'user_id': [101, 101, 102, 101, 102]
}
ITERATING THROUGH
TRANSACTIONS:
o for index, row in transactions.iterrows():
fraud_cases.append((row['transaction_id'],
'High transaction amount'))
fraud_cases.append((row['transaction_id'],
'Unusual location'))
# Check for multiple transactions in a
short time frame
recent_transactions =
transactions[(transactions['user_id'] ==
row['user_id']) &
(transactions['time']
< row['time'])]
if not recent_transactions.empty:
time_diff = pd.to_datetime(row['time'])
-
pd.to_datetime(recent_transactions['time'].max
())
if time_diff.total_seconds() < 300: # 5
minutes
fraud_cases.append((row['transaction_id'],
'Multiple transactions in short time'))
return fraud_cases
# Detect fraud in transactions
fraudulent_transactions =
detect_fraud(transactions)
# Output results
if fraudulent_transactions:
print("Fraudulent Transactions Detected:")
for transaction in fraudulent_transactions:
print(f"Transaction ID: {transaction[0]},
Reason: {transaction[1]}")
else:
print("No fraudulent transactions detected.")
PROJECT OUTPUT