probinet.models.base#

Base classes for the models classes.

Classes

ModelBase(*args, **kwargs)

Base class for the models classes that inherit from the ModelBaseParameters class.

ModelBaseParameters([inf, err_max, err, ...])

ModelUpdateMixin()

Mixin class for the update methods of the models classes.

class probinet.models.base.ModelBase(*args, **kwargs)[source]#

Base class for the models classes that inherit from the ModelBaseParameters class. It contains the methods to check the parameters of the fit method, initialize the parameters, and check for convergence. All the models classes should inherit from this class.

check_params_to_load_data(binary, noselfloop, undirected, **kwargs)[source]#

Check that the parameters to load the data are correct.

abstract compute_likelihood() float[source]#

Compute the log-likelihood of the data.

This is an abstract method that must be implemented in each derived class.

get_data_nonzero(data: COO | ndarray) tuple[source]#
get_data_nonzero(data: ndarray) tuple
get_data_nonzero(data: COO) tuple

Get the indices of non-zero elements in the data.

Parameters:

data (GraphDataType) – The data to get non-zero indices from.

Returns:

The indices of non-zero elements.

Return type:

tuple

Raises:

TypeError – If the data type is unsupported.

get_data_sum(data: COO | ndarray) float[source]#
get_data_sum(data: ndarray) float
get_data_sum(data: COO) float

Compute the sum of the data.

Parameters:

data (GraphDataType) – The data to sum.

Raises:

TypeError – If the data type is unsupported.

get_data_toarray(data: COO | ndarray) ndarray[source]#
get_data_toarray(data: ndarray) ndarray
get_data_toarray(data: COO) ndarray

Convert the data to a numpy array.

Parameters:

data (GraphDataType) – The data to convert.

Returns:

The converted numpy array.

Return type:

np.ndarray

Raises:

TypeError – If the data type is unsupported.

get_data_values(data) ndarray[source]#
get_data_values(data: ndarray) ndarray
get_data_values(data: COO) ndarray

Get the values of non-zero elements in the data.

Parameters:

data (Union[np.ndarray, COO]) – The data to get non-zero values from.

Returns:

The values of non-zero elements.

Return type:

np.ndarray

Raises:

TypeError – If the data type is unsupported.

get_params_to_load_data(args: Namespace) Dict[str, Any][source]#

Get the parameters from the arguments.

Parameters:

args (Namespace) – The arguments.

Returns:

params – The parameters.

Return type:

Dict[str, Any]

load_data(files: str, adj_name: str, **kwargs: Any) GraphData[source]#

Load the data from the input files.

Parameters:
  • files – The directory containing the input files.

  • adj_name – The name of the adjacency file.

  • **kwargs – Additional keyword arguments to pass to the data loading function.

Returns:

The loaded graph data.

Return type:

GraphData

class probinet.models.base.ModelBaseParameters(inf: float = 10000000000.0, err_max: float = 1e-12, err: float = 0.1, num_realizations: int = 3, convergence_tol: float = 0.0001, decision: int = 10, max_iter: int = 500, plot_loglik: bool = False, flag_conv: str = 'log')[source]#
inf#

Initial value of the log-likelihood.

Type:

float

err_max#

Minimum value for the parameters.

Type:

float

err#

Noise for the initialization.

Type:

float

num_realizations#

Number of iterations with different random initialization.

Type:

int

convergence_tol#

Tolerance for convergence.

Type:

float

decision#

Convergence parameter.

Type:

int

max_iter#

Maximum number of EM steps before aborting.

Type:

int

plot_loglik#

Flag to plot the log-likelihood.

Type:

bool

flag_conv#

Flag to choose the convergence criterion.

Type:

str

convergence_tol: float = 0.0001#
decision: int = 10#
err: float = 0.1#
err_max: float = 1e-12#
flag_conv: str = 'log'#
inf: float = 10000000000.0#
max_iter: int = 500#
num_realizations: int = 3#
plot_loglik: bool = False#
class probinet.models.base.ModelUpdateMixin[source]#

Mixin class for the update methods of the models classes. It is not a requirement to inherit from this class.