This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tensorflow import keras | |
from tensorflow.python.lib.io import file_io | |
class ModelCheckpointInGcs(keras.callbacks.ModelCheckpoint): | |
def __init__( | |
self, | |
filepath, | |
gcs_dir: str, | |
monitor="val_loss", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- see https://docs.aws.amazon.com/redshift/latest/dg/r_PG_TABLE_DEF.html | |
select "column", type, encoding, distkey, sortkey | |
from pg_table_def where schemaname='public' and tablename='mytable' and sortkey!=0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
feature_important = clf.get_booster().get_score(importance_type="weight") | |
keys = list(feature_important.keys()) | |
values = list(feature_important.values()) | |
data = pd.DataFrame(data=values, index=keys, columns=["score"]).sort_values(by = "score", ascending=False) | |
# Top 10 features | |
data.head(20) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def recall(y_true, y_pred): | |
y_true = K.ones_like(y_true) | |
true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1))) | |
all_positives = K.sum(K.round(K.clip(y_true, 0, 1))) | |
recall = true_positives / (all_positives + K.epsilon()) | |
return recall | |
def precision(y_true, y_pred): | |
y_true = K.ones_like(y_true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import numpy as np | |
from matplotlib import pyplot as plt | |
import IPython.display as ipd | |
import librosa | |
import pandas as pd | |
%matplotlib inline | |
def print_plot_play(x, Fs, text=''): | |
"""1. Prints information about an audio singal, 2. plots the waveform, and 3. Creates player |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import numpy as np | |
from matplotlib import pyplot as plt | |
import IPython.display as ipd | |
import librosa | |
import pandas as pd | |
%matplotlib inline | |
def print_plot_play(x, Fs, text=''): | |
"""1. Prints information about an audio singal, 2. plots the waveform, and 3. Creates player |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
definitions: | |
steps: | |
- step: &tests | |
image: python:3.7.9 | |
script: | |
- pip install ."[tests]" | |
- mypy src | |
- pytest -vv --cov=src | |
caches: | |
- pip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE PROCEDURE sp_update_ddl() | |
AS $$ | |
BEGIN | |
alter table myschema.mytable add column newcolumn bigint; | |
EXCEPTION | |
WHEN OTHERS THEN | |
raise 'exception in filename.sql'; | |
END | |
$$ LANGUAGE plpgsql | |
; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws s3 ls --summarize --human-readable --recursive s3://mybucket/mydir/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model.call = tf.function(model.call, experimental_relax_shapes=True) | |
for (test_df, pred_df) in tqdm(env.iter_test()): | |
pred = model(data, training = False).numpy() |