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 / 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
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
# 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)))
@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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
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:
!pip install mnist
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn import metrics
import mnist
# from hmmlearn.hmm import GaussianHMM, MultinomialHMM
X_train = mnist.train_images()
@alik604
alik604 / build_dataset LSTM.py
Created July 28, 2020 01:17
build_dataset LSTM.py
# 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)
@alik604
alik604 / Fourier_Extrapolation.py
Last active August 24, 2020 23:41 — forked from tartakynov/fourex.py
Fourier Extrapolation in Python
import numpy as np
import pylab as pl
from numpy import fft
def fourierExtrapolation(x, n_predict):
n = x.size
n_harm = 10 # number of harmonics in model
t = np.arange(0, n)
p = np.polyfit(t, x, 1) # find linear trend in x