File size: 656 Bytes
2f7dda8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9628c5e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# prediction_model.py
import pandas as pd
from sklearn.tree import DecisionTreeClassifier
import pickle

def train_document_model():
    df = pd.read_csv("data.csv")

    df["Document_Status"] = df["Document_Status"].map({"active": 0, "expiring": 1})
    df["Risk_Level"] = df["Risk_Level"].map({"Low": 0, "High": 1})

    X = df[["Days_Left", "Document_Status"]]
    y = df["Risk_Level"]

    model = DecisionTreeClassifier()
    model.fit(X, y)

    pickle.dump(model, open("document_model.sav", "wb"))
    print("✔ تم تدريب نموذج الوثائق Document Model")

if __name__ == "__main__":
    train_document_model()