This Python package implements the function random_sparse_matrix that generates random sparse matrices.
The sparse matrices have named rows and columns -- see the package "SSparseMatrix", [AAp1].
Functions from the package "RandomDataGenerators", [AAp2], are used to obtain row- and column names and entry values.
To install from GitHub use the shell command:
python -m pip install git+https://github.com/antononcube/Python-packages.git#egg=RandomSparseMatrix\&subdirectory=RandomSparseMatrixTo install from PyPI:
python -m pip install RandomSparseMatrixHere is random sparse matrix
(SSparseMatrix object)
with 6 rows and 4 columns:
import random
from RandomSparseMatrix import *
random.seed(87)
rmat = random_sparse_matrix(6, 4,
column_names_generator=random_pet_name,
row_names_generator=random_word,
min_number_of_values=6,
max_number_of_values=None)
rmat.print_matrix(n_digits=20)
# ============================================================================================
# | Cleo Diamond Max Tessa
# --------------------------------------------------------------------------------------------
# cuticular | . . . 12.886794438387263
# elysian | . . . 13.891135469455826
# spot-check | . 11.465064963144142 . .
# cetacean | . 9.626463367706222 . .
# idem | 5.474873249244756 . . .
# lot | . . 10.818678723268317 .
# ============================================================================================[AAp1] Anton Antonov, SSparseMatrix Python package, (2021), PyPI.
[AAp2] Anton Antonov, RandomDataGenerators Python package, (2021), PyPI.
[AAp3] Anton Antonov, SparseMatrixRecommender Python package, (2021), PyPI.