Set
In jajapy, a training / test set is a member of the Set class described below.
A Set has three attributes:
sequences: which is the list of all possible traces in the set.
times: which corresponds to the number of times each traces appears in the set.
type: that indicates which kind of traces are in sequences.
>>> import jajapy as ja
>>> model = ja.HMM_random(3,['a','b'])
>>> s = model.generateSet(5,3)
>>> s.sequences
[['a','b','b'],['a','b','a'],['b','a','a']]
>>> s.times
[1,3,1]
>>> # model has generated 'abb' and 'baa' once, and 'aba' three times
>>> s.type
0
>>> # if s.type == 0 then the traces are sequences of discrete observations,
>>> # i.e. they have been generated by a HMM or a MC (they can also be non-timed
>>> # traces of a CTMC).
- class jajapy.Set(sequences: list, times: Optional[list] = None, t: Optional[int] = None)
Class representing a set (training set / test set).
Creates the Set.
Parameters
- sequenceslist
List of sequences of traces. A trace can be: - a sequence of observations (list of str) ->HMM or MC - an alternating sequence of actions/observations (list of str) ->MDP - a sequence of vectors of timed observations (list of list of float) ->GoHMM - an alternating sequence of waiting-times/observations (list of float and str) ->CTMC
- timeslist, optional
times[i] is the number of time sequences[i] appears in the set. Can be omitted.
- tint, optional
0 if this set was generated by a HMM or a MC,
1 if it was generated by a MDP,
3 if it was generated by a GoHMM,
4 if it was generated by a CTMC.
- addSet(s2)
Merges this set with another generated by the same kind of Markov model.
Parameters
- s2Set
set 2.
Raises
- TypeError
If the two models type attribute are different.
- getActionsObservations() list
Returns all possible observations and all possible actions in this set.
Returns
- list
list of one list of actions and one list of observations.
- getAlphabet() list
Returns the list of all possible observations in this set.
Returns
- list
list of observations.
- isEqual(set2) bool
Checks wheter or not this set is equal to another set set2.
Parameters
- set2Set
Another set.
Returns
- bool
True if this set is equal to set2.
- setFromList(l: list) None
Convert a list of sequences of observations to a set.
Parameters
- llist
list of sequences of observations.
- sort() None
Sort the sequences in lexicographic order.