[R-pkg-devel] Identify Original Column Names of Model Matrix

Dario Strbenac d@tr7320 @end|ng |rom un|@@ydney@edu@@u
Mon Oct 10 10:00:04 CEST 2022


Good day,

I am developing a wrapper around xgboost which does not (yet - I see that it is on the developer's version 2.0 task list) support factor variable type. It requires input data to be in one-hot encoding, which is created by Matrix::sparse.model.matrix. For further analysis, such as variable importance, is there a way to identify which original feature each column of a sparse.model.matrix result was derived from? Using str(oneHotMatrix), I don't see any class slots nor tacked-on attributes which would confidently allow the identification of original column names of the expanded input data. Is there an alternative way to robustly identify the original variable names?

--------------------------------------
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia


More information about the R-package-devel mailing list