Skip to content

Instantly share code, notes, and snippets.

View KenoLeon's full-sized avatar

Keno Leon KenoLeon

View GitHub Profile
@KenoLeon
KenoLeon / App.vue
Last active June 18, 2020 01:23
Cascading vue props
<!-- FILE: App.vue -->
<!-- NOTE: Import bootstrap on main.js -->
<template>
<div id="app">
<bootsCard v-bind="{ cardT : cardTitle, alertD:alertData }"/>
</div>
</template>
<script>
@KenoLeon
KenoLeon / simpleTone.py
Created July 7, 2020 01:13
Simple Tone for Medium Article
# Notes:
# You need to install winsound:
# > pip install winsound
# Only works with windows,
# for an alternative see following gist.
import winsound
# HZ and milliseconds
winsound.Beep(200, 1000)
@KenoLeon
KenoLeon / simpleTone_crossplatform.py
Created July 7, 2020 01:21
simple Tone cross platform for Medium article.
# Notes:
# Import and install numpy and simpleaudio
# Volume is louder than winsound
import numpy as np
import simpleaudio as sa
def sound(freq,sec):
frequency = freq
fs = 44100 #samples per second
@KenoLeon
KenoLeon / 40HzTo20480HzSineWaveSweep.py
Created July 7, 2020 01:34
40Hz To 20480Hz SineWave Sweep
import winsound
# HZ and milliseconds
winsound.Beep(40, 1000)
winsound.Beep(80, 1000)
winsound.Beep(160, 1000)
winsound.Beep(320, 1000)
winsound.Beep(640, 1000)
winsound.Beep(1280, 1000)
winsound.Beep(2560, 1000)
@KenoLeon
KenoLeon / toneScaleSweep.py
Last active July 7, 2020 01:46
Musical Scale sine tones
import winsound
# HZ and milliseconds
winsound.Beep(262, 600) # C4
winsound.Beep(294, 600) # D4
winsound.Beep(330, 600) # E4
winsound.Beep(349, 600) # F4
winsound.Beep(392, 600) # G4
winsound.Beep(440, 600) # A4
winsound.Beep(494, 600) # B4
winsound.Beep(523, 600) # C3
@KenoLeon
KenoLeon / NMRKerasLoadDataset.py
Last active July 17, 2020 19:51
Load Numerai dataset.
import pandas as pd
# CONSTANTS:
ROUND = '220'
TOURNAMENT_NAME = "kazutsugi"
TARGET_NAME = f"target_{TOURNAMENT_NAME}"
PREDICTION_NAME = f"prediction_{TOURNAMENT_NAME}"
# LOAD DATASETS:
@KenoLeon
KenoLeon / buildModelKeras.py
Last active July 17, 2020 20:48
Build keras model
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
def build_model(learning_rate, layer_size):
"""Build Keras model"""
model = keras.Sequential([
layers.Dense(layer_size, activation='relu',
input_shape=[len(feature_names)]),
layers.Dense(layer_size, activation='relu', kernel_regularizer='l2'),
@KenoLeon
KenoLeon / trainNNKeras.py
Created July 18, 2020 00:44
Train NN Keras
def train_model(model, feature, label, epochs, batch_size):
"""Train Keras Model"""
history = model.fit(x=feature,
y=label,
batch_size=batch_size,
epochs=epochs)
epochs = history.epoch
hist = pd.DataFrame(history.history)
mse = hist["mse"]
@KenoLeon
KenoLeon / validation.py
Last active January 28, 2023 00:46
Keras training validation.
from matplotlib import pyplot as plt
def plot_the_loss_curve(epochs, mse):
"""Plot a curve of loss vs. epoch."""
plt.figure()
plt.xlabel("Epoch")
plt.ylabel("Mean Squared Error")
plt.plot(epochs, mse, label="Loss")
@KenoLeon
KenoLeon / predict.py
Last active July 18, 2020 18:06
Make predictions Keras
tournament_data[PREDICTION_NAME] = regressor_model.predict(tournament_data[feature_names])
df = tournament_data[PREDICTION_NAME]
df.columns = ["id", "prediction_kazutsugi"]
df.to_csv("Numerai/" + TOURNAMENT_NAME + "_submission_YourSubmissionName.csv", header=True)
print(df)