I would like to use the merf (mixed effect random forest) library in an ensemble model e.g. by using the mlens or mlxtend python libraries. However, due to the non-traditional way in which the fit and predict methods of merf are structured, I am unable to figure out how to do that:
from merf import MERF
merf = MERF()
merf.fit(X_train, Z_train, clusters_train, y_train)
y_hat = merf.predict(X_test, Z_test, clusters_test)
Is there a way I can use the merf library in an ensemble model? The issue is that building an ensemble model with mlens or other ensemble libraries assumes a scikit-learn structure where the fit method has X, y as input and the predict method has X as the input. However, merf clearly has more inputs in both the fit and predict methods. Here is a simplified syntax for mlens:
from mlens.ensemble import SuperLearner
ensemble = SuperLearner()
ensemble.add(estimators)
ensemble.add_meta(meta_estimator)
ensemble.fit(X, y).predict(X)
I am not restricted to using mlens or mlxten. Any other way to build an ensemble model with merf in it would work too.
I mean, you could always just sneak in the datamaking process using
merf:P. Majority of the data generation is taken from manifoldai merf example:Before making the fit and prediction with some modification from Flennerhag
mlens.ensemble superlearner.py(Github):But of course, there is always a better method overall if you don't mind specifically using the
merfandensembletogether.KerasmethodDo note that the
X_trainused here is from the previousmerfcode: