数据集¶
有关当前可用数据集和使用说明的列表,请参阅 数据集页面。
许可证¶
要被考虑包含在statsmodels中,数据集必须是公共领域的,在BSD兼容许可证下分发,或者我们必须获得原始作者的许可。
添加数据集:一个示例¶
尼罗河数据测量了1871年至1970年间阿斯旺的尼罗河流量。数据摘自Cobb(1978)的论文。
步骤1:创建一个目录 datasets/nile/
步骤 2: 添加 datasets/nile/nile.csv 和一个新文件 datasets/__init__.py,其中包含
from data import *
步骤3:如果nile.csv是原始数据的转换/清理版本,请创建一个nile/src目录,并在其中包含原始的原始数据。在nile的情况下,此步骤不是必需的。
步骤4:将datasets/template_data.py复制到nile/data.py。通过填写COPYRIGHT、TITLE、SOURCE、DESCRSHORT、DESCLONG和NOTE的字符串来编辑nile/data.py。
COPYRIGHT = """This is public domain."""
TITLE = """Nile River Data"""
SOURCE = """
Cobb, G.W. 1978. The Problem of the Nile: Conditional Solution to a Changepoint
Problem. Biometrika. 65.2, 243-251,
"""
DESCRSHORT = """Annual Nile River Volume at Aswan, 1871-1970""
DESCRLONG = """Annual Nile River Volume at Aswan, 1871-1970. The units of
measurement are 1e9 m^{3}, and there is an apparent changepoint near 1898."""
NOTE = """
Number of observations: 100
Number of variables: 2
Variable name definitions:
year - Year of observation
volume - Nile River volume at Aswan
The data were originally used in Cobb (1987, See SOURCE). The author
acknowledges that the data were originally compiled from various sources by
Dr. Barbara Bell, Center for Astrophysics, Cambridge, Massachusetts. The data
set is also used as an example in many textbooks and software packages.
"""
步骤5: 编辑data.py文件中load函数的文档字符串,以指定将加载哪个数据集。同时编辑路径和endog和exog属性的索引。在nile情况下,没有exog,因此所有引用exog的内容都不使用。year变量也不使用。
步骤6:编辑datasets/__init__.py以导入目录。
就是这样!结果可以在这里找到以供参考。
Last update:
Oct 16, 2024