Skip to content

Instantly share code, notes, and snippets.

View notha99y's full-sized avatar
:octocat:
loading...

Ren Jie notha99y

:octocat:
loading...
View GitHub Profile
# Target Variable: Survival
c_palette = ['tab:blue', 'tab:orange']
categorical_summarized(train_df, y = 'Survived', palette=c_palette)
def categorical_summarized(dataframe, x=None, y=None, hue=None, palette='Set1', verbose=True):
'''
Helper function that gives a quick summary of a given column of categorical data
Arguments
=========
dataframe: pandas dataframe
x: str. horizontal axis to plot the labels of categorical data, y would be the count
y: str. vertical axis to plot the labels of categorical data, x would be the count
hue: str. if you want to compare it another variable (usually the target variable)
# Importing the Callbacks
from keras.callbacks import EarlyStopping
from keras.callbacks import TensorBoard
from keras.callbacks import ModelCheckpoint
# Saving logs
LOG_DIR = os.path.join(os.getcwd(), 'logs')
tb = TensorBoard(LOG_DIR)
# Saving weights
weights_dir = 'weights/' + model.name + \
'-{epoch:02d}-{loss:.2f}.hdf5'
def simple_LSTM():
np.random.seed(7)
model = Sequential(name = 'simple_LSTM')
model.add(LSTM(512, input_shape=(None, 6), recurrent_dropout=0.5))
model.add(Dense(len(activities), activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer=Adam(lr=1e-4), metrics=['accuracy'])
print(model.summary())
return model