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
e27e7922
Commit
e27e7922
authored
Oct 17, 2020
by
Haritha Chanuka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace IT17106702.py
parent
720c6e7b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
22 deletions
+3
-22
IT17106702.py
IT17106702.py
+3
-22
No files found.
IT17106702.py
View file @
e27e7922
...
@@ -9,26 +9,12 @@ dataset = pd.read_csv("/Users/harithachanuka/Documents/SLIIT/Research/Harry/Wanh
...
@@ -9,26 +9,12 @@ dataset = pd.read_csv("/Users/harithachanuka/Documents/SLIIT/Research/Harry/Wanh
X
=
dataset
.
iloc
[:,
[
1
,
3
]]
.
values
X
=
dataset
.
iloc
[:,
[
1
,
3
]]
.
values
y
=
dataset
.
iloc
[:,
5
]
.
values
y
=
dataset
.
iloc
[:,
5
]
.
values
# datasetnew = pd.read_csv("/Users/harithachanuka/Documents/SLIIT/Research/Implementation/new.csv", encoding='latin-1')
# Encoding categorical data-ForX
# Xnw = datasetnew.iloc[:, :5].values
#Encoding categorical data-ForX
from
sklearn.preprocessing
import
LabelEncoder
,
OneHotEncoder
from
sklearn.preprocessing
import
LabelEncoder
,
OneHotEncoder
from
sklearn.compose
import
ColumnTransformer
labelencoder_X_S
=
LabelEncoder
()
labelencoder_X_S
=
LabelEncoder
()
X
[:,
0
]
=
labelencoder_X_S
.
fit_transform
(
X
[:,
0
])
X
[:,
0
]
=
labelencoder_X_S
.
fit_transform
(
X
[:,
0
])
#labelencoder_X_D = LabelEncoder()
# X[:, 2] = labelencoder_X_D.fit_transform(X[:, 2])
labelencoder_X_P
=
LabelEncoder
()
labelencoder_X_P
=
LabelEncoder
()
X
[:,
1
]
=
labelencoder_X_P
.
fit_transform
(
X
[:,
1
])
X
[:,
1
]
=
labelencoder_X_P
.
fit_transform
(
X
[:,
1
])
# ct = ColumnTransformer([("Source", OneHotEncoder(), [1])], remainder = 'passthrough')
# X = ct.fit_transform(X).toarray()
# ct2 = ColumnTransformer([("Destination", OneHotEncoder(), [72])], remainder = 'passthrough')
# X = ct2.fit_transform(X)
# ct3 = ColumnTransformer([("Protocol", OneHotEncoder(), [118])], remainder = 'passthrough')
# X = ct3.fit_transform(X)
labelencoder_y
=
LabelEncoder
()
labelencoder_y
=
LabelEncoder
()
y
=
labelencoder_y
.
fit_transform
(
y
)
y
=
labelencoder_y
.
fit_transform
(
y
)
...
@@ -36,10 +22,7 @@ y = labelencoder_y.fit_transform(y)
...
@@ -36,10 +22,7 @@ y = labelencoder_y.fit_transform(y)
# Splitting the dataset into the Training set and Test set
# Splitting the dataset into the Training set and Test set
from
sklearn.model_selection
import
train_test_split
from
sklearn.model_selection
import
train_test_split
X_train
,
X_test
,
y_train
,
y_test
=
train_test_split
(
X
,
y
,
test_size
=
0.25
,
random_state
=
0
)
X_train
,
X_test
,
y_train
,
y_test
=
train_test_split
(
X
,
y
,
test_size
=
0.25
,
random_state
=
0
)
# print(X_train)
# print(X_test)
# print(y_train)
# print(X_train)
# Feature Scaling
# Feature Scaling
from
sklearn.preprocessing
import
StandardScaler
from
sklearn.preprocessing
import
StandardScaler
...
@@ -55,8 +38,6 @@ classifier.fit(X_train, y_train)
...
@@ -55,8 +38,6 @@ classifier.fit(X_train, y_train)
# Predicting the Test set results
# Predicting the Test set results
y_pred
=
classifier
.
predict
(
X_test
)
y_pred
=
classifier
.
predict
(
X_test
)
# Create confusion metrics to check the performance of algorithm
from
sklearn.metrics
import
confusion_matrix
from
sklearn.metrics
import
confusion_matrix
cm
=
confusion_matrix
(
y_test
,
y_pred
)
cm
=
confusion_matrix
(
y_test
,
y_pred
)
#
\ 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