from sklearn.datasets import make_regression
from sklearn.model_selection import cross_validate
from sklearn.metrics import make_scorer, mean_absolute_error
from rse import RSE
# S is Stimulus Featues, B is Neural Activity.
S, B = make_regression(n_samples=100, n_features=500, n_targets=500, random_state=0)print(f'the shape of S (Stimulus Featues): { S.shape } \nthe shape of B (Neural Activity): { B.shape }')
cv_results = cross_validate(estimator=RSE(), X=S, y=B, scoring=make_scorer(mean_absolute_error))print('MAE score:', cv_results['test_score'])
output
the shape of S (Stimulus Featues): (100, 500)
the shape of B (Neural Activity): (100, 500)
MAE score: [153.16376721 156.01156413 132.29871222 125.02879147 139.89512202]
Kriegeskorte, N. (2011). Pattern-information analysis: From stimulus decoding to computational-model testing. NeuroImage, 56(2), 411–421. url
Anderson, A. J., Zinszer, B. D., & Raizada, R. D. S. (2016). Representational similarity encoding for fMRI: Pattern-based synthesis to predict brain activity using stimulus-model-similarities. NeuroImage, 128, 44–53. url