Generators SubPackage
This subpackage implements test data generation
transitionMatrix.generators contents
- transitionMatrix.generators.dataset_generators.deterministic(sequences, replication_count)[source]
Generate a transition dataset from a given sequence. Each element in the list is a different transition profile through the state space starting with the initial observation. Replicating the sequences a number of times generates a statistical sample (each replication being a different entity). This allows controlled testing.
- Parameters:
sequences – a list of sequences to replicate
replication_count – the number of replications
- Returns:
- transitionMatrix.generators.dataset_generators.exponential_transitions(statespace, n, sample, rate, data_format='Compact')[source]
Generate continuous time events from exponential distribution and uniform sampling from state space. Suitable for testing cohorting algorithms and duration based estimators.
The data are sorted by entity ID, then by time of occurrence T. The first entry per entity indicates the state up to that timepoint. The format is a sequence of triples (ID, Time, State)
- Parameters:
statespace – The state space to use for the simulation
n (int) – The number of distinct entities to simulate
sample (int) – The number of events to simulate
rate (float) – The event rate
- Returns:
transition events
- Return type:
pandas dataframe
Note
May generate successive events in the same state
- transitionMatrix.generators.dataset_generators.long_format(statespace, mymatrix, n, timesteps, mode='Canonical')[source]
Generate continuous events from a markov chain matrix in long data format. Suitable for testing duration based estimators
- Parameters:
statespace (object) – The state space to use for the simulation
mymatrix (object) – The transition matrix to use for the simulation
n (int) – The number of distinct entities to simulate
timesteps (int) – The number of timesteps to simulate (including the initial state)
mode (str) – How to encode the data (Canonical -> From/To, Compact -> State)
- Returns:
generated dataset
- Return type:
pandas dataframe
- transitionMatrix.generators.dataset_generators.markov_chain(statespace, transitionmatrix, n, timesteps)[source]
Generate discrete events from a markov chain matrix in Compact data format. Suitable for testing cohort based estimators (each time step is a cohort)
- Parameters:
n (int) – The number of distinct entities to simulate
timesteps (int) – The number of timesteps to simulate (including initial state)
- Returns:
the message id
- Return type:
pandas dataframe
- transitionMatrix.generators.dataset_generators.portfolio_labels(statespace, n)[source]
Generate a collection of credit rating states emulating a snapshot of portfolio data. Suitable for mappings and transformations of credit rating states
- Parameters:
n (int) – The number of distinct entities to generate
- Returns:
the collection
- Return type:
list