Skip to content

Instantly share code, notes, and snippets.

View algonacci's full-sized avatar
🎯
Very Active in GitHub

Eric Julianto algonacci

🎯
Very Active in GitHub
View GitHub Profile
@algonacci
algonacci / Rename_File.ipynb
Created June 23, 2022 13:56
A python command line to rename files in a folder
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@algonacci
algonacci / callback.py
Created June 14, 2022 10:40
A script to make a callback on training
class myCallback(tf.keras.callbacks.Callback):
def on_epoch_end(self, epoch, logs={}):
if logs.get('accuracy') is not None and logs.get('val_accuracy') > 0.85:
print("\nReached 85% validation accuracy so cancelling training!")
self.model.stop_training = True
callback = myCallback()
@algonacci
algonacci / horizontal_evaluation.py
Created June 1, 2022 16:48
A script to plot the training result
# Plot the training and validation accuracies for each epoch
acc = history.history['accuracy']
val_acc = history.history['val_accuracy']
loss = history.history['loss']
val_loss = history.history['val_loss']
epochs = range(len(acc))
fig = plt.figure(figsize = (15,5))
@algonacci
algonacci / plot_history.py
Created April 15, 2022 17:07
The easiest way to plot the model history metrics
import pandas as pd
evaluation = pd.DataFrame(model.history.history)
evaluation[['accuracy', 'val_accuracy']].plot()
evaluation[['loss', 'val_loss']].plot()
@algonacci
algonacci / ResponseFormatter.php
Created April 10, 2022 08:30
A response formatter helpers to keep making consistent response from API following the JSON-API standard
<?php
namespace App\Http\Controllers\API;
class ResponseFormatter
{
protected static $response = [
'meta' => [
'code' => 200,
'status' => 'success',
@algonacci
algonacci / matplotlib_dark_mode.py
Created April 10, 2022 08:24
A command to setup dark theme on Matplotlib visualization
import matplotlib.pyplot as plt
plt.rcParams.update({
"lines.color": "white",
"patch.edgecolor": "white",
"text.color": "white",
"axes.facecolor": "black",
"axes.edgecolor": "white",
"axes.labelcolor": "white",
"xtick.color": "white",
@algonacci
algonacci / dark_theme.ipynb
Last active April 10, 2022 08:16
A command to apply dark mode in Jupyter Notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@algonacci
algonacci / plot_graph.py
Created April 10, 2022 05:53
A function to generate accuracy & loss visualization with Matplotlib
import matplotlib.pyplot as plt
# Plot utility
def plot_graphs(history, string):
plt.plot(history.history[string])
plt.plot(history.history['val_'+string])
plt.xlabel("Epochs")
plt.ylabel(string)
plt.legend([string, 'val_'+string])
plt.show()