diff --git a/blockchain_integration/PiSure/ml/models/riskAssessment/risk_assessment_model.py b/blockchain_integration/PiSure/ml/models/riskAssessment/risk_assessment_model.py new file mode 100644 index 000000000..2480f5cba --- /dev/null +++ b/blockchain_integration/PiSure/ml/models/riskAssessment/risk_assessment_model.py @@ -0,0 +1,19 @@ +import pandas as pd +from sklearn.ensemble import RandomForestClassifier +from sklearn.model_selection import train_test_split +from sklearn.metrics import accuracy_score, classification_report + +class RiskAssessmentModel: + def __init__(self): + self.model = RandomForestClassifier(n_estimators=100, random_state=42) + + def train(self, X, y): + X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) + self.model.fit(X_train, y_train) + y_pred = self.model.predict(X_test) + print("Accuracy:", accuracy_score(y_test, y_pred)) + print("Classification Report:") + print(classification_report(y_test, y_pred)) + + def predict(self, X): + return self.model.predict(X)