Package: pyfirst
FIRST: Factor Importance Ranking and Selection for Total IndicesAPython3module of FIRST, a model-independent factor importance ranking and selection procedure that is based on total Sobol' indices (Huang and Joseph, 2024). This research is supported by U.S. National Science Foundation grantsDMS-2310637andDMREF-1921873. TheRimplementation is also available onCRAN.Installationpipinstallpyfirstor from sourcepipinstallgit+https://github.com/BillHuang01/pyfirst.gitUsageFactor Importance Ranking and SelectionFIRSTis the main function of this module. It provides factor importance ranking and selection directly from scattered data without any model fitting, where the importance is computed based on total Sobol' indices (Sobol', 2001).FIRSTrequires the following two arguments:a numpy ndarray or a pandas dataframe for the factors/predictorsXa numpy ndarray or a pandas series for the responseyFIRSTreturns a numpy ndarray for the factor importance, with value ofzeroindicating that the factor is not important to the prediction of the response.frompyfirstimportFIRSTfromsklearn.datasetsimportmake_friedman1X,y=make_friedman1(n_samples=10000,n_features=10,noise=1.0,random_state=43)FIRST(X,y)For more advanced usages ofFIRST, e.g., speeding up for big data, please seeorAPI documentation.To support an easy integration withsklearn.pipeline.Pipelinefor a streamline model training process, we also provideSelectByFIRST, a class that is built fromsklearn.feature_selection.importnumpyasnpfrompyfirstimportSelectByFIRSTfromsklearn.pipelineimportPipelinefromsklearn.ensembleimportRandomForestRegressorfromsklearn.model_selectionimporttrain_test_splitfromsklearn.datasetsimportfetch_california_housinghousing=fetch_california_housing()X=housing.datay=np.log(housing.target)X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.2,random_state=43)pipe=Pipeline([('selector',SelectByFIRST(regression=True,random_state=43)),('estimator',RandomForestRegressor(random_state=43))]).fit(X_train,y_train)pipe.predict(X_test)For more details, please seeorAPI documentation.Total Sobol' Indices EstimationThis module also provides the functionTotalSobolKNNfor a consistent estimation of total Sobol' indices (Sobol', 2001) directly from scattered data. When the response is noiseless,TotalSobolKNNimplements the Nearest-Neighbor estimator fromBroto et al. (2020). For noisy response,TotalSobolKNNimplements the Noise-Adjusted Nearest-Neighbor estimator fromHuang and Joseph (2024).TotalSobolKNNreturns a numpy ndarray for the total Sobol' indices estimation.frompyfirstimportTotalSobolKNNfromsklearn.datasetsimportmake_friedman1X,y=make_friedman1(n_samples=10000,n_features=5,noise=1.0,random_state=43)TotalSobolKNN(X,y,noise=True)For more details and applications, please seeorAPI documentation.A documentation of this module is also available onRead the Docs.ReferencesHuang, C., & Joseph, V. R. (2024). Factor Importance Ranking and Selection using Total Indices. arXiv preprint arXiv:2401.00800.Sobol', I. M. (2001). Global sensitivity indices for nonlinear mathematical models and their Monte Carlo estimates. Mathematics and computers in simulation, 55(1-3), 271-280.Broto, B., Bachoc, F., & Depecker, M. (2020). Variance reduction for estimation of Shapley effects and adaptation to unknown input distribution. SIAM/ASA Journal on Uncertainty Quantification, 8(2), 693-716.CitationIf you find this module useful, please consider citing@article{huang2024factor,
  title={Factor Importance Ranking and Selection using Total Indices},
  author={Huang, Chaofan and Joseph, V Roshan},
  journal={arXiv preprint arXiv:2401.00800},
  year={2024}
}