pomegranate
假设我使用当时可用的数据拟合模型。一旦有更多数据进入,我想相应地更新模型。换句话说,是否可以在pomegranate
不覆盖先前参数的情况下用新数据更新现有模型?需要明确的是:我不是指核外学习,因为我的问题与在不同时间点可用的数据有关,而不是在单个时间点提供过大的内存数据。
这是我尝试过的:
>>> from pomegranate.distributions import BetaDistribution
>>> # suppose a coin generated the following data, where 1 is head and 0 is tail
>>> data1 = [0, 0, 0, 1, 0, 1, 0, 1, 0, 0]
>>> # as usual, we fit a Beta distribution to infer the bias of the coin
>>> model = BetaDistribution(1, 1)
>>> model.summarize(data1) # compute sufficient statistics
>>> # presume we have seen all the data available so far,
>>> # we can now estimate the parameters
>>> model.from_summaries()
>>> # this results in the following model (so far so good)
>>> model
{
"class" :"Distribution",
"name" :"BetaDistribution",
"parameters" :[
3.0,
7.0
],
"frozen" :false
}
>>> # now suppose the coin is flipped a few more times, getting the following data
>>> data2 = [0, 1, 0, 0, 1]
>>> # we would like to update the model parameters accordingly
>>> model.summarize(data2)
>>> # but this fits only data2, overriding the previous parameters
>>> model.from_summaries()
>>> model
{
"class" :"Distribution",
"name" :"BetaDistribution",
"parameters" :[
2.0,
3.0
],
"frozen" :false
}
>>> # however I want to get the result that corresponds to the following,
>>> # but ideally without having to "drag along" data1
>>> data3 = data1 + data2
>>> model.fit(data3)
>>> model # this should be the final model
{
"class" :"Distribution",
"name" :"BetaDistribution",
"parameters" :[
5.0,
10.0
],
"frozen" :false
}
编辑:
提出问题的另一种方式:是否pomegranate
支持增量学习或在线学习?基本上,我正在寻找与scikit-learn
's类似的东西partial_fit()
,你可以在这里找到。
鉴于它pomegranate
支持核心外学习,我觉得我忽略了一些东西。有什么帮助吗?