Skip to content

Instantly share code, notes, and snippets.

with table_stats as (
select psut.relname,
psut.n_live_tup,
1.0 * psut.idx_scan / greatest(1, psut.seq_scan + psut.idx_scan) as index_use_ratio
from pg_stat_user_tables psut
order by psut.n_live_tup desc
),
table_io as (
select psiut.relname,
sum(psiut.heap_blks_read) as table_page_read,
@marr75
marr75 / map.geojson
Last active December 5, 2016 19:58
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@marr75
marr75 / finished-digital-clock-in-javascript.markdown
Created January 16, 2021 16:51
Finished: Digital Clock In JavaScript
@marr75
marr75 / vectorized_f1_calc.py
Created January 6, 2023 15:54
Quick vectorized approach to calculating metrics at every potential breakpoint for a classification problem. Nice way to visualize precision, recall, and f1 in continuous graphs if you're introducing unsupervised machine learning or talking about very shallow decision trees.
def evaluate_threshold_binary_classification(x: pandas.Series, y: pandas.Series, reverse=False):
""" Calculate quality metrics such as True Positive, True Negative, False Positive, False Negative, Precision, Recall, and F1
for all possible thresholds of a metric x being used to predict a classification against a binary class, y.
x: the independent variable we will use as a predictor, a continuos variable
y: the dependent variable representing the class we are predicting, 0/1 or bool
reverse: whether the x and y series have an inverse relationship
"""
predictor = pd.DataFrame(
{
'discriminant': x * (1 and reverse or -1),