跳转到主要内容

混合效应虚拟模型

项目描述

DOI

杜姆ME:混合效应虚拟模型

这是MERF(《https://github.com/manifoldai/merf》)的一个改编版本。主要区别在于这个版本完全符合scikit-learn API。

其他区别包括

  • 名称:MERF更名为更通用的MixedEffectsModel
  • 默认固定效应模型:虚拟模型而不是随机森林
  • 包结构:简化到核心,然后升级到使用现代标准
  • 测试套件:使用pytest而不是unittest

[注意] 我们目前没有维护或进一步开发此版本。理想情况下,我们会将我们的更改贡献给MERF的原始版本(见《https://github.com/manifoldai/merf/issues/68》)。如果您想在此基础上构建或与我们合作,请与我们联系。

使用此版本

通过github安装

pip install git+https://github.com/phenology/merf

实例化虚拟模型

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)

要获得“原始”MERF(但仍然具有新的fit签名)

from sklearn.ensemble import RandomForestRegressor

rf = RandomForestRegressor(n_estimators=300, n_jobs=-1)
me_rf = MixedEffectsModel(rf)
me_rf.fit(X, y)

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于《安装包》的信息。

源分布

DumME-0.1.0.tar.gz (14.2 kB 查看哈希值)

上传时间: 源代码

构建发行版

DumME-0.1.0-py3-none-any.whl (12.2 kB 查看哈希值)

上传时间: Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面