本文整理汇总了Python中pgmpy.models.MarkovModel.fit方法的典型用法代码示例。如果您正苦于以下问题:Python MarkovModel.fit方法的具体用法?Python MarkovModel.fit怎么用?Python MarkovModel.fit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pgmpy.models.MarkovModel
的用法示例。
在下文中一共展示了MarkovModel.fit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MarkovModel
# 需要导入模块: from pgmpy.models import MarkovModel [as 别名]
# 或者: from pgmpy.models.MarkovModel import fit [as 别名]
import numpy as np
import pandas as pd
from pgmpy.models import MarkovModel
from pgmpy.estimators import PseudoMomentMatchingEstimator
# Generating some random data
raw_data = np.random.randint(low=0, high=2, size=(100, 4))
raw_data
data = pd.DataFrame(raw_data, columns=['A', 'B', 'C', 'D'])
data
# Diamond shaped Markov Model as stated in Fig. 6.1
markov_model = MarkovModel([('A', 'B'), ('B', 'C'),
('C', 'D'), ('D', 'A')])
markov_model.fit(data, estimator=PseudoMomentMatchingEstimator)
factors = coin_model.get_factors()
factors
示例2: MarkovModel
# 需要导入模块: from pgmpy.models import MarkovModel [as 别名]
# 或者: from pgmpy.models.MarkovModel import fit [as 别名]
import numpy as np
import pandas as pd
from pgmpy.models import MarkovModel
from pgmpy.estimators import MaximumLikelihoodEstimator
# Generating some random data
raw_data = np.random.randint(low=0, high=2, size=(100, 2))
raw_data
data = pd.DataFrame(raw_data, columns=['A', 'B'])
data
# Markov Model as stated in Fig. 6.5
markov_model = MarkovModel([('A', 'B')])
markov_model.fit(data, estimator=MaximumLikelihoodEstimator)
factors = coin_model.get_factors()
print(factors[0])
示例3: MarkovModel
# 需要导入模块: from pgmpy.models import MarkovModel [as 别名]
# 或者: from pgmpy.models.MarkovModel import fit [as 别名]
import numpy as np
import pandas as pd
from pgmpy.models import MarkovModel
from pgmpy.estimators import BayesianEstimator
# Generating random data
raw_data = np.random.randint(low=0, high=2, size=(1000, 2))
data = pd.DataFrame(raw_data, columns=['X', 'Y'])
model = MarkovModel()
model.fit(data, estimator=BayesianEstimator)
model.get_factors()
model.get_nodes()
model.get_edges()