Binary metrics
avg_precision(true_val, pred_val)
¶
Compute the average precision between the PRS predictions and a binary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val |
The response value or phenotype (a binary numpy vector with 0s and 1s) |
required | |
pred_val |
The predicted value or PRS (a numpy vector) |
required |
Source code in viprs/eval/binary_metrics.py
cox_snell_r2(true_val, pred_val, covariates=None)
¶
Compute the Cox-Snell pseudo-R^2 between the PRS predictions and a binary phenotype. If covariates are provided, we compute the incremental pseudo-R^2 by conditioning on the covariates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val |
The response value or phenotype (a binary numpy vector with 0s and 1s) |
required | |
pred_val |
The predicted value or PRS (a numpy vector) |
required | |
covariates |
A pandas table of covariates where the rows are ordered the same way as the predictions and response. |
None
|
Source code in viprs/eval/binary_metrics.py
f1(true_val, pred_val)
¶
Compute the F1 score between the PRS predictions and a binary phenotype.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val |
The response value or phenotype (a binary numpy vector with 0s and 1s) |
required | |
pred_val |
The predicted value or PRS (a numpy vector) |
required |
Source code in viprs/eval/binary_metrics.py
liability_logit_r2(true_val, pred_val, covariates=None, return_all_r2=False)
¶
Compute the R^2 between the PRS predictions and a binary phenotype on the liability scale using the logit likelihood as outlined in Lee et al. (2012) Gene. Epi. https://pubmed.ncbi.nlm.nih.gov/22714935/
The R^2 is defined as: R2_{logit} = Var(pred) / (Var(pred) + pi^2 / 3)
Where Var(pred) is the variance of the predicted liability.
If covariates are provided, we compute the incremental pseudo-R^2 by conditioning on the covariates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val |
The response value or phenotype (a binary numpy vector with 0s and 1s) |
required | |
pred_val |
The predicted value or PRS (a numpy vector) |
required | |
covariates |
A pandas table of covariates where the rows are ordered the same way as the predictions and response. |
None
|
|
return_all_r2 |
If True, return the null, full and incremental R2 values. |
False
|
Source code in viprs/eval/binary_metrics.py
liability_probit_r2(true_val, pred_val, covariates=None, return_all_r2=False)
¶
Compute the R^2 between the PRS predictions and a binary phenotype on the liability scale using the probit likelihood as outlined in Lee et al. (2012) Gene. Epi. https://pubmed.ncbi.nlm.nih.gov/22714935/
The R^2 is defined as: R2_{probit} = Var(pred) / (Var(pred) + 1)
Where Var(pred) is the variance of the predicted liability.
If covariates are provided, we compute the incremental pseudo-R^2 by conditioning on the covariates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val |
The response value or phenotype (a binary numpy vector with 0s and 1s) |
required | |
pred_val |
The predicted value or PRS (a numpy vector) |
required | |
covariates |
A pandas table of covariates where the rows are ordered the same way as the predictions and response. |
None
|
|
return_all_r2 |
If True, return the null, full and incremental R2 values. |
False
|
Source code in viprs/eval/binary_metrics.py
liability_r2(true_val, pred_val, covariates=None, return_all_r2=False)
¶
Compute the coefficient of determination (R^2) on the liability scale according to Lee et al. (2012) Gene. Epi. https://pubmed.ncbi.nlm.nih.gov/22714935/
The R^2 liability is defined as: R_{liability}^2 = R2_{observed}K(K-1)/(z^2)
where R_{observed}^2 is the R^2 on the observed scale and K is the sample prevalence and z is the "height of the normal density at the quantile for K".
If covariates are provided, we compute the incremental pseudo-R^2 by conditioning on the covariates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val |
The response value or phenotype (a binary numpy vector with 0s and 1s) |
required | |
pred_val |
The predicted value or PRS (a numpy vector) |
required | |
covariates |
A pandas table of covariates where the rows are ordered the same way as the predictions and response. |
None
|
|
return_all_r2 |
If True, return the null, full and incremental R2 values. |
False
|
Source code in viprs/eval/binary_metrics.py
mcfadden_r2(true_val, pred_val, covariates=None)
¶
Compute the McFadden pseudo-R^2 between the PRS predictions and a phenotype. If covariates are provided, we compute the incremental pseudo-R^2 by conditioning on the covariates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val |
The response value or phenotype (a binary numpy vector with 0s and 1s) |
required | |
pred_val |
The predicted value or PRS (a numpy vector) |
required | |
covariates |
A pandas table of covariates where the rows are ordered the same way as the predictions and response. |
None
|
Source code in viprs/eval/binary_metrics.py
nagelkerke_r2(true_val, pred_val, covariates=None)
¶
Compute the Nagelkerke pseudo-R^2 between the PRS predictions and a binary phenotype. If covariates are provided, we compute the incremental pseudo-R^2 by conditioning on the covariates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val |
The response value or phenotype (a binary numpy vector with 0s and 1s) |
required | |
pred_val |
The predicted value or PRS (a numpy vector) |
required | |
covariates |
A pandas table of covariates where the rows are ordered the same way as the predictions and response. |
None
|
Source code in viprs/eval/binary_metrics.py
pr_auc(true_val, pred_val)
¶
Compute the area under the Precision-Recall curve for a model that maps from the PRS predictions to the binary phenotype.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val |
The response value or phenotype (a binary numpy vector with 0s and 1s) |
required | |
pred_val |
The predicted value or PRS (a numpy vector) |
required |
Source code in viprs/eval/binary_metrics.py
roc_auc(true_val, pred_val)
¶
Compute the area under the ROC (AUROC) for a model that maps from the PRS predictions to the binary phenotype.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_val |
The response value or phenotype (a numpy binary vector with 0s and 1s) |
required | |
pred_val |
The predicted value or PRS (a numpy vector) |
required |