scnn.metrics
Metrics that can be recorded while training models.
- class scnn.metrics.Metrics(metric_freq: int = 25, objective: bool = True, grad_norm: bool = True, time: bool = True, model_loss: bool = False, constraint_gaps: bool = False, lagrangian_grad: bool = False, train_accuracy: bool = False, train_mse: bool = False, test_accuracy: bool = False, test_mse: bool = False, total_neurons: bool = False, neuron_sparsity: bool = False, active_neurons: bool = False, total_features: bool = False, feature_sparsity: bool = False, active_features: bool = False, active_weights: bool = False, weight_sparsity: bool = False)
Metrics collected while optimizing models.
By default, only the objective, training time, and norm of the minimum-norm subgradient are collected.
- objective
the optimization objective, including any constraint penalty terms.
- Type:
numpy.ndarray
- time
the cumulative wall-clock time.
- Type:
numpy.ndarray
- grad_norm
squared 2-norm of the minimum-norm subgradient of the optimization objective, including penalty terms.
- Type:
numpy.ndarray
- model_loss
the regularized loss of the model on the training set. This is the same as objective but does not include penalties.
- Type:
numpy.ndarray
- constraint_gaps
2-norm of constraint violations. Ignored for unconstrained problems.
- Type:
numpy.ndarray
- lagrangian_grad
2-norm of the (primal) subgradient of the Lagrangian function. Ignored for unconstrained problems.
- Type:
numpy.ndarray
- train_accuracy
accuracy on the training set.
- Type:
numpy.ndarray
- train_mse
mean squared error on the training set.
- Type:
numpy.ndarray
- test_accuracy"
accuracy on the test set.
- test_mse
means squared error on the test set.
- Type:
numpy.ndarray
- total_neurons
total number of neurons (active and inactive) in the model.
- Type:
numpy.ndarray
- neuron_sparsity
proportion of neurons which are not used by the model (ie. all weights are exactly zero for those neurons).
- Type:
numpy.ndarray
- active_neurons
the number of neurons which are active (ie. the weights for those neurons are not exactly zero).
- Type:
numpy.ndarray
- total_features
total number of features in the dataset (both used and not used by the model).
- Type:
numpy.ndarray
- feature_sparsity
proportion of features which are not used by the model (ie. all weights are exactly zero for those features).
- Type:
numpy.ndarray
- active_features
the number of features currently used by the model.
- Type:
numpy.ndarray
- weight_sparsity
proportion of weights are which zero.
- Type:
numpy.ndarray
- metric_freq
the frequency (in iterations) at which metrics should be collected in iterations.
- metrics_to_collect
internal dictionary specifying which metrics should be collected.
- has_test_metrics() bool
Returns True if any test-set metric is enabled, False otherwise.