import pandas as pd
from sklearn import preprocessing
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import classification_report, confusion_matrix

names = ['a','b','c','d','e','f','g','h','i','j','k','l']
dataset_dos = pd.read_csv('DoS_dataset.csv', names=names)
dataset_gear = pd.read_csv('gear_dataset.csv', header=None, names=names)
dataset_rpm = pd.read_csv('RPM_dataset.csv', header=None, names=names)

dataset = pd.concat([dataset_dos, dataset_gear, dataset_rpm])
dataset = dataset.reset_index(drop=True)

dataset['b'] = dataset['b'].apply(int, base=16)
dataset['d'] = dataset['d'].apply(int, base=16)
dataset['e'] = dataset['e'].apply(int, base=16)
dataset['f'] = dataset['f'].apply(int, base=16)
dataset['g'] = dataset['g'].apply(int, base=16)
dataset['h'] = dataset['h'].apply(int, base=16)
dataset['i'] = dataset['i'].apply(int, base=16)
dataset['j'] = dataset['j'].apply(int, base=16)
dataset['k'] = dataset['k'].apply(int, base=16)
        
X = dataset.iloc[:, 0:11]

y = dataset.select_dtypes(include=[object])

le = preprocessing.LabelEncoder()
y = y.apply(le.fit_transform)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.40)

scaler = StandardScaler()
scaler.fit(X_train)

X_train = scaler.transform(X_train)
X_test = scaler.transform(X_test)

mlp = MLPClassifier(hidden_layer_sizes=(15, 15, 15), max_iter=1000)
mlp.fit(X_train, y_train.values.ravel())

predictions = mlp.predict(X_test)

print(confusion_matrix(y_test,predictions))
print(classification_report(y_test,predictions))