rsatoolbox.model.model module

Definition of RSA Model class and subclasses

class rsatoolbox.model.model.Model(name)[source]

Bases: object

Abstract model class. Defines members that every class needs to have, but does not implement any interesting behavior. Inherit from this class to define specific model types

fit(data, method='cosine', pattern_idx=None, pattern_descriptor=None, sigma_k=None)[source]

fit the model to a RDM object data

Parameters
  • data (RDM object) – the RDMs to be fit with the model

  • method (String) – how to measure rdm_similarity

  • patterrn_idx – which patterns to use

  • pattern_descriptor – which part of the dict to use to interpret pattern_idx

Returns

parameter vector (one dimensional)

Return type

theta(numpy.ndarray)

predict(theta=None)[source]

Returns the predicted rdm vector

Parameters

theta (numpy.ndarray) – the model parameter vector (one dimensional)

Returns

rdm vector

Return type

numpy.ndarray

predict_rdm(theta=None)[source]

Returns the predicted rdm as an object

Parameters

theta (numpy.ndarray) – the model parameter vector (one dimensional)

Returns

rdm object

Return type

numpy.ndarray

to_dict()[source]

Converts the model into a dictionary, which can be used for saving

Returns

A dictionary containting all data needed to

recreate the object

Return type

model_dict(dict)

class rsatoolbox.model.model.ModelFixed(name, rdm)[source]

Bases: Model

predict(theta=None)[source]

Returns the predicted rdm vector

For the fixed model there are no parameters. theta is ignored.

Parameters

theta (numpy.ndarray) – the model parameter vector (one dimensional)

Returns

rdm vector

predict_rdm(theta=None)[source]

Returns the predicted rdm vector

For the fixed model there are no parameters.

Parameters

theta (numpy.ndarray) – the model parameter vector (one dimensional)

Returns

rdm object

Return type

rsatoolbox.rdm.RDMs

class rsatoolbox.model.model.ModelInterpolate(name, rdm)[source]

Bases: Model

inpterpolation Model models the RDM as an interpolation between 2 neigboring rdms

predict(theta=None)[source]

Returns the predicted rdm vector

theta are the weights for the different rdms

Parameters

theta (numpy.ndarray) – the model parameter vector (one dimensional)

Returns

rdm vector

predict_rdm(theta=None)[source]

Returns the predicted rdm vector

For the fixed model there are no parameters.

Parameters

theta (numpy.ndarray) – the model parameter vector (one dimensional)

Returns

rdm object

Return type

rsatoolbox.rdm.RDMs

class rsatoolbox.model.model.ModelSelect(name, rdm)[source]

Bases: Model

Selection model This model has a set of RDMs and selects one of them as its prediction. theta should here be an integer index

predict(theta=0)[source]

Returns the predicted rdm vector

For the fixed model there are no parameters. theta is ignored.

Parameters

theta (numpy.ndarray) – the model parameter vector (one dimensional)

Returns

rdm vector

predict_rdm(theta=0)[source]

Returns the predicted rdm vector

For the fixed model there are no parameters.

Parameters

theta (numpy.ndarray) – the model parameter vector (one dimensional)

Returns

rdm object

Return type

rsatoolbox.rdm.RDMs

class rsatoolbox.model.model.ModelWeighted(name, rdm)[source]

Bases: Model

weighted Model models the RDM as a weighted sum of a set of RDMs

predict(theta=None)[source]

Returns the predicted rdm vector

theta are the weights for the different rdms

Parameters

theta (numpy.ndarray) – the model parameter vector (one dimensional)

Returns

rdm vector

predict_rdm(theta=None)[source]

Returns the predicted rdm vector

For the fixed model there are no parameters.

Parameters

theta (numpy.ndarray) – the model parameter vector (one dimensional)

Returns

rdm object

Return type

rsatoolbox.rdm.RDMs

rsatoolbox.model.model.model_from_dict(model_dict)[source]

recreates a model object from a dictionary

Parameters

model_dict (dict) – The dictionary to be turned into a model

Returns

model(Model): The recreated model