PyFastL2LR is fast implementation of ridge regression (regression with L2 normalization) that is developed for predicting neural netowrk unit activities from fMRI data. This method is five times faster than ordinary implementations of ridge regression, and can be used with feature selection.
$ pip install fastl2lir
When installing on Python >= 3.5, threadpoolctl are required.
import fastl2lir
model = fastl2lir.FastL2LiR()
model.fit(X, Y, alpha, n_feat)
Y_predicted = model.predict(X)
Here,
X: A matrix (# of training samples x # of voxels).Y: A vector including label information (# of training samples x # of cnn features).alpha: Regularization term of L2 normalization.n_feat: # of features to be selected (feature selection is based on correlation coefficient).
See demo.py for more examples.
- You don't need to add bias term in
X;FastL2LiRautomatically adds the bias term in the input data. FastL2LiR.fit()automatically performs feature selection. You don't need to select features by yourself.XandYshould be z-scored with mean and standard deviation of training data.