in msticpy/analysis/anomalous_sequence/model.py [0:0]
def _compute_counts(self):
"""
Compute all the counts for the model.
The items we will count depend on the the `session_type` attribute.
We will compute the individual command and transition command counts.
If params are provided with the commands, then, in addition,
we will compute the individual param counts and param conditional
on the command counts.
If values are provided with the params, then in addition, we
will compute the individual value counts and value conditional
on the param counts. Also, we will use rough heuristics
to determine which params take categorical values, and hence
have modellable values.
"""
if self.session_type is None:
raise MsticpyException("session_type attribute should not be None")
if self.session_type == SessionType.cmds_only:
seq1_counts, seq2_counts = cmds_only.compute_counts(
sessions=self.sessions,
start_token=self.start_token,
end_token=self.end_token,
unk_token=self.unk_token,
)
self._seq1_counts = seq1_counts
self._seq2_counts = seq2_counts
elif self.session_type == SessionType.cmds_params_only:
(
seq1_counts,
seq2_counts,
param_counts,
cmd_param_counts,
) = cmds_params_only.compute_counts(
sessions=self.sessions,
start_token=self.start_token,
end_token=self.end_token,
)
self._seq1_counts = seq1_counts
self._seq2_counts = seq2_counts
self._param_counts = param_counts
self._cmd_param_counts = cmd_param_counts
elif self.session_type == SessionType.cmds_params_values:
(
seq1_counts,
seq2_counts,
param_counts,
cmd_param_counts,
value_counts,
param_value_counts,
) = cmds_params_values.compute_counts(
sessions=self.sessions,
start_token=self.start_token,
end_token=self.end_token,
)
if self.modellable_params is None:
modellable_params = cmds_params_values.get_params_to_model_values(
param_counts=param_counts, param_value_counts=param_value_counts
)
self.modellable_params = modellable_params
self._seq1_counts = seq1_counts
self._seq2_counts = seq2_counts
self._param_counts = param_counts
self._cmd_param_counts = cmd_param_counts
self._value_counts = value_counts
self._param_value_counts = param_value_counts