diff --git a/blockchain_development_integration/pi_network/components/fraud_detection/fraud_detection.py b/blockchain_development_integration/pi_network/components/fraud_detection/fraud_detection.py new file mode 100644 index 000000000..a2748e218 --- /dev/null +++ b/blockchain_development_integration/pi_network/components/fraud_detection/fraud_detection.py @@ -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]