-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |