Skip to content

Instantly share code, notes, and snippets.

@tristanwietsma
tristanwietsma / glmnet.py
Last active October 9, 2023 18:55
Access glmnet through RPy2
import numpy as np
import rpy2.robjects as ro
import rpy2.robjects.numpy2ri as n2r
n2r.activate()
r = ro.r
r.library('glmnet')
# input files (for this example) need to have header and NO index column
X = np.loadtxt('./x.csv', dtype=float, delimiter=',', skiprows=1)