The $\texttt{torch-choice}$ is an open-source library for flexible, fast choice modeling with Python and PyTorch. $\texttt{torch-choice}$ provides a $\texttt{ChoiceDataset}$ data structure to manage databases flexibly and memory-efficiently. The paper demonstrates constructing a $\texttt{ChoiceDataset}$ from databases of various formats and functionalities of $\texttt{ChoiceDataset}$. The package implements two widely used models, namely the multinomial logit and nested logit models, and supports regularization during model estimation. The package incorporates the option to take advantage of GPUs for estimation, allowing it to scale to massive datasets while being computationally efficient. Models can be initialized using either R-style formula strings or Python dictionaries. We conclude with a comparison of the computational efficiencies of $\texttt{torch-choice}$ and $\texttt{mlogit}$ in R as (1) the number of observations increases, (2) the number of covariates increases, and (3) the expansion of item sets. Finally, we demonstrate the scalability of $\texttt{torch-choice}$ on large-scale datasets.
翻译:$\texttt{torch-choice}$是一个开源库,用于通过Python和PyTorch实现灵活、快速的选择建模。该库提供$\texttt{ChoiceDataset}$数据结构,以灵活且内存高效的方式管理数据库。本文演示了如何从多种格式的数据库构建$\texttt{ChoiceDataset}$,并展示了该数据结构的功能。该工具包实现了两种广泛应用的模型——多项logit模型和嵌套logit模型,并支持模型估计过程中的正则化。该工具包集成了利用GPU进行估计的选项,使其在保持计算效率的同时能够扩展至大规模数据集。模型可通过R语言风格公式字符串或Python字典进行初始化。我们最终从以下三个方面比较了$\texttt{torch-choice}$与R语言中$\texttt{mlogit}$的计算效率:(1)观测值数量增加时,(2)协变量数量增加时,(3)项目集扩展时。最后,我们在大规模数据集上展示了$\texttt{torch-choice}$的可扩展性。