Mixed Effects Dummy Model
Project description
DumME: Mixed Effects Dummy Model
This is an adaptation of MERF (https://github.com/manifoldai/merf). The main difference is that this version is fully compliant with the scikit-learn API.
Other difference include:
- The name: MERF was renamed to the more general MixedEffectsModel
- The default fixed-effects model: dummy model instead of random forest
- The package structure: stripped down to its core and then upgraded to use modern standards
- Test suite: using pytest instead of unittest
[!CAUTION] We are currently not maintaining or developing this further. Ideally we would contribute our changes to the original version of MERF (see https://github.com/manifoldai/merf/issues/68). Do reach out if you want to build upon or collaborate with us on this.
Using this version
Install via github:
pip install git+https://github.com/phenology/merf
Instantiate the dummy model:
from dumme.dumme import MixedEffectsModel
from dumme.utils import DummeDataGenerator
# Get some sample data
dg = DummeDataGenerator(m=0.6, sigma_b=4.5, sigma_e=1)
df, _ = dg.generate_split_samples([1, 3], [3, 2], [1, 1])
y = df.pop("y")
x = df
# Fit a dummy model
# Notice the signature of the `fit` method: first X and y, and the other args are optional.
me_dummy = MixedEffectsModel()
me_dummy.fit(X, y)
# or
me_dummy.fit(X, y, cluster_column="cluster", fixed_effects=["X_0", "X_1", "X_2"], random_effects=["Z"])
# Predict only accepts X as input. It is assumed new data is structured
# in the same way as the original training data.
new_X = X.copy()
me_dummy.predict(new_X)
To get the "original" MERF (but still with the new fit signature):
from sklearn.ensemble import RandomForestRegressor
rf = RandomForestRegressor(n_estimators=300, n_jobs=-1)
me_rf = MixedEffectsModel(rf)
me_rf.fit(X, y)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file DumME-0.1.0.tar.gz
.
File metadata
- Download URL: DumME-0.1.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30b83ccfad3bc4cd2c2ed824226ef1efd1da205a03e102a7184d095a37941eab |
|
MD5 | 5886aa6a285b8333c47e184467a5f15c |
|
BLAKE2b-256 | dfd0cca14c29ae9e3342453307a76d1551e0faab1abdecb8d073a4e85ff06f0e |
File details
Details for the file DumME-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: DumME-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92684bee7ba9a8a0f1c35e49cdb90b55c6960874f769ae73a4a7a39b8f071c4a |
|
MD5 | 188ae823ca17be894e1c7226904e6644 |
|
BLAKE2b-256 | 9c02c54fc6a17222cc484bb70ff1b83793a5b54530891c7e6efd7a82340237b4 |