Skip to content

Instantly share code, notes, and snippets.

View alik604's full-sized avatar
👨‍🎓
Full time student

K. Ali Pardhan alik604

👨‍🎓
Full time student
View GitHub Profile
@alik604
alik604 / boilerplate.py
Last active July 1, 2020 00:34
boiler plate for jupyter notebook on Data Science or Machine Learning
%%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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alik604
alik604 / OpenCV_Image_Augmentation.py
Created June 4, 2020 16:25
Image augmentation by mirroring, random rotation, shifts, shear and flips, etc.
# @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
# 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)))
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
@alik604
alik604 / EEGNet.py
Last active December 25, 2019 21:44
EEGNet in Keras
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
# 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