Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/xskillscore_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ jobs:
run: |
python -m pip install --no-deps -e .
- name: Test notebooks in docs
# Route HTTP(S) to a dead proxy so notebooks that download data at build
# time fail here, not only intermittently on Read the Docs.
# intersphinx inventories then fail too, which only emits warnings.
env:
HTTP_PROXY: http://127.0.0.1:9
HTTPS_PROXY: http://127.0.0.1:9
NO_PROXY: ""
run: |
pushd docs
nbstripout source/*.ipynb
Expand Down
3 changes: 2 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@

autodoc_typehints = "none"

nbsphinx_timeout = 60
# per cell; Read the Docs builders are slower than GitHub Actions runners
nbsphinx_timeout = 300
nbsphinx_execute = "always"

autosummary_generate = True
Expand Down
4 changes: 2 additions & 2 deletions docs/source/quick-start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1336,9 +1336,9 @@
"source": [
"# resample with replacement in that one dimension\n",
"iterations = 100\n",
"%timeit f_r = xs.resampling.resample_iterations(f, iterations, 'member', replace=True)\n",
"%timeit -n 1 -r 3 f_r = xs.resampling.resample_iterations(f, iterations, 'member', replace=True)\n",
"# resample_iterations_idx is much (50x) faster because it involves no loops\n",
"%timeit f_r = xs.resampling.resample_iterations_idx(f, iterations, 'member', replace=True)\n",
"%timeit -n 1 -r 3 f_r = xs.resampling.resample_iterations_idx(f, iterations, 'member', replace=True)\n",
"# but both do the same resampling"
]
},
Expand Down
223 changes: 9 additions & 214 deletions docs/source/tabular-data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"import numpy as np\n",
"import pandas as pd\n",
"import xskillscore as xs\n",
"from sklearn.datasets import fetch_california_housing\n",
"from sklearn.metrics import mean_squared_error\n",
"\n",
"np.random.seed(seed=42)"
Expand All @@ -39,7 +38,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## California house prices dataset"
"## House prices dataset"
]
},
{
Expand All @@ -48,224 +47,20 @@
"source": [
"A small example is to take a dataset and evaluate the model according to a field (column).\n",
"\n",
"Load the California house prices dataset:"
"Create a synthetic house prices dataset, where the price `y` increases with the\n",
"average number of rooms `AveRooms`. The data is generated locally so the\n",
"documentation builds without downloading anything:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>MedInc</th>\n",
" <th>HouseAge</th>\n",
" <th>AveRooms</th>\n",
" <th>AveBedrms</th>\n",
" <th>Population</th>\n",
" <th>AveOccup</th>\n",
" <th>Latitude</th>\n",
" <th>Longitude</th>\n",
" <th>y</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>8.3252</td>\n",
" <td>41.0</td>\n",
" <td>7.0</td>\n",
" <td>1.023810</td>\n",
" <td>322.0</td>\n",
" <td>2.555556</td>\n",
" <td>37.88</td>\n",
" <td>-122.23</td>\n",
" <td>4.526</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>8.3014</td>\n",
" <td>21.0</td>\n",
" <td>6.0</td>\n",
" <td>0.971880</td>\n",
" <td>2401.0</td>\n",
" <td>2.109842</td>\n",
" <td>37.86</td>\n",
" <td>-122.22</td>\n",
" <td>3.585</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>7.2574</td>\n",
" <td>52.0</td>\n",
" <td>8.0</td>\n",
" <td>1.073446</td>\n",
" <td>496.0</td>\n",
" <td>2.802260</td>\n",
" <td>37.85</td>\n",
" <td>-122.24</td>\n",
" <td>3.521</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>5.6431</td>\n",
" <td>52.0</td>\n",
" <td>6.0</td>\n",
" <td>1.073059</td>\n",
" <td>558.0</td>\n",
" <td>2.547945</td>\n",
" <td>37.85</td>\n",
" <td>-122.25</td>\n",
" <td>3.413</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>3.8462</td>\n",
" <td>52.0</td>\n",
" <td>6.0</td>\n",
" <td>1.081081</td>\n",
" <td>565.0</td>\n",
" <td>2.181467</td>\n",
" <td>37.85</td>\n",
" <td>-122.25</td>\n",
" <td>3.422</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20635</th>\n",
" <td>1.5603</td>\n",
" <td>25.0</td>\n",
" <td>5.0</td>\n",
" <td>1.133333</td>\n",
" <td>845.0</td>\n",
" <td>2.560606</td>\n",
" <td>39.48</td>\n",
" <td>-121.09</td>\n",
" <td>0.781</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20636</th>\n",
" <td>2.5568</td>\n",
" <td>18.0</td>\n",
" <td>6.0</td>\n",
" <td>1.315789</td>\n",
" <td>356.0</td>\n",
" <td>3.122807</td>\n",
" <td>39.49</td>\n",
" <td>-121.21</td>\n",
" <td>0.771</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20637</th>\n",
" <td>1.7000</td>\n",
" <td>17.0</td>\n",
" <td>5.0</td>\n",
" <td>1.120092</td>\n",
" <td>1007.0</td>\n",
" <td>2.325635</td>\n",
" <td>39.43</td>\n",
" <td>-121.22</td>\n",
" <td>0.923</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20638</th>\n",
" <td>1.8672</td>\n",
" <td>18.0</td>\n",
" <td>5.0</td>\n",
" <td>1.171920</td>\n",
" <td>741.0</td>\n",
" <td>2.123209</td>\n",
" <td>39.43</td>\n",
" <td>-121.32</td>\n",
" <td>0.847</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20639</th>\n",
" <td>2.3886</td>\n",
" <td>16.0</td>\n",
" <td>5.0</td>\n",
" <td>1.162264</td>\n",
" <td>1387.0</td>\n",
" <td>2.616981</td>\n",
" <td>39.37</td>\n",
" <td>-121.24</td>\n",
" <td>0.894</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>20640 rows × 9 columns</p>\n",
"</div>"
],
"text/plain": [
" MedInc HouseAge AveRooms AveBedrms Population AveOccup Latitude \\\n",
"0 8.3252 41.0 7.0 1.023810 322.0 2.555556 37.88 \n",
"1 8.3014 21.0 6.0 0.971880 2401.0 2.109842 37.86 \n",
"2 7.2574 52.0 8.0 1.073446 496.0 2.802260 37.85 \n",
"3 5.6431 52.0 6.0 1.073059 558.0 2.547945 37.85 \n",
"4 3.8462 52.0 6.0 1.081081 565.0 2.181467 37.85 \n",
"... ... ... ... ... ... ... ... \n",
"20635 1.5603 25.0 5.0 1.133333 845.0 2.560606 39.48 \n",
"20636 2.5568 18.0 6.0 1.315789 356.0 3.122807 39.49 \n",
"20637 1.7000 17.0 5.0 1.120092 1007.0 2.325635 39.43 \n",
"20638 1.8672 18.0 5.0 1.171920 741.0 2.123209 39.43 \n",
"20639 2.3886 16.0 5.0 1.162264 1387.0 2.616981 39.37 \n",
"\n",
" Longitude y \n",
"0 -122.23 4.526 \n",
"1 -122.22 3.585 \n",
"2 -122.24 3.521 \n",
"3 -122.25 3.413 \n",
"4 -122.25 3.422 \n",
"... ... ... \n",
"20635 -121.09 0.781 \n",
"20636 -121.21 0.771 \n",
"20637 -121.22 0.923 \n",
"20638 -121.32 0.847 \n",
"20639 -121.24 0.894 \n",
"\n",
"[20640 rows x 9 columns]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"housing = fetch_california_housing(as_frame=True)\n",
"df = housing.frame\n",
"df[\"AveRooms\"] = df[\"AveRooms\"].round()\n",
"df = df.rename(columns={\"MedHouseVal\": \"y\"})\n",
"n = 20_000\n",
"df = pd.DataFrame({\"AveRooms\": np.random.randint(1, 11, size=n).astype(float)})\n",
"df[\"y\"] = 0.5 + 0.3 * df[\"AveRooms\"] + np.random.gamma(2.0, 0.5, size=n)\n",
"df"
]
},
Expand Down
Loading