temporal_type='Cumulative')

    # Initialize a threshold set
    As = ThresholdSet(TMSet=T)

    print("> Fit Multiperiod Thresholds")
    for ri in range(0, Ratings):
        print("RI: ", ri)
        As.fit(AR_Model, ri)

    print(
        "> Validate Multiperiod Thresholds against Input Transition Matrix Set"
    )
    Q = As.validate(AR_Model)

    print("> Save Multiperiod Thresholds in JSON Format")
    As.to_json('generic_thresholds.json')

elif example == 2:
    TS = tm.TransitionMatrixSet(json_file=dataset_path +
                                'generic_monthly.json')
    As = ThresholdSet(TMSet=TS)
    for ri in range(0, TS.entries[0].dimension):
        print("RI: ", ri)
        As.fit(AR_Model, ri)

    print(
        "> Validate Multiperiod Thresholds against Input Transition Matrix Set"
    )
    Q = As.validate(AR_Model)
# Example 2: Minimal -> Three state transition matrix

M = tm.TransitionMatrix(values=Generic)
# Lets take a look at the values
M.print()
M.validate()

# The size of the rating scale
Ratings = M.dimension

# The Default (absorbing state)
Default = Ratings - 1

# Lets extend the matrix into multi periods
Periods = 5
T = tm.TransitionMatrixSet(values=M, periods=Periods, method='Power', temporal_type='Cumulative')

# Initialize a threshold set
As = ThresholdSet(TMSet=T)

print("> Fit Multiperiod Thresholds")
for ri in range(0, Ratings):
    print("RI: ", ri)
    As.fit(AR_Model, ri)

print("> Validate Multiperiod Thresholds against Input Transition Matrix Set")
Q = As.validate(AR_Model)

print("> Save Multiperiod Thresholds in JSON Format")
As.to_json('generic_thresholds.json')
    Ratings = M.dimension

    # The Default (absorbing state)
    Default = Ratings - 1

    # Lets extend the matrix into multi periods
    Periods = 10
    T = tm.TransitionMatrixSet(values=M,
                               periods=Periods,
                               method='Power',
                               temporal_type='Cumulative')
    print("> Extend the matrix into 10 periods")
elif example == 2:
    T = tm.TransitionMatrixSet(periods=120,
                               temporal_type='Cumulative',
                               json_file=dataset_path + "generic_monthly.json")
    Ratings = T.entries[0].dimension

# Initialize a threshold set
As = ThresholdSet(TMSet=T)

# Calculate thresholds per initial rating state
print("> Calculate thresholds per initial rating state")
for ri in range(0, Ratings):
    print("Initial Rating: ", ri)
    As.fit(AR_Model, ri, dt=1.0 / 12.0)
As.to_json(json_file="monthly_thresholds.json")

# Display the calculated thresholds
# print("> Display the calculated thresholds")
# As.print()