Skip to content

Commit

Permalink
Create fraud_detection.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Dec 2, 2024
1 parent 6c6cab0 commit 2d1c0c5
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# fraud_detection.py
import pandas as pd
from sklearn.ensemble import IsolationForest

def detect_fraud(transactions):
model = IsolationForest(contamination=0.01)
model.fit(transactions[['amount', 'time', 'location']])
transactions['is_fraud'] = model.predict(transactions[['amount', 'time', 'location']])
return transactions[transactions['is_fraud'] == -1]

0 comments on commit 2d1c0c5

Please sign in to comment.