Testing¶
Common helper functions for testing the ML algorithms in the rest of the repo.
Utilities for writing unit tests
-
numpy_ml.utils.testing.
is_symmetric
(X)[source]¶ Check that an array X is symmetric along its main diagonal
-
numpy_ml.utils.testing.
is_symmetric_positive_definite
(X)[source]¶ Check that a matrix X is a symmetric and positive-definite.
-
numpy_ml.utils.testing.
is_stochastic
(X)[source]¶ True if X contains probabilities that sum to 1 along the columns
-
numpy_ml.utils.testing.
is_one_hot
(x)[source]¶ Return True if array x is a binary array with a single 1
-
numpy_ml.utils.testing.
random_one_hot_matrix
(n_examples, n_classes)[source]¶ Create a random one-hot matrix of shape (n_examples, n_classes)
-
numpy_ml.utils.testing.
random_stochastic_matrix
(n_examples, n_classes)[source]¶ Create a random stochastic matrix of shape (n_examples, n_classes)
-
numpy_ml.utils.testing.
random_tensor
(shape, standardize=False)[source]¶ Create a random real-valued tensor of shape shape. If standardize is True, ensure each column has mean 0 and std 1.
-
numpy_ml.utils.testing.
random_binary_tensor
(shape, sparsity=0.5)[source]¶ Create a random binary tensor of shape shape. sparsity is a value between 0 and 1 controlling the ratio of 0s to 1s in the output tensor.
-
numpy_ml.utils.testing.
random_paragraph
(n_words, vocab=None)[source]¶ Generate a random paragraph consisting of n_words words. If vocab is not None, words will be drawn at random from this list. Otherwise, words will be sampled uniformly from a collection of 26 Latin words.
-
exception
numpy_ml.utils.testing.
DependencyWarning
[source]¶ Bases:
RuntimeWarning
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-