Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020-092
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2020 - 092
2020-092
Commits
77bd15df
Commit
77bd15df
authored
Oct 19, 2020
by
Navindu Eshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slowloris attack python model
parent
dda254f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
117 additions
and
0 deletions
+117
-0
WANHEDA Server/Slowloris Attack/slowlorisModel.py
WANHEDA Server/Slowloris Attack/slowlorisModel.py
+117
-0
No files found.
WANHEDA Server/Slowloris Attack/slowlorisModel.py
0 → 100644
View file @
77bd15df
# -*- coding: utf-8 -*-
"""Navindu.ipynb"""
# Importing the libraries
# Fundamental package for scientific computing
import
numpy
as
np
# Plotting library
import
matplotlib.pyplot
as
plt
# Data manipulation and analysis library
import
pandas
as
pd
# Completing missing values
from
sklearn.impute
import
SimpleImputer
# Encode target labels with value between 0 and n_classes-1
from
sklearn.preprocessing
import
LabelEncoder
,
OneHotEncoder
# Applies transformers to columns of an array or pandas DataFrame
from
sklearn.compose
import
ColumnTransformer
# Split arrays or matrices into random train and test subsets
from
sklearn.model_selection
import
train_test_split
# Standardize features by removing the mean and scaling to unit variance
from
sklearn.preprocessing
import
StandardScaler
# Logistic Regression classifier
from
sklearn.linear_model
import
LogisticRegression
# Compute confusion matrix to evaluate the accuracy of a classification
from
sklearn.metrics
import
confusion_matrix
# Accuracy classification score
from
sklearn.metrics
import
accuracy_score
# Build a text report showing the main classification metrics
from
sklearn.metrics
import
classification_report
# Data visualization library based on matplotlib
import
seaborn
as
sns
# Importing the dataset
dataset
=
pd
.
read_csv
(
'/Users/harithachanuka/Documents/SLIIT/Research/Harry/Wanheda_Server/Slowloris/SlowlorisDATASET.numbers'
)
# Read in data and display first 5 rows
dataset
.
head
()
# Drop the dataset
dataset
=
dataset
.
dropna
()
#Data cleaning
dataset
.
isnull
()
.
sum
()
#Encoding categarical data
from
sklearn.preprocessing
import
LabelEncoder
,
OneHotEncoder
labelencoder_Y
=
LabelEncoder
()
dataset
.
iloc
[:,
78
]
=
labelencoder_Y
.
fit_transform
(
dataset
.
iloc
[:,
78
])
dataset
.
shape
dataset
=
dataset
[
~
dataset
.
isin
([
np
.
isnan
])
.
any
(
1
)]
.
astype
(
np
.
float64
)
dataset
=
dataset
[
~
dataset
.
isin
([
np
.
isinf
])
.
any
(
1
)]
.
astype
(
np
.
float64
)
dataset
=
dataset
.
mask
(
np
.
isinf
(
dataset
))
dataset
=
dataset
.
dropna
()
dataset
.
shape
#returns a boolean array of the X
np
.
any
(
np
.
isinf
(
dataset
))
#detect numpy arrays of different data types
np
.
any
(
np
.
isnan
(
dataset
))
#get all colomns without last colomn in X axis and get last colomn in y axis
X
=
dataset
.
iloc
[:,
:
-
1
]
.
values
y
=
dataset
.
iloc
[:,
78
]
.
values
dataset
.
info
()
y
df
=
pd
.
DataFrame
(
data
=
X
)
df
#Spliting the dataset into the training set and test set
from
sklearn.model_selection
import
train_test_split
X_train
,
X_test
,
y_train
,
y_test
=
train_test_split
(
X
,
y
,
test_size
=
0.2
,
random_state
=
0
)
#feature scaling
from
sklearn.preprocessing
import
StandardScaler
sc_X
=
StandardScaler
()
X_train
=
sc_X
.
fit_transform
(
X_train
)
X_test
=
sc_X
.
transform
(
X_test
)
y_train
.
shape
#fitting simple linear regression to the training set
from
sklearn.linear_model
import
LinearRegression
regressor
=
LinearRegression
()
regressor
.
fit
(
X_train
,
y_train
)
#predecting the data
y_pred
=
regressor
.
predict
(
X_test
)
print
(
y_pred
)
X_train
.
shape
y_train
.
shape
#visual plot
plt
.
scatter
(
X_train
,
y_train
,
color
=
'red'
)
plt
.
plot
(
X_train
,
y_train
,
color
=
'red'
)
plt
.
plot
(
X_test
,
y_pred
,
color
=
'blue'
)
plt
.
title
(
'Slowloris Attack'
)
plt
.
xlabel
(
'Flow Duration'
)
plt
.
ylabel
(
'Total Length'
)
plt
.
show
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment