[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-118031-en":3,"doc-seo-118031-105":30,"detail-sidebar-cat-0-en-105":91},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":4,"is_deleted":4,"is_public":20,"is_downloadable":20,"audit_status":20,"page_count":21,"language":22,"language_code":23,"site_id":24,"html_lang":23,"table_of_contents":25,"faqs":26,"seo_title":27,"seo_description":14,"update_tm":28,"read_time":29},118031,549758252649,"Ivy","https://ap-avatar.wpscdn.com/avatar/8000253669c5317157?_k=1778319167496531819",6,"Technology","pystacked - Stacking generalization and machine learning in Stata","pystacked implements stacked generalization for regression and binary classification by combining multiple supervised machine learners into a single predictive model. The command supports regularized regression, random forest, gradient boosted trees, support vector machines, and feed-forward neural nets via Python’s scikit-learn. It can also act as a regular machine-learning interface by fitting a single base learner, giving an easy, versatile programming bridge for scikit-learn algorithms in Stata.","The World's Largest Open Access Agricultural &Applied Economics Digital Library  \nThis document is discoverable and free to researchers across theglobe due to the work of AgEcon Search.  \nHelp ensure our sustainability.  \nGive to AgEcon Search  \nAgEcon Searchhttp://ageconsearch.umn.eduaesearch@umn.edu  \nPapers downloaded from AgEcon Search may be used for non-commercial purposes and personal study only.No other use,including posting to another Internet site,is permitted without permission from the copyrightowner(not AgEcon Search),or as allowed under the provisions of Fair Use,U.S.Copyright Act,Title 17U.S.C.  \nNo endorsement of AgEcon Search or its fundraising activities by the author(s)of the following work or theiremployer(s)is intended orimplied.  \npystacked:Stacking generalization and machinelearning in Stata  \nAchim AhrensChristian B.Hansen  \nETH ZürichUniversity of ChicagoZürich,SwitzerlandChicago,ILachim.ahrens@gess.ethz.chchristian.hansen@chicagobooth.edu  \nMark E.Schaffer  \nHeriot-Watt UniversityEdinburgh,U.K.  \nm.e.schaffer@hw.ac.uk  \nAbstract.The pystacked command implements stacked generalization (Wolpert,1992,Neural Networks 5:241-259)for regression and binary classification viaPython's scikit-learn.Stacking combines multiple supervised machine learners—the “base”or“level-0”learners—into one learner.The currently supported baselearners include regularized regression,random forest,gradient boosted trees,support vector machines,and feed-forward neural nets(multilayer perceptron).pystacked can also be used as a “regular”machine learning program to fit onebase learner and thus provides an easy-to-use application programming interfacefor scikit-learn's machine learning algorithms.  \nKeywords:st0731,pystacked,machine learning,stacked generalization,modelaveraging,Python,sci-kit learn  \n# 1 Introduction\n\nWhen faced with a new prediction or classification task,it is rarely obvious whichmachine learning algorithm is best suited.A common approach is to evaluate theperformance of a set of machine learners on a holdout partition of the data or via cross-validation and then select the machine learner that minimizes a chosen loss metric.However,this approach is incomplete because combining multiple learners into one finalprediction might lead to superior performance compared with each individual learner.This possibility motivates stacked generalization,or simply“stacking”(see Wolpert[1992]and Breiman [1996]).Stacking is a form of model averaging.Theoretical resultsin van der Laan,Polley,and Hubbard (2007)support the use of stacking because itperforms asymptotically at least as well as the best-performing individual learner aslong as the number of base learners is not too large.  \nIn this article,we introduce pystacked,a command for stacking regression and bi-nary classification in Stata.pystacked allows users to fit multiple machine learningalgorithms via Python's scikit-learn(Pedregosa et al.2011;Buitinck et al.2013)and combine these into one final prediction as a weighted average of individual pre-  \npystacked  \ndictions.pystacked adds to the growing number of programs for machine learningin Stata,including lassopack for regularized regression(Ahrens,Hansen,and Schaffer2020),rforest for random forests(Schonlau and Zou 2020),and svm for support vectormachines(Guenther and Schonlau 2016,2018).Similarly to pystacked,Cerulli(2022)and Droste(2022)provide an interface to scikit-learn in Stata.mlrtime allows Statausers to make use of R's parsnip machine learning library(Huntington-Klein 2021).pystacked differs from these in that it is,to our knowledge,the first to make stackingavailable to Stata users.Furthermore,pystacked can also be used to fit one machinelearner and thus provides an easy-to-use and versatile application programming interfaceto scikit-learn's machine learning algorithms.  \nStacking is widely used in applied predictive modeling in many disciplines—for ex-ample,predicting mortality(Hwangbo et al.2022),bankruptcy fi","cbCaipe1uaowWsQG","https://ap.wps.com/l/cbCaipe1uaowWsQG","pdf",5045745,1,24,"English","en",105,"# 1 Introduction\n## Motivation and related work\n# 2 Methodology\n## Stacking for regression and binary classification\n# 3 Program features\n# 4 Examples","[{\"question\":\"What is stacked generalization (stacking) used for in pystacked?\",\"answer\":\"It combines several supervised base learners into one final weighted-average predictor, aiming to match or outperform the best individual learner asymptotically.\"},{\"question\":\"Which base learners are supported by pystacked?\",\"answer\":\"pystacked supports regularized regression, random forest, gradient boosted trees, support vector machines, and feed-forward neural nets (multilayer perceptron).\"},{\"question\":\"How does pystacked integrate scikit-learn with Stata?\",\"answer\":\"pystacked relies on Python’s scikit-learn and uses Stata’s Python integration (introduced in Stata 16.0), enabling users to fit models in scikit-learn and combine predictions for Stata workflows.\"}]","pystacked - Stacking generalization and machine learning in Stata | PDF",1785680900,60,{"code":4,"msg":31,"data":32},"ok",{"site_id":24,"language":23,"slug":33,"title":13,"keywords":34,"description":14,"schema_data":35,"social_meta":86,"head_meta":88,"extra_data":90,"updated_unix":28},"pystacked-stacking-generalization-and-machine-learning-in-stata","",{"@graph":36,"@context":85},[37,54,68],{"@type":38,"itemListElement":39},"BreadcrumbList",[40,44,48,51],{"item":41,"name":42,"@type":43,"position":20},"https://docshare.wps.com","Home","ListItem",{"item":45,"name":46,"@type":43,"position":47},"https://docshare.wps.com/document/","Document",2,{"item":49,"name":12,"@type":43,"position":50},"https://docshare.wps.com/document/technology/",3,{"item":52,"name":13,"@type":43,"position":53},"https://docshare.wps.com/document/pystacked-stacking-generalization-and-machine-learning-in-stata/118031/",4,{"url":52,"name":13,"@type":55,"author":56,"headline":13,"publisher":58,"fileFormat":61,"inLanguage":23,"description":14,"dateModified":62,"datePublished":62,"encodingFormat":61,"isAccessibleForFree":63,"interactionStatistic":64},"DigitalDocument",{"name":9,"@type":57},"Person",{"url":41,"name":59,"@type":60},"DocShare","Organization","application/pdf","2026-08-02",true,{"@type":65,"interactionType":66,"userInteractionCount":4},"InteractionCounter",{"@type":67},"ViewAction",{"@type":69,"mainEntity":70},"FAQPage",[71,77,81],{"name":72,"@type":73,"acceptedAnswer":74},"What is stacked generalization (stacking) used for in pystacked?","Question",{"text":75,"@type":76},"It combines several supervised base learners into one final weighted-average predictor, aiming to match or outperform the best individual learner asymptotically.","Answer",{"name":78,"@type":73,"acceptedAnswer":79},"Which base learners are supported by pystacked?",{"text":80,"@type":76},"pystacked supports regularized regression, random forest, gradient boosted trees, support vector machines, and feed-forward neural nets (multilayer perceptron).",{"name":82,"@type":73,"acceptedAnswer":83},"How does pystacked integrate scikit-learn with Stata?",{"text":84,"@type":76},"pystacked relies on Python’s scikit-learn and uses Stata’s Python integration (introduced in Stata 16.0), enabling users to fit models in scikit-learn and combine predictions for Stata workflows.","https://schema.org",{"og:url":52,"og:type":87,"og:title":13,"og:site_name":59,"og:description":14},"article",{"robots":89,"canonical":52},"index,follow",{"doc_id":7,"site_id":24},{"code":4,"msg":5,"data":92},[93,97,101,105,109,112,117,122,127,130,134],{"id":20,"doc_module":4,"doc_module_name":46,"category_name":94,"show_sort_weight":95,"slug":96},"Story & Novel",90,"story-novel",{"id":47,"doc_module":4,"doc_module_name":46,"category_name":98,"show_sort_weight":99,"slug":100},"Literature",80,"literature",{"id":53,"doc_module":4,"doc_module_name":46,"category_name":102,"show_sort_weight":103,"slug":104},"Exam",70,"exam",{"id":106,"doc_module":4,"doc_module_name":46,"category_name":107,"show_sort_weight":29,"slug":108},5,"Comic","comic",{"id":11,"doc_module":4,"doc_module_name":46,"category_name":12,"show_sort_weight":110,"slug":111},50,"technology",{"id":113,"doc_module":4,"doc_module_name":46,"category_name":114,"show_sort_weight":115,"slug":116},7,"Healthcare",40,"healthcare",{"id":118,"doc_module":4,"doc_module_name":46,"category_name":119,"show_sort_weight":120,"slug":121},8,"Research & Report",30,"research-report",{"id":123,"doc_module":4,"doc_module_name":46,"category_name":124,"show_sort_weight":125,"slug":126},9,"Religion & Spirituality",20,"religion-spirituality",{"id":125,"doc_module":4,"doc_module_name":46,"category_name":128,"show_sort_weight":125,"slug":129},"World Cup","world-cup",{"id":131,"doc_module":4,"doc_module_name":46,"category_name":132,"show_sort_weight":131,"slug":133},10,"Lifestyle","lifestyle",{"id":135,"doc_module":4,"doc_module_name":46,"category_name":136,"show_sort_weight":106,"slug":137},19,"General","general"]