資料集¶
如需目前可用的資料集和使用說明清單,請參閱資料集頁面。
授權條款¶
要考慮納入 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。編輯 nile/data.py,填入 COPYRIGHT、TITLE、SOURCE、DESCRSHORT、DESCLONG 和 NOTE 的字串。
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 函數的 docstring,以指定將載入哪個資料集。同時編輯 endog 和 exog 屬性的路徑和索引。在 nile 的案例中,沒有 exog,因此不使用任何參考 exog 的內容。year 變數也未使用。
步驟 6:編輯 datasets/__init__.py 以匯入目錄。
就是這樣!結果可以在這裡找到,以供參考。
上次更新:2024 年 10 月 03 日