Commit 5f1b9216 authored by Haritha Chanuka's avatar Haritha Chanuka

Delete IT17106702.py

parent f9294e95
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.impute import SimpleImputer
# Importing the dataset
dataset = pd.read_csv("/Users/harithachanuka/Documents/SLIIT/Research/Harry/Wanheda_Server/MobileBotNet/packet_data.csv", encoding='latin-1')
X = dataset.iloc[:, [1,3]].values
y = dataset.iloc[:, 5].values
# Encoding categorical data-ForX
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder_X_S = LabelEncoder()
X[:, 0] = labelencoder_X_S.fit_transform(X[:, 0])
labelencoder_X_P = LabelEncoder()
X[:, 1] = labelencoder_X_P.fit_transform(X[:, 1])
labelencoder_y = LabelEncoder()
y = labelencoder_y.fit_transform(y)
# Splitting 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.25, 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)
# Fitting classifier to the Training set
from sklearn.naive_bayes import GaussianNB
classifier = GaussianNB()
classifier.fit(X_train, y_train)
# Predicting the Test set results
y_pred = classifier.predict(X_test)
# Create confusion metrics to check the performance of algorithm
from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_test, y_pred)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment