from sklearn.svm import SVC
import os
from joblib import dump, load

def SVM(X_train, y_train, Kernel):
    classifier = SVC(kernel=Kernel, random_state=0, probability=True)
    classifier.fit(X_train, y_train)
    print("Model trained.")
    return classifier

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

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