-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
198 lines (177 loc) · 15.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Spatial Resampling Infrastructure • spatialsample</title>
<script src="deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet">
<script src="deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="deps/Source_Sans_Pro-0.4.9/font.css" rel="stylesheet">
<link href="deps/Source_Code_Pro-0.4.9/font.css" rel="stylesheet">
<link href="deps/font-awesome-6.4.2/css/all.min.css" rel="stylesheet">
<link href="deps/font-awesome-6.4.2/css/v4-shims.min.css" rel="stylesheet">
<script src="deps/headroom-0.11.0/headroom.min.js"></script><script src="deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="deps/search-1.0.0/fuse.min.js"></script><script src="deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><script src="pkgdown.js"></script><meta property="og:title" content="Spatial Resampling Infrastructure">
<meta name="description" content="Functions and classes for spatial resampling to use with the rsample package, such as spatial cross-validation (Brenning, 2012) <doi:10.1109/IGARSS.2012.6352393>. The scope of rsample and spatialsample is to provide the basic building blocks for creating and analyzing resamples of a spatial data set, but neither package includes functions for modeling or computing statistics. The resampled spatial data sets created by spatialsample do not contain much overhead in memory.">
<meta property="og:description" content="Functions and classes for spatial resampling to use with the rsample package, such as spatial cross-validation (Brenning, 2012) <doi:10.1109/IGARSS.2012.6352393>. The scope of rsample and spatialsample is to provide the basic building blocks for creating and analyzing resamples of a spatial data set, but neither package includes functions for modeling or computing statistics. The resampled spatial data sets created by spatialsample do not contain much overhead in memory.">
<meta property="og:image" content="https://spatialsample.tidymodels.org/logo.png">
<script defer data-domain="spatialsample.tidymodels.org,all.tidymodels.org" src="https://plausible.io/js/plausible.js"></script>
</head>
<body>
<a href="#container" class="visually-hidden-focusable">Skip to content</a>
<nav class="navbar navbar-expand-lg fixed-top bg-none" data-bs-theme="light" aria-label="Site navigation"><div class="container">
<a class="navbar-brand me-2" href="index.html">spatialsample</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Released version">0.6.0</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbar" class="collapse navbar-collapse ms-3">
<ul class="navbar-nav me-auto">
<li class="nav-item"><a class="nav-link" href="articles/spatialsample.html">Get started</a></li>
<li class="nav-item"><a class="nav-link" href="reference/index.html">Reference</a></li>
<li class="nav-item dropdown">
<button class="nav-link dropdown-toggle" type="button" id="dropdown-articles" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">Articles</button>
<ul class="dropdown-menu" aria-labelledby="dropdown-articles">
<li><a class="dropdown-item" href="articles/buffering.html">Buffering</a></li>
</ul>
</li>
<li class="nav-item"><a class="nav-link" href="news/index.html">Changelog</a></li>
</ul>
<ul class="navbar-nav">
<li class="nav-item"><form class="form-inline" role="search">
<input class="form-control" type="search" name="search-input" id="search-input" autocomplete="off" aria-label="Search site" placeholder="Search for" data-search-index="search.json">
</form></li>
<li class="nav-item"><a class="external-link nav-link" href="https://github.com/tidymodels/spatialsample/" aria-label="GitHub"><span class="fa fab fa-github fa-lg"></span></a></li>
</ul>
</div>
</div>
</nav><div class="container template-home" id="container">
<div class="row">
<main id="main" class="col-md-9"><div class="section level1">
<div class="page-header">
<img src="logo.png" class="logo" alt=""><h1 id="spatialsample-">spatialsample
<a class="anchor" aria-label="anchor" href="#spatialsample-"></a>
</h1>
</div>
<!-- badges: start -->
<div class="section level2">
<h2 id="introduction">Introduction<a class="anchor" aria-label="anchor" href="#introduction"></a>
</h2>
<p>The goal of spatialsample is to provide functions and classes for spatial resampling to use with <a href="https://rsample.tidymodels.org/" class="external-link">rsample</a>, including:</p>
<ul>
<li><a href="https://doi.org/10.1109/IGARSS.2012.6352393" class="external-link">spatial clustering cross-validation</a></li>
<li><a href="https://doi.org/10.1111/ecog.02881" class="external-link">spatial block cross-validation</a></li>
<li><a href="https://doi.org/10.1111/geb.12161" class="external-link">spatially buffered cross-validation</a></li>
<li><a href="https://doi.org/10.1016/j.envsoft.2017.12.001" class="external-link">leave-location-out cross-validation</a></li>
</ul>
<p>Like <a href="https://rsample.tidymodels.org/" class="external-link">rsample</a>, spatialsample provides building blocks for creating and analyzing resamples of a spatial data set but does not include code for modeling or computing statistics. The resampled data sets created by spatialsample are efficient and do not have much memory overhead.</p>
</div>
<div class="section level2">
<h2 id="installation">Installation<a class="anchor" aria-label="anchor" href="#installation"></a>
</h2>
<p>You can install the released version of spatialsample from <a href="https://CRAN.R-project.org" class="external-link">CRAN</a> with:</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html" class="external-link">install.packages</a></span><span class="op">(</span><span class="st">"spatialsample"</span><span class="op">)</span></span></code></pre></div>
<p>And the development version from <a href="https://github.com/" class="external-link">GitHub</a> with:</p>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># install.packages("pak")</span></span>
<span><span class="fu">pak</span><span class="fu">::</span><span class="fu"><a href="https://pak.r-lib.org/reference/pak.html" class="external-link">pak</a></span><span class="op">(</span><span class="st">"tidymodels/spatialsample"</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level2">
<h2 id="example">Example<a class="anchor" aria-label="anchor" href="#example"></a>
</h2>
<p>The most straightforward spatial resampling strategy is <code><a href="reference/spatial_clustering_cv.html">spatial_clustering_cv()</a></code>, which uses k-means clustering to identify cross-validation folds:</p>
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/tidymodels/spatialsample" class="external-link">spatialsample</a></span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/Random.html" class="external-link">set.seed</a></span><span class="op">(</span><span class="fl">1234</span><span class="op">)</span></span>
<span><span class="va">folds</span> <span class="op"><-</span> <span class="fu"><a href="reference/spatial_clustering_cv.html">spatial_clustering_cv</a></span><span class="op">(</span><span class="va">boston_canopy</span>, v <span class="op">=</span> <span class="fl">5</span><span class="op">)</span></span>
<span></span>
<span><span class="va">folds</span></span>
<span><span class="co">#> # 5-fold spatial cross-validation </span></span>
<span><span class="co">#> # A tibble: 5 × 2</span></span>
<span><span class="co">#> splits id </span></span>
<span><span class="co">#> <list> <chr></span></span>
<span><span class="co">#> 1 <split [604/78]> Fold1</span></span>
<span><span class="co">#> 2 <split [595/87]> Fold2</span></span>
<span><span class="co">#> 3 <split [524/158]> Fold3</span></span>
<span><span class="co">#> 4 <split [490/192]> Fold4</span></span>
<span><span class="co">#> 5 <split [515/167]> Fold5</span></span></code></pre></div>
<p>In this example, the <code>boston_canopy</code> data on tree cover in Boston, MA is resampled with <code>v = 5</code>; notice that the resulting partitions do not contain an equal number of observations.</p>
<p>In addition to resampling algorithms, spatialsample provides methods to visualize resamples using <a href="https://ggplot2.tidyverse.org/" class="external-link">ggplot2</a> through the <code><a href="https://ggplot2.tidyverse.org/reference/autoplot.html" class="external-link">autoplot()</a></code> function:</p>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/autoplot.html" class="external-link">autoplot</a></span><span class="op">(</span><span class="va">folds</span><span class="op">)</span></span></code></pre></div>
<p><img src="reference/figures/README-2022-06-12_boston_static-1.png" width="100%"></p>
<p>We can use the same function to visualize each fold separately:</p>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://purrr.tidyverse.org/" class="external-link">purrr</a></span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://purrr.tidyverse.org/reference/map.html" class="external-link">walk</a></span><span class="op">(</span><span class="va">folds</span><span class="op">$</span><span class="va">splits</span>, <span class="kw">function</span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/base/print.html" class="external-link">print</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/autoplot.html" class="external-link">autoplot</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
<p><img src="reference/figures/README-2022-06-12_boston-anim-.gif" width="100%"></p>
<p>So far, we’ve only scratched the surface of the functionality spatialsample provides. For more information, check out the <a href="https://spatialsample.tidymodels.org/articles/spatialsample.html">Getting Started</a> documentation!</p>
</div>
<div class="section level2">
<h2 id="contributing">Contributing<a class="anchor" aria-label="anchor" href="#contributing"></a>
</h2>
<p>This project is released with a <a href="https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html" class="external-link">Contributor Code of Conduct</a>. By contributing to this project, you agree to abide by its terms.</p>
<ul>
<li><p>For questions and discussions about tidymodels packages, modeling, and machine learning, please <a href="https://forum.posit.co/new-topic?category_id=15&tags=tidymodels,question" class="external-link">post on RStudio Community</a>.</p></li>
<li><p>If you think you have encountered a bug, please <a href="https://github.com/tidymodels/rules/issues" class="external-link">submit an issue</a>.</p></li>
<li><p>Either way, learn how to create and share a <a href="https://reprex.tidyverse.org/articles/articles/learn-reprex.html" class="external-link">reprex</a> (a minimal, reproducible example), to clearly communicate about your code.</p></li>
<li><p>Check out further details on <a href="https://www.tidymodels.org/contribute/" class="external-link">contributing guidelines for tidymodels packages</a> and <a href="https://www.tidymodels.org/help/" class="external-link">how to get help</a>.</p></li>
</ul>
</div>
</div>
</main><aside class="col-md-3"><div class="links">
<h2 data-toc-skip>Links</h2>
<ul class="list-unstyled">
<li><a href="https://cloud.r-project.org/package=spatialsample" class="external-link">View on CRAN</a></li>
<li><a href="https://github.com/tidymodels/spatialsample/" class="external-link">Browse source code</a></li>
<li><a href="https://github.com/tidymodels/spatialsample/issues" class="external-link">Report a bug</a></li>
</ul>
</div>
<div class="license">
<h2 data-toc-skip>License</h2>
<ul class="list-unstyled">
<li><a href="LICENSE.html">Full license</a></li>
<li><small><a href="https://opensource.org/licenses/mit-license.php" class="external-link">MIT</a> + file <a href="LICENSE-text.html">LICENSE</a></small></li>
</ul>
</div>
<div class="community">
<h2 data-toc-skip>Community</h2>
<ul class="list-unstyled">
<li><a href="CONTRIBUTING.html">Contributing guide</a></li>
<li><a href="CODE_OF_CONDUCT.html">Code of conduct</a></li>
</ul>
</div>
<div class="citation">
<h2 data-toc-skip>Citation</h2>
<ul class="list-unstyled">
<li><a href="authors.html#citation">Citing spatialsample</a></li>
</ul>
</div>
<div class="developers">
<h2 data-toc-skip>Developers</h2>
<ul class="list-unstyled">
<li>
<a href="https://www.mm218.dev/" class="external-link">Michael Mahoney</a> <br><small class="roles"> Author, maintainer </small> <a href="https://orcid.org/0000-0003-2402-304X" target="orcid.widget" aria-label="ORCID" class="external-link"><span class="fab fa-orcid orcid" aria-hidden="true"></span></a> </li>
<li>
<a href="https://juliasilge.com/" class="external-link">Julia Silge</a> <br><small class="roles"> Author </small> <a href="https://orcid.org/0000-0002-3671-836X" target="orcid.widget" aria-label="ORCID" class="external-link"><span class="fab fa-orcid orcid" aria-hidden="true"></span></a> </li>
<li>
<a href="https://www.posit.co" class="external-link"><img src="https://www.tidyverse.org/posit-logo.svg" alt="Posit" height="16" width="62" style="margin-bottom: 3px;"></a> <br><small class="roles"> Copyright holder, funder </small> </li>
</ul>
</div>
</aside>
</div>
</div>
<footer><div class="container">
<div class="pkgdown-footer-left">
<p>Developed by <a href="https://www.mm218.dev/" class="external-link">Michael Mahoney</a>, <a href="https://juliasilge.com/" class="external-link">Julia Silge</a>, <a href="https://www.posit.co" class="external-link"><img src="https://www.tidyverse.org/posit-logo.svg" alt="Posit" height="16" width="62" style="margin-bottom: 3px;"></a>.</p>
</div>
<div class="pkgdown-footer-right">
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.1.1.</p>
</div>
</div></footer>
</body>
</html>