mendevi.models.base.Model

class mendevi.models.base.Model(*args: tuple, **kwargs: dict)[source]

Common structure to all models.

Attributes

citestr

The latex bibtext model citation.

parameterstuple[tuple[str], dict[tuple, object]] | None

The fitted parameters of the trainable model (readonly).

aggregationlist[str]

The labels that divide clusterers (readonly).

input_labelslist[str]

The name of all input parameters (readonly).

input_labels_aggreglist[str]

The subset of input_label that does not contain the aggregation values (readonly).

output_labelslist[str]

The name of all output parameters (readonly).

accuracydict[str, dict]

For each cluster name, associate for each output label, the predicted and validation data. This dictionary is builded / overwitten when the .validate method is called (readonly).

Initialise the model.

Parameters

titlestr, optional

The model title.

**kwargsdict

Includes the following fields.

sourcesstr

All sources for the model, the conference paper, the authors, etc.

input_labelslist[str]

The name of all input parameters. The possibles values are mendevi.plot.axis.Name.

output_labelslist[str]

The name of all output parameters. The possibles values are mendevi.plot.axis.Name.

aggregationlist[str]

Specifies the list of parameters that the model will not interpolate. By default, this list consists of the subset of discrete parameters from input_labels. For example, if you provide an empty list, a single instance of the model will be trained on all parameters.

property accuracy: dict[str, float]

Return the error std for each output label.

property aggregation: list[str]

Return the labels that divide clusters.

property cite: str

Return the bibtex citation.

extract_video_props(video: Path | str) dict[str][source]

Excerpt from the video, useful settings for the model.

Parameters

videopathlike

The path to the video whose behavior we want to predict.

Returns

propertiesdict[str]

For relevant input labels, associate the corresponding properties of the video provided as a parameter.

fit(database: Path | str, select: str | None = None, query: str | None = None, table: str | None = None) Self[source]

Fit the trainable hyper parameters of the model.

Parameters

databasepathlike

The training database.

selectstr, optional

The python expression to keep the line, like mendevi plot --filter.

querystr, optional

If provided, use this sql query to perform the request, otherwise (default) attemps to guess the query.

tablestr, optional

The main sql table juste after the FROM in SELECT. It helps to choose the write query when there is several candidates.

Return

self

A reference to the inplace fitted model.

fit_generator(database: Path | str, select: str | None = None, query: str | None = None, table: str | None = None, *, _validate: bool = False) Self[source]

Fit the trainable hyper parameters of the model.

Implementation of :py:method:`fit`.

property input_labels: list[str]

Return the name of all input parameters.

property input_labels_aggreg: list[str]

Return the subset of input_label that does not contain the aggregation values.

is_fit() bool[source]

Return True if the method fit has been succesfully called.

property output_labels: list[str]

Return the name of all output parameters.

predict(*input_args: tuple, **input_kwargs: dict) dict[str, list][source]

Perform the prediction(s) of this model.

Parameters

*input_args, **input_kwargs

The parameters values, with the keys defined during initialisation.

Returns

predictiondict[str]

Associate each ouput variable with the prediction.

predict_from_video(video: Path | str, *args: tuple, **kwargs: dict) dict[str, list][source]

Simplify the predict method by automatically extracting parameters from the video.

Parameters

videopathlike

Transmitted to self.extract_video_props.

*args, **kwargs, optional

The other arguments are passed to the prdict method. Accept a list of arguments for vectorization. Single values are duplicated in a list of the same length as the longest one.

Returns

predictiondict[str]

The value returned by the predict method.

validate(database: Path | str, select: str | None = None, query: str | None = None, table: str | None = None) None[source]

Evaluate the model accuracy.

It fill the attribute self.accuracy.

All parameters are the same as :py:method:`fit`.

static vectorize_kwargs(kwargs: dict[str], *, _skip_duplication: bool = False) dict[str][source]

Help for predict method.