Skip to content

results.py


pycmtensor.results

PyCMTensor results module

This module provides the results of the estimated model and output formatting

Results()

Bases: object

Base class object to hold model results and scores

Attributes:

Name Type Description
build_time str

string formatted time stamp of the duration of the build stage

train_time str

string formatted time stamp of the duration of the training stage

epochs_per_sec float

number of epochs of the training dataset per second, benchmark for calculation speed

n_params int

total number of parameters, used for calculating statistics

n_train int

number of training samples used

n_valid int

number of validation samples used

seed int

random seed value used

null_loglikelihood float

null log likelihood of the model

best_loglikelihood float

the final estimated model log likelihood

best_valid_error float

final estimated model validation error

best_epoch int

the epoch number at the final estimated model

gnorm float

the gradient norm at the final estimated model

hessian_matrix ndarray

the 2-D hessian matrix

bhhh_matrix ndarray

the 3-D bhhh matrix where the 1st dimension is the length of the dataset and the last 2 dimensions are the matrix for each data observation

statistics_graph dict

a dictionary containing the learning_rate, training, and validation statistics

betas dict

a dictionary containing the Beta coefficients

params dict

a dictionary containing all model coefficients

rho_square()

rho square value of the model

Returns:

Type Description
float

analogue for the model fit

rho_square_bar()

McFadden's adjusted rho square

Returns:

Type Description
float

the adjusted McFadden's rho square value

loglikelihood_ratio_test()

Log likelihood ratio test

Returns:

Type Description
float

the log likelihood ratio test: $-2 times (NLL-LL)

AIC()

Akaike information criterion

Returns:

Type Description
float

the AIC of the model

BIC()

Bayesian information criterion, adjusted for the number of parameters and number of training samples

Returns:

Type Description
float

the BIC of the model

benchmark()

benchmark statistics

Returns:

Type Description
DataFrame

Summary of the model performance benchmark

model_statistics()

model statistics

Returns:

Type Description
DataFrame

Summary of the model statistics

beta_statistics()

Beta statistics

Returns:

Type Description
DataFrame

Summary of the estimated Beta statistics

model_correlation_matrix()

Correlation matrix calculated from the hessian

Returns:

Type Description
DataFrame

The correlation matrix

model_robust_correlation_matrix()

Robust correlation matrix calculated from the hessian and bhhh

Returns:

Type Description
DataFrame

The robust correlation matrix

show_training_plot(sample_intervals=1)

Displays the statistics graph as a line plot

Parameters:

Name Type Description Default
sample_intervals int

plot only the n-th point from the statistics

1

Returns:

Type Description
DataFrame

The statistics as a pandas dataframe