This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load data and set labels. details admitted | |
train = pd.read_csv('https://raw.githubusercontent.com/defcom17/NSL_KDD/master/KDDTrain%2B.csv') | |
test = pd.read_csv('https://raw.githubusercontent.com/defcom17/NSL_KDD/master/KDDTest%2B.csv') | |
train.columns , test.columns = labels , labels | |
combined_data = pd.concat([train, test]).drop('difficulty_level', 1) | |
le = LabelEncoder() | |
vector = combined_data['attack_type'] | |
print("Attack Vectors:", set(list(vector))) # use print to make it print on single line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def EEGNet(nb_classes, Chans = 64, Samples = 128, | |
dropoutRate = 0.5, kernLength = 64, F1 = 8, | |
D = 2, F2 = 16, norm_rate = 0.25, dropoutType = 'Dropout'): | |
""" Keras Implementation of EEGNet | |
http://iopscience.iop.org/article/10.1088/1741-2552/aace8c/meta | |
Inputs: | |
nb_classes : int, number of classes to classify | |
Chans, Samples : number of channels and time points in the EEG data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pylab as plt | |
import numpy as np | |
import matplotlib | |
import matplotlib.pyplot as plt | |
import keras | |
from keras.models import Sequential, Model | |
from keras.layers import Dense | |
from keras.optimizers import Adam |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/alik604/Notebooks/blob/master/Data%20Science-Datasets/MNIST/Where_to_add_GaussianNoise_MNIST_.ipynb | |
# data - MNIST | |
# note - test_size=0.98... ya... | |
model = Sequential() | |
model.add(Conv2D(filters=100, kernel_size=3)) # remove relu | |
# model.add(GaussianNoise(0.5)) # sandwich between | |
# GaussianNoise(0.5) here - accuracy: 0.9829 - val_loss: 0.4050 - val_accuracy: 0.9024 | |
model.add(Activation('relu')) # add relu | |
# GaussianNoise(0.5) here - accuracy: 0.9900 - val_loss: 1.4703 - val_accuracy: 0.8073 | |
model.add(MaxPooling2D(pool_size=(2, 2))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @credit - kaggle.com/hanzh0420/image-augmentation-with-opencv | |
import os | |
print(os.listdir("../input")) | |
# Input data files are available in the "../input/" directory. | |
# Any results you write to the current directory are saved as output. | |
import numpy as np | |
#import pandas as pd # pd.read_csv | |
import cv2 | |
import random |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%capture | |
!pip install scikit-plot | |
!pip install catboost | |
!pip install mlxtend | |
!pip install yfinance | |
!pip install pyod | |
import pyod | |
import yfinance | |
import xgboost # xgboost.readthedocs.io/en/latest/python/python_api.html#xgboost.XGBClassifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# imports from matplotlib import pyplot as plt | |
from matplotlib import pyplot as plt | |
import pylab | |
from mpl_toolkits.mplot3d import Axes3D | |
from mpl_toolkits.mplot3d import proj3d | |
%matplotlib inline | |
%pylab inline | |
from sklearn.manifold import TSNE | |
from sklear.decomposition import PCA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make dataset to input | |
def build_dataset(time_series, seq_length): | |
dataX = [] | |
dataY = [] | |
for i in range(0, len(time_series) - seq_length): | |
_x = time_series[i:i + seq_length, :] | |
_y = time_series[i + seq_length, [-1]] # Next close price | |
print(_x, "->", _y) | |
dataX.append(_x) | |
dataY.append(_y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.parse as parse | |
url = "" | |
if 'url' not in globals(): | |
print("Enter URL to parse") | |
url = input() | |
def printDict(data): | |
for x in data: |
OlderNewer