From 6c0eb5a9406524f3caa41d7508b98a0849b9faeb Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 19:27:27 +0700 Subject: [PATCH] Create risk_assessment.py --- risk_management/risk_assessment.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 risk_management/risk_assessment.py diff --git a/risk_management/risk_assessment.py b/risk_management/risk_assessment.py new file mode 100644 index 000000000..6bdb51647 --- /dev/null +++ b/risk_management/risk_assessment.py @@ -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 RiskAssessment: + def __init__(self, data): + self.data = data + self.X = self.data.drop('risk_level', axis=1) + self.y = self.data['risk_level'] + + 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_risk(self, new_data): + return self.model.predict(new_data)