import operator
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.preprocessing import StandardScaler
import time
from Accuracy import Accuracy
from getXY import getXY, getXY_single
import sys
from sklearn.model_selection import train_test_split
from pprint import pprint as pp
import os

X, y = getXY(sys.argv[1])
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)

from Models.Logistic import Load
modelLR = Load()

### ---------------- Random Forest ---------------------- ###

from Models.RandomForest import Load as RLoad
modelRF = RLoad()

### ------------------------ SVM --------------------------- ###

from Models.SVM import Load as SVMLoad
modelSVM = SVMLoad()

### ---------------------- AdaBoost ------------------------- ###

from Models.AdaBoost import Load as AdaLoad
modelAda = AdaLoad()

### --------------------- Gradient Boosting ---------------- ###

from Models.GradientBoosting import Load as GBLoad
modelGB = GBLoad()

### -------------------- XGBoost --------------------------- ###

from Models.XGBoost import Load as XGBLoad
modelXGB = XGBLoad()

### --------------------- Decision Tree ------------------------ ###

from Models.DecisionTree import Load as DTLoad
modelDT = DTLoad()

### -------------------------------------------------------- ###

from features.get_features import get_features

while (True):
    print("----------------------------------------------------------")
    print("----------------------------------------------------------")
    print("Enter the file name: ")
    s = input()
    out = os.getcwd() + '/features/temp_dataset_for_input.csv'
    inp = os.getcwd() + '/' + s
    get_features(inp, out)

    x, y = getXY_single(out)

    print("----------------------------------------------------------")
    print("\n\nLogistic Regression")
    score = modelLR.predict_proba(x)
    score = 1 - score[0][0]
    print("Malicious: {}".format(score))
    if score <= 0.3:
        print("Verdict: {}".format("Low"))
    elif score <= 0.6:
        print("Verdict: {}".format("Medium"))
    else:
        print("Verdict: {}".format("High"))
    print()

    print("----------------------------------------------------------")
    print("Random Forest")
    score = modelRF.predict_proba(x)
    score = 1 - score[0][0]
    print("Malicious: {}".format(score))
    if score <= 0.3:
        print("Verdict: {}".format("Low"))
    elif score <= 0.6:
        print("Verdict: {}".format("Medium"))
    else:
        print("Verdict: {}".format("High"))
    print()

    print("----------------------------------------------------------")
    print("SVM")
    score = modelSVM.predict_proba(x)
    score = 1 - score[0][0]
    print("Malicious: {}".format(score))
    if score <= 0.3:
        print("Verdict: {}".format("Low"))
    elif score <= 0.6:
        print("Verdict: {}".format("Medium"))
    else:
        print("Verdict: {}".format("High"))
    print()

    print("----------------------------------------------------------")
    print("AdaBoost")
    score = modelAda.predict_proba(x)
    score = 1 - score[0][0]
    print("Malicious: {}".format(score))
    if score <= 0.3:
        print("Verdict: {}".format("Low"))
    elif score <= 0.6:
        print("Verdict: {}".format("Medium"))
    else:
        print("Verdict: {}".format("High"))
    print()

    print("----------------------------------------------------------")
    print("Gradient Boosting")
    score = modelGB.predict_proba(x)
    score = 1 - score[0][0]
    print("Malicious: {}".format(score))
    if score <= 0.3:
        print("Verdict: {}".format("Low"))
    elif score <= 0.6:
        print("Verdict: {}".format("Medium"))
    else:
        print("Verdict: {}".format("High"))
    print()

    print("----------------------------------------------------------")
    print("XGBoost")
    score = modelXGB.predict_proba(x)
    score = 1 - score[0][0]
    print("Malicious: {}".format(score))
    if score <= 0.3:
        print("Verdict: {}".format("Low"))
    elif score <= 0.6:
        print("Verdict: {}".format("Medium"))
    else:
        print("Verdict: {}".format("High"))
    print()

    print("----------------------------------------------------------")
    print("Decision Tree")
    score = modelDT.predict_proba(x)
    score = 1 - score[0][0]
    print("Malicious: {}".format(score))
    if score <= 0.3:
        print("Verdict: {}".format("Low"))
    elif score <= 0.6:
        print("Verdict: {}".format("Medium"))
    else:
        print("Verdict: {}".format("High"))
    print()