from sklearn.naive_bayes import GaussianNB
import os
from joblib import dump, load

def GaussianNaiveBayes(X_train, y_train):
    classifier = GaussianNB()
    classifier.fit(X_train, y_train)
    #print("Model loaded.")
    return classifier

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

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