Old engine for Continuous Time Bayesian Networks. Superseded by reCTBN. 🐍
https://github.com/madlabunimib/PyCTBN
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.8 KiB
58 lines
1.8 KiB
4 years ago
|
import sys
|
||
|
sys.path.append('../')
|
||
4 years ago
|
|
||
5 years ago
|
import numpy as np
|
||
|
|
||
|
|
||
4 years ago
|
class Trajectory:
|
||
5 years ago
|
"""
|
||
4 years ago
|
Abstracts the infos about a complete set of trajectories, represented as a numpy array of doubles and a numpy matrix
|
||
|
of ints.
|
||
4 years ago
|
|
||
4 years ago
|
:list_of_columns: the list containing the times array and values matrix
|
||
|
:original_cols_numb: total number of cols in the data
|
||
|
:actual_trajectory: the trajectory containing also the duplicated and shifted values
|
||
|
:times: the array containing the time deltas
|
||
5 years ago
|
|
||
|
"""
|
||
5 years ago
|
|
||
4 years ago
|
def __init__(self, list_of_columns, original_cols_number):
|
||
|
if type(list_of_columns[0][0]) != np.float64:
|
||
|
raise TypeError('The first array in the list has to be Times')
|
||
|
self.original_cols_number = original_cols_number
|
||
4 years ago
|
self._actual_trajectory = np.array(list_of_columns[1:], dtype=np.int).T
|
||
|
self._times = np.array(list_of_columns[0], dtype=np.float)
|
||
|
|
||
|
@property
|
||
4 years ago
|
def trajectory(self) -> np.ndarray:
|
||
4 years ago
|
"""
|
||
|
Parameters:
|
||
|
void
|
||
|
Returns:
|
||
|
a numpy matrix containing ONLY the original columns values, not the shifted ones
|
||
|
"""
|
||
4 years ago
|
return self._actual_trajectory[:, :self.original_cols_number]
|
||
4 years ago
|
|
||
|
@property
|
||
4 years ago
|
def complete_trajectory(self) -> np.ndarray:
|
||
4 years ago
|
"""
|
||
|
Parameters:
|
||
|
void
|
||
|
Returns:
|
||
|
a numpy matrix containing all the values
|
||
|
"""
|
||
4 years ago
|
return self._actual_trajectory
|
||
|
|
||
|
@property
|
||
|
def times(self):
|
||
|
return self._times
|
||
4 years ago
|
|
||
4 years ago
|
def size(self):
|
||
4 years ago
|
return self._actual_trajectory.shape[0]
|
||
|
|
||
|
def __repr__(self):
|
||
|
return "Complete Trajectory Rows: " + str(self.size()) + "\n" + self.complete_trajectory.__repr__() + \
|
||
|
"\nTimes Rows:" + str(self.times.size) + "\n" + self.times.__repr__()
|
||
4 years ago
|
|
||
5 years ago
|
|