Skip to content

Commit

Permalink
Create fraud_detection_model.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored May 10, 2024
1 parent a50f1a4 commit 5e79cd2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions fraud_detection/fraud_detection_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import numpy as np
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split

class FraudDetectionModel:
def __init__(self, data):
self.data = data
self.X = self.data.drop('fraudulent', axis=1)
self.y = self.data['fraudulent']

def train_model(self):
X_train, X_test, y_train, y_test = train_test_split(self.X, self.y, test_size=0.2, random_state=42)
self.model = RandomForestClassifier(n_estimators=100, random_state=42)
self.model.fit(X_train, y_train)

def predict_fraud(self, new_data):
return self.model.predict(new_data)

0 comments on commit 5e79cd2

Please sign in to comment.