cnellington / Contextualized

An SKLearn-style toolbox for estimating and analyzing models, distributions, and functions with context-specific parameters.
http://contextualized.ml/
GNU General Public License v3.0
65 stars 9 forks source link

SKLearn Modules weird behavior with linear encoder passed in fit kwargs #237

Open cnellington opened 6 months ago

cnellington commented 6 months ago

To reproduce

import numpy as np
C = np.random.normal(0, 1, (100, 2))
X = np.random.normal(0, 1, (100, 2))
Y = np.random.normal(0, 1, 100)

from contextualized.easy import ContextualizedRegressor
model = ContextualizedRegressor(encoder_type='linear')
model.fit(C, X, Y)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/calebellington/Workbench/Contextualized/contextualized/easy/wrappers/SKLearnWrapper.py", line 514, in fit
    model = self.base_constructor(**organized_kwargs["model"])
  File "/Users/calebellington/Workbench/Contextualized/contextualized/regression/lightning_modules.py", line 69, in __init__
    self._build_metamodel(*args, **kwargs)
  File "/Users/calebellington/Workbench/Contextualized/contextualized/regression/lightning_modules.py", line 243, in _build_metamodel
    self.metamodel = NaiveMetamodel(*args, **kwargs)
  File "/Users/calebellington/Workbench/Contextualized/contextualized/regression/metamodels.py", line 50, in __init__
    self.context_encoder = encoder(context_dim, out_dim, **encoder_kwargs)
TypeError: Linear.__init__() got an unexpected keyword argument 'width'