from sklearn.ensemble import AdaBoostClassifier
import os
from joblib import dump, load

def AdaBoost(X_train, y_train, nEstimators, learningRate):
    classifier = AdaBoostClassifier(n_estimators = nEstimators, learning_rate=learningRate, random_state=0)
    classifier.fit(X_train, y_train)
    return classifier

def Persist(classifier):
    if os.path.exists("./trained_models/AdaBoost.joblib"):
        os.remove("./trained_models/AdaBoost.joblib")
    else:
        print("The file does not exist.")
    dump(classifier, "./trained_models/AdaBoost.joblib")
    print("Model stored.")

def Load():
    classifier = load("./trained_models/AdaBoost.joblib")
    #print("Model loaded.")
    return classifier