This file contains 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
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, |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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), |