From: Debian Science Maintainers Date: Tue, 28 Jan 2020 22:29:29 +0000 (+0000) Subject: Use cached datasets for building documentation/examples X-Git-Tag: archive/raspbian/0.11.1-2+rpi1~2^2~18 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7816f13bddb3e7c6a9caa6b0018e6ffb69df638c;p=statsmodels.git Use cached datasets for building documentation/examples Also remove a download that isn't actually used in that example. This allows at least some of the examples to be built in an offline environment such as a Debian buildd. The cached data is extracted from R packages by debian/datasets/*. Author: Diane Trout , Rebecca N. Palmer Forwarded: not-needed Gbp-Pq: Name use-cached-datasets --- diff --git a/docs/source/contingency_tables.rst b/docs/source/contingency_tables.rst index a4927eb..cf66652 100644 --- a/docs/source/contingency_tables.rst +++ b/docs/source/contingency_tables.rst @@ -49,7 +49,7 @@ contingency table cell counts: import pandas as pd import statsmodels.api as sm - df = sm.datasets.get_rdataset("Arthritis", "vcd").data + df = sm.datasets.get_rdataset("Arthritis", "vcd", cache=True).data tab = pd.crosstab(df['Treatment'], df['Improved']) tab = tab.loc[:, ["None", "Some", "Marked"]] @@ -184,7 +184,7 @@ contingency table. .. ipython:: python - df = sm.datasets.get_rdataset("VisualAcuity", "vcd").data + df = sm.datasets.get_rdataset("VisualAcuity", "vcd", cache=True).data df = df.loc[df.gender == "female", :] tab = df.set_index(['left', 'right']) del tab["gender"] diff --git a/docs/source/datasets/index.rst b/docs/source/datasets/index.rst index 92cefb0..f66dae4 100644 --- a/docs/source/datasets/index.rst +++ b/docs/source/datasets/index.rst @@ -30,7 +30,7 @@ The `Rdatasets project `__ give .. ipython:: python import statsmodels.api as sm - duncan_prestige = sm.datasets.get_rdataset("Duncan", "carData") + duncan_prestige = sm.datasets.get_rdataset("Duncan", "carData", cache=True) print(duncan_prestige.__doc__) duncan_prestige.data.head(5) diff --git a/docs/source/duration.rst b/docs/source/duration.rst index 66ae9a2..f861f97 100644 --- a/docs/source/duration.rst +++ b/docs/source/duration.rst @@ -44,7 +44,7 @@ We fit the survival distribution only for the female subjects. import statsmodels.api as sm - data = sm.datasets.get_rdataset("flchain", "survival").data + data = sm.datasets.get_rdataset("flchain", "survival", cache=True).data df = data.loc[data.sex == "F", :] sf = sm.SurvfuncRight(df["futime"], df["death"]) @@ -157,7 +157,7 @@ Examples import statsmodels.api as sm import statsmodels.formula.api as smf - data = sm.datasets.get_rdataset("flchain", "survival").data + data = sm.datasets.get_rdataset("flchain", "survival", cache=True).data del data["chapter"] data = data.dropna() data["lam"] = data["lambda"] diff --git a/docs/source/example_formulas.rst b/docs/source/example_formulas.rst index 0275994..b950e4d 100644 --- a/docs/source/example_formulas.rst +++ b/docs/source/example_formulas.rst @@ -47,7 +47,7 @@ and list-wise delete to remove missing observations: .. ipython:: python - df = sm.datasets.get_rdataset("Guerry", "HistData").data + df = sm.datasets.get_rdataset("Guerry", "HistData", cache=True).data df = df[['Lottery', 'Literacy', 'Wealth', 'Region']].dropna() df.head() diff --git a/docs/source/gee.rst b/docs/source/gee.rst index bf45eb7..b06326c 100644 --- a/docs/source/gee.rst +++ b/docs/source/gee.rst @@ -24,7 +24,7 @@ within clusters using data on epilepsy seizures. import statsmodels.api as sm import statsmodels.formula.api as smf - data = sm.datasets.get_rdataset('epil', package='MASS').data + data = sm.datasets.get_rdataset('epil', package='MASS', cache=True).data fam = sm.families.Poisson() ind = sm.cov_struct.Exchangeable() diff --git a/docs/source/gettingstarted.rst b/docs/source/gettingstarted.rst index e62a1b4..ff27ab6 100644 --- a/docs/source/gettingstarted.rst +++ b/docs/source/gettingstarted.rst @@ -44,7 +44,7 @@ We could download the file locally and then load it using ``read_csv``, but .. ipython:: python - df = sm.datasets.get_rdataset("Guerry", "HistData").data + df = sm.datasets.get_rdataset("Guerry", "HistData", cache=True).data The `Input/Output doc page `_ shows how to import from various other formats. diff --git a/docs/source/index.rst b/docs/source/index.rst index d75da98..01b0170 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -25,7 +25,7 @@ example using ordinary least squares: import statsmodels.formula.api as smf # Load data - dat = sm.datasets.get_rdataset("Guerry", "HistData").data + dat = sm.datasets.get_rdataset("Guerry", "HistData", cache=True).data # Fit regression model (using the natural log of one of the regressors) results = smf.ols('Lottery ~ Literacy + np.log(Pop1831)', data=dat).fit() diff --git a/docs/source/mixed_linear.rst b/docs/source/mixed_linear.rst index 4e50a40..ef3d1f0 100644 --- a/docs/source/mixed_linear.rst +++ b/docs/source/mixed_linear.rst @@ -83,7 +83,7 @@ Examples import statsmodels.api as sm import statsmodels.formula.api as smf - data = sm.datasets.get_rdataset("dietox", "geepack").data + data = sm.datasets.get_rdataset("dietox", "geepack", cache=True).data md = smf.mixedlm("Weight ~ Time", data, groups=data["Pig"]) mdf = md.fit() diff --git a/docs/source/release/version0.6.rst b/docs/source/release/version0.6.rst index 53eda46..e735b01 100644 --- a/docs/source/release/version0.6.rst +++ b/docs/source/release/version0.6.rst @@ -41,7 +41,7 @@ covariates. import statsmodels.api as sm import statsmodels.formula.api as smf - data = sm.datasets.get_rdataset("epil", "MASS").data + data = sm.datasets.get_rdataset("epil", "MASS", cache=True).data md = smf.gee("y ~ age + trt + base", "subject", data, cov_struct=sm.cov_struct.Independence(), diff --git a/examples/notebooks/markov_regression.ipynb b/examples/notebooks/markov_regression.ipynb index 1357783..357724a 100644 --- a/examples/notebooks/markov_regression.ipynb +++ b/examples/notebooks/markov_regression.ipynb @@ -28,11 +28,7 @@ "import pandas as pd\n", "import statsmodels.api as sm\n", "import matplotlib.pyplot as plt\n", - "\n", - "# NBER recessions\n", - "from pandas_datareader.data import DataReader\n", - "from datetime import datetime\n", - "usrec = DataReader('USREC', 'fred', start=datetime(1947, 1, 1), end=datetime(2013, 4, 1))" + "from datetime import datetime\n" ] }, { diff --git a/examples/notebooks/mixed_lm_example.ipynb b/examples/notebooks/mixed_lm_example.ipynb index 6f40219..7084d74 100644 --- a/examples/notebooks/mixed_lm_example.ipynb +++ b/examples/notebooks/mixed_lm_example.ipynb @@ -68,7 +68,7 @@ "metadata": {}, "outputs": [], "source": [ - "data = sm.datasets.get_rdataset('dietox', 'geepack').data\n", + "data = sm.datasets.get_rdataset('dietox', 'geepack', cache=True).data\n", "md = smf.mixedlm(\"Weight ~ Time\", data, groups=data[\"Pig\"])\n", "mdf = md.fit()\n", "print(mdf.summary())" @@ -202,7 +202,7 @@ "metadata": {}, "outputs": [], "source": [ - "data = sm.datasets.get_rdataset(\"Sitka\", \"MASS\").data\n", + "data = sm.datasets.get_rdataset(\"Sitka\", \"MASS\", cache=True).data\n", "endog = data[\"size\"]\n", "data[\"Intercept\"] = 1\n", "exog = data[[\"Intercept\", \"Time\"]]" diff --git a/examples/notebooks/regression_diagnostics.ipynb b/examples/notebooks/regression_diagnostics.ipynb index 140eafc..df7f6e8 100644 --- a/examples/notebooks/regression_diagnostics.ipynb +++ b/examples/notebooks/regression_diagnostics.ipynb @@ -52,8 +52,8 @@ "import matplotlib.pyplot as plt\n", "\n", "# Load data\n", - "url = 'https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/HistData/Guerry.csv'\n", - "dat = pd.read_csv(url)\n", + "import statsmodels.datasets\n", + "dat = statsmodels.datasets.get_rdataset(\"Guerry\", \"HistData\", cache=True).data\n", "\n", "# Fit regression model (using the natural log of one of the regressors)\n", "results = smf.ols('Lottery ~ Literacy + np.log(Pop1831)', data=dat).fit()\n",