import numpy as np
import modin.pandas as pd
import pandas as pdo
import matplotlib.pyplot as plt
import time
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
from sklearn.model_selection import train_test_split,cross_val_score
from sklearn.metrics import accuracy_score,confusion_matrix,roc_auc_score,mean_squared_error,roc_curve
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

start = time.time()
train_df = pd.read_csv('ModelTrain.csv')
test_df = pd.read_csv('ModelTestFinal.csv')
print('Data loaded in '+str(round(time.time()-start,2))+' seconds.\n')

TrainColumnNames = list(train_df.columns.values)
print(TrainColumnNames)
print(len(TrainColumnNames))

TrainColumnNames = list(test_df.columns.values)
print(TrainColumnNames)
print(len(TrainColumnNames))

X = train_df.drop('HasDetections',axis=1)
#X = X.iloc[:].values
Y = train_df['HasDetections']
#.values
print("Created X and Y")

#X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.25, random_state = 0)
print("Test and Train Split")

start = time.time()
from sklearn.svm import LinearSVC
from sklearn.feature_selection import SelectFromModel
lsvc = LinearSVC(C=0.5, penalty="l1", dual=False).fit(X, Y)
model = SelectFromModel(lsvc, prefit=True)
X_new = model.transform(X)

TrainColumnNames = list(X_new.columns.values)
print(TrainColumnNames)
print(len(TrainColumnNames))
print(str(round(time.time()-start,2))+' seconds.\n')