I have two models which are binary classifiers:
benign_DDoS_balanced.h5 and benign_DoS_balanced.h5
One for DoS attack label:
model = tf.keras.models.Sequential([
tf.keras.layers.Dense(units=64, activation='relu', input_shape=(56,)),
tf.keras.layers.Dense(units=128, activation='relu'),
tf.keras.layers.Dense(units=256, activation='relu'),
tf.keras.layers.Dense(units=1, activation='sigmoid')
])
and another one for DDoS attack label:
model = tf.keras.models.Sequential([
tf.keras.layers.Dense(units=64, activation='relu', input_shape=(56,)),
tf.keras.layers.Dense(units=128, activation='relu'),
tf.keras.layers.Dense(units=256, activation='relu'),
tf.keras.layers.Dense(units=1, activation='sigmoid')
])
the accuracy and overall metrics of these models at detecting DoS and DDoS are perfect. I want to unify these two models, and make a single model that can do the job of a multi-class classifier. Because I have not worked with ensemble methods before, I have no idea how to do this. but I have done research and I have seen libraries like Brew and other libraries as well. anyone could help?? (I need complete tutorial)
Thank you all!!
I used the Brew library, and tried this code:
# import the brew package
```
from brew.base import Ensemble
from brew.base import EnsembleClassifier
from brew.combination.combiner import Combiner
from tensorflow.keras.models import load_model
mlp1 = load_model('benign_DDoS_balanced.h5')
mlp2 = load_model('benign_DoS_balanced.h5')
```
# create Ensemble model
```
clfs = [mlp1, mlp2] # your list of MLP classifiers
ens = Ensemble(classifiers = clfs)
```
# create Combiner
# I don't know which rule could be the best : 'majority_vote', 'max', 'min', 'mean' or 'median'
```
comb = Combiner(rule='mean')
```
# create EnsembleClassifier
```
ensemble_clf = EnsembleClassifier(ensemble=ens, combiner=comb)
```
# fit and predict as usual
```
ensemble_clf.fit(X_train_standardized, Y_trains)
```
52868/52868 [==============================] - 119s 2ms/step - loss: 0.0304 - accuracy: 0.9903
18951/52868 [=========>....................] - ETA: 1:13 - loss: 0.0407 - accuracy: 0.9881
# Predict on X_test
```
y_pred = ensemble_clf.predict(X_test_standardized)
I get error right here:
AttributeError: 'Sequential' object has no attribute 'classes_'