Improvement: New function highorder_fuzzy_markov_chain that return the fuzzy markov chain (prior probability vector and transition matrix) of a PWFTS model
This commit is contained in:
parent
d3aaa8a692
commit
c8f4513f5e
@ -661,22 +661,29 @@ class ProbabilisticWeightedFTS(ifts.IntervalFTS):
|
|||||||
return tmp
|
return tmp
|
||||||
|
|
||||||
|
|
||||||
def visualize_distributions(model, **kwargs):
|
def highorder_fuzzy_markov_chain(model):
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
from matplotlib import gridspec
|
|
||||||
import seaborn as sns
|
|
||||||
|
|
||||||
ordered_sets = model.partitioner.ordered_sets
|
ordered_sets = model.partitioner.ordered_sets
|
||||||
|
|
||||||
ftpg_keys = sorted(model.flrgs.keys(), key=lambda x: model.flrgs[x].get_midpoint(model.sets))
|
ftpg_keys = sorted(model.flrgs.keys(), key=lambda x: model.flrgs[x].get_midpoint(model.sets))
|
||||||
|
|
||||||
lhs_probs = [model.flrg_lhs_unconditional_probability(model.flrgs[k])
|
lhs_probs = np.array([model.flrg_lhs_unconditional_probability(model.flrgs[k])
|
||||||
for k in ftpg_keys]
|
for k in ftpg_keys])
|
||||||
|
|
||||||
mat = np.zeros((len(ftpg_keys), len(ordered_sets)))
|
mat = np.zeros((len(ftpg_keys), len(ordered_sets)))
|
||||||
for row, w in enumerate(ftpg_keys):
|
for row, w in enumerate(ftpg_keys):
|
||||||
for col, k in enumerate(ordered_sets):
|
for col, k in enumerate(ordered_sets):
|
||||||
if k in model.flrgs[w].RHS:
|
if k in model.flrgs[w].RHS:
|
||||||
mat[row, col] = model.flrgs[w].rhs_unconditional_probability(k)
|
mat[row, col] = model.flrgs[w].rhs_unconditional_probability(k)
|
||||||
|
|
||||||
|
return ftpg_keys, ordered_sets, lhs_probs, mat
|
||||||
|
|
||||||
|
|
||||||
|
def visualize_distributions(model, **kwargs):
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
from matplotlib import gridspec
|
||||||
|
import seaborn as sns
|
||||||
|
|
||||||
|
ftpg_keys, ordered_sets, lhs_probs, mat = highorder_fuzzy_markov_chain(model)
|
||||||
|
|
||||||
size = kwargs.get('size', (5,10))
|
size = kwargs.get('size', (5,10))
|
||||||
|
|
||||||
@ -695,3 +702,5 @@ def visualize_distributions(model, **kwargs):
|
|||||||
ax.set_xticklabels(ordered_sets)
|
ax.set_xticklabels(ordered_sets)
|
||||||
ax.grid(True)
|
ax.grid(True)
|
||||||
ax.xaxis.set_tick_params(rotation=90)
|
ax.xaxis.set_tick_params(rotation=90)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user