Skip to content

Commit 7f1493d

Browse files
committed
Report R2 when estimating mixing weights
1 parent 6e3c5d9 commit 7f1493d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

polypred.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from pandas.api.types import is_numeric_dtype
1313
from polyfun_utils import Logger, check_package_versions, set_snpid_index, configure_logger
1414
from sklearn.linear_model import LinearRegression
15+
import sklearn.metrics as metrics
1516

1617
def splash_screen():
1718
print('*********************************************************************')
@@ -308,6 +309,8 @@ def estimate_mixing_weights(args):
308309
linreg = LinearRegression(positive = not args.allow_neg_mixweights)
309310
linreg.fit(df_prs_sum_all, df_pheno['PHENO'])
310311
mix_weights, intercept = linreg.coef_, linreg.intercept_
312+
r2_score = metrics.r2_score(df_pheno['PHENO'], linreg.predict(df_prs_sum_all))
313+
logging.info('In-sample R2: %0.3f'%(r2_score))
311314

312315
#create and print df_coef, and save it to disk
313316
df_coef = pd.Series(mix_weights, index=beta_files)

0 commit comments

Comments
 (0)