-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Trying to run the examples from the readme :
from yaglm.toy_data import sample_sparse_lin_reg
from yaglm.GlmTuned import GlmCV, GlmTrainMetric
from yaglm.config.loss import Huber
from yaglm.config.penalty import Lasso, GroupLasso
from yaglm.config.flavor import Adaptive, NonConvex
from yaglm.metrics.info_criteria import InfoCriteria
from yaglm.infer.Inferencer import Inferencer
from yaglm.infer.lin_reg_noise_var import ViaRidge
# sample sparse linear regression data
X, y, _ = sample_sparse_lin_reg(n_samples=100, n_features=10)
# fit a lasso penalty tuned via cross-validation with the 1se rule
GlmCV(loss='lin_reg',
penalty=Lasso(), # specify penalty with config object
select_rule='1se'
).fit(X, y)
# fit an adaptive lasso tuned via cross-validation
# initialized with a lasso tuned with cross-validation
GlmCV(loss='lin_reg',
penalty=Lasso(flavor=Adaptive()),
initializer='default'
).fit(X, y)
# fit an adaptive lasso and tuned via EBIC
# estimate the noise variance via a ridge-regression method
GlmTrainMetric(loss='lin_reg',
penalty=Lasso(flavor=Adaptive()),
inferencer=Inferencer(scale=ViaRidge()), # noise variance estimator
scorer=InfoCriteria(crit='ebic') # Info criteria
).fit(X, y)
raises the following errors :
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In [11], line 37
25 GlmCV(loss='lin_reg',
26 penalty=Lasso(flavor=Adaptive()),
27 initializer='default'
28 ).fit(X, y)
30 # fit an adaptive lasso and tuned via EBIC
31 # estimate the noise variance via a ridge-regression method
32 GlmTrainMetric(loss='lin_reg',
33 penalty=Lasso(flavor=Adaptive()),
34
35 inferencer=Inferencer(scale=ViaRidge()), # noise variance estimator
36 scorer=InfoCriteria(crit='ebic') # Info criteria
---> 37 ).fit(X, y)
File ~/opt/anaconda3/envs/automated_reliability_tests/lib/python3.10/site-packages/yaglm-_0.3.3_-py3.10.egg/yaglm/GlmTuned.py:341, in GlmTrainMetric.fit(self, X, y, sample_weight, offsets)
334 start_time = time()
336 ##############################################
337 # setup, preprocess, and prefitting routines #
338 ##############################################
339 pro_data, raw_data, pre_pro_out, \
340 configs, solver, init_data, inferencer = \
--> 341 self.setup_and_prefit(X=X, y=y,
342 sample_weight=sample_weight,
343 offsets=offsets)
345 # store inferencer
346 self.inferencer_ = inferencer
File ~/opt/anaconda3/envs/automated_reliability_tests/lib/python3.10/site-packages/yaglm-_0.3.3_-py3.10.egg/yaglm/base.py:429, in BaseGlm.setup_and_prefit(self, X, y, sample_weight, offsets)
425 raw_data = {'X': X, 'y': y,
426 'sample_weight': sample_weight, 'offsets': offsets}
428 # run any prefitting inference
--> 429 inferencer = self.run_prefit_inference(**raw_data)
431 # preproceess X, y
432 pro_data, pre_pro_out = self.preprocess(**raw_data, copy=True)
File ~/opt/anaconda3/envs/automated_reliability_tests/lib/python3.10/site-packages/yaglm-_0.3.3_-py3.10.egg/yaglm/base.py:718, in BaseGlm.run_prefit_inference(self, X, y, sample_weight, offsets)
715 if self.inferencer is not None:
716 # TODO: do we want to do a copy here?
717 inferencer = deepcopy(self.inferencer)
--> 718 inferencer.pre_fit(estimator=self, X=X, y=y,
719 sample_weight=sample_weight,
720 offsets=offsets)
721 return inferencer
723 else:
TypeError: Inferencer.pre_fit() got an unexpected keyword argument 'offset
Indeed, l718 in base.py a call to pre_fit of an inferencer is passed using an offset argument :
inferencer.pre_fit(estimator=self, X=X, y=y,
sample_weight=sample_weight,
offsets=offsets)
while inferencer pre_fit methods does not accept offsets parameter yet according to l45 in Inferencer.py
def pre_fit(self, estimator, X, y, sample_weight=None):
I see that a commit adding offset have been merged recently so I guess it is related.
I hope it helps,
Thanks a lot for the package and I hope the project goes on !
Best regards,
Timothée
t-silvers and JoachimSchaeffer
Metadata
Metadata
Assignees
Labels
No labels