nltools icon indicating copy to clipboard operation
nltools copied to clipboard

Wrong cross validated weight maps in output for lassopcr

Open mpcoll opened this issue 3 years ago • 0 comments

In brain_data.py at line 1108 the same (non-cross validated) weight map is returned for each cross-validation fold because the initial classifier object is used instead of the cross-validation one.

I believe this part

if predictor_settings['algorithm'] == 'lassopcr':
    wt_map_xval.append(np.dot(predictor_settings['_pca'].components_.T, predictor_settings['_lasso'].coef_))
elif predictor_settings['algorithm'] == 'pcr':
    wt_map_xval.append(np.dot(predictor_settings['_pca'].components_.T, predictor_settings['_regress'].coef_))
else:
    wt_map_xval.append(predictor_cv.coef_.squeeze())
output['weight_map_xval'].data = np.array(wt_map_xval)

should be replaced by

if predictor_settings['algorithm'] == 'lassopcr':
    wt_map_xval.append(np.dot(predict_cv['pca'].components_.T, predict_cv['lasso'].coef_))
elif predictor_settings['algorithm'] == 'pcr':
    wt_map_xval.append(np.dot(predict_cv['pca'].components_.T, predict_cv['regress'].coef_))
else:
    wt_map_xval.append(predictor_cv.coef_.squeeze())
output['weight_map_xval'].data = np.array(wt_map_xval)

mpcoll avatar Jan 16 '21 20:01 mpcoll