import datetime

from sklearn.preprocessing import StandardScaler
from sklearn import svm
from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from sklearn import svm
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
from yellowbrick.classifier import ClassificationReport
from collections import Counter
from datetime import time


start = datetime.datetime.now()
csv_data = pd.read_csv(r"../Files/opcodes624_fcns98-malicious.csv", header=None)
metrix = csv_data.values
# print(metrix.shape)
# scaler = MinMaxScaler()
# y = metrix[:, 8]
# print(Counter(y))
# print(y.shape)
# X = np.delete(metrix, 8, axis=1)
# print(metrix.shape, X.shape)
# X_scaled = scaler.fit_transform(X)
# print(X_scaled)
# print(np.max(X_scaled))
# print(np.where(np.isnan(X_scaled)))

'''
opcodes624_fcns98_malicious
'''
hashcodes_list = metrix[:, -1]
y = metrix[:, -2]
y = y.astype("int")
print(Counter(y))
y_resinged = []
for i in y:
    if i == 1:
        y_resinged.append("android")
    else:
        y_resinged.append("linux")
print(y)
X = np.delete(metrix, np.s_[-2, -1], axis=1)

clf = svm.SVC()
x_train, x_test, y_train, y_test = train_test_split(X, y_resinged, test_size=0.3)
clf.fit(x_train, y_train)
label_predict = clf.predict(x_test)
report = classification_report(y_test, label_predict)
print(clf.classes_)
classes = clf.classes_
print(report)
visualizer = ClassificationReport(clf, classes = classes, support=True)
visualizer.fit(x_train, y_train)
visualizer.score(x_test, y_test)
g = visualizer.poof()
print(datetime.datetime.now() - start)
import datetime

from sklearn.preprocessing import StandardScaler
from sklearn import svm
from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from sklearn import svm
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
from yellowbrick.classifier import ClassificationReport
from collections import Counter
from datetime import time


start = datetime.datetime.now()
csv_data = pd.read_csv(r"../Files/opcodes624_fcns98-malicious.csv", header=None)
metrix = csv_data.values
# print(metrix.shape)
# scaler = MinMaxScaler()
# y = metrix[:, 8]
# print(Counter(y))
# print(y.shape)
# X = np.delete(metrix, 8, axis=1)
# print(metrix.shape, X.shape)
# X_scaled = scaler.fit_transform(X)
# print(X_scaled)
# print(np.max(X_scaled))
# print(np.where(np.isnan(X_scaled)))

'''
opcodes624_fcns98_malicious
'''
hashcodes_list = metrix[:, -1]
y = metrix[:, -2]
y = y.astype("int")
print(Counter(y))
y_resinged = []
for i in y:
    if i == 1:
        y_resinged.append("android")
    else:
        y_resinged.append("linux")
print(y)
X = np.delete(metrix, np.s_[-2, -1], axis=1)

clf = svm.SVC()
x_train, x_test, y_train, y_test = train_test_split(X, y_resinged, test_size=0.3)
clf.fit(x_train, y_train)
label_predict = clf.predict(x_test)
report = classification_report(y_test, label_predict)
print(clf.classes_)
classes = clf.classes_
print(report)
visualizer = ClassificationReport(clf, classes = classes, support=True)
visualizer.fit(x_train, y_train)
visualizer.score(x_test, y_test)
g = visualizer.poof()
print(datetime.datetime.now() - start)
# print(metrix.shape) # scaler = MinMaxScaler() # y = metrix[:, 8] # print(Counter(y)) # print(y.shape) # X = np.delete(metrix, 8, axis=1) # print(metrix.shape, X.shape) # X_scaled = scaler.fit_transform(X) # print(X_scaled) # print(np.max(X_scaled)) # print(np.where(np.isnan(X_scaled))) opcodes624_fcns98_malicious