📄 cvsegments.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Generate segments for cross-validation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../R.css">
</head><body>
<table width="100%" summary="page for cvsegments {pls}"><tr><td>cvsegments {pls}</td><td align="right">R Documentation</td></tr></table>
<h2>Generate segments for cross-validation</h2>
<h3>Description</h3>
<p>
The function generates a list of segments for cross-validation.
Random, consecutive and interleaved segments can be produced.
</p>
<h3>Usage</h3>
<pre>
cvsegments(N, k, length.seg = ceiling(N/k),
type = c("random", "consecutive", "interleaved"))
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>N</code></td>
<td>
Integer. The number of objects in the data set.</td></tr>
<tr valign="top"><td><code>k</code></td>
<td>
Integer. The number of segments to return.</td></tr>
<tr valign="top"><td><code>length.seg</code></td>
<td>
Integer. The length of the segments. If
given, it overrides <code>k</code>.</td></tr>
<tr valign="top"><td><code>type</code></td>
<td>
One of <code>"random"</code>, <code>"consecutive"</code> and
<code>"interleaved"</code>. The type of segments to generate. Default is
<code>"random"</code>.</td></tr>
</table>
<h3>Details</h3>
<p>
If <code>length.seg</code> is specified, it is used to calculate the number of
segments to generate. Otherwise <code>k</code> must be specified. If
<i>k*length.seg <> N</i>, the
<i>k*length.seg - N</i> last segments will contain only
<i>length.seg - 1</i> indices.
</p>
<p>
If <code>type</code> is <code>"random"</code>, the indices are allocated to
segments in random order. If it is <code>"consecutive"</code>, the first
segment will contain the first <i>length.seg</i> indices, and so on.
If <code>type</code> is <code>"interleaved"</code>, the first segment will contain
the indices <i>1, length.seg+1, 2*lenght.seg+1, ...,
(k-1)*length.seg+1</i>, and so on.
</p>
<h3>Value</h3>
<p>
A list of vectors. Each vector contains the indices for one segment.
The attribute <code>"incomplete"</code> contains the number of incomplete
segments, and the attribute <code>"type"</code> contains the type of segments.</p>
<h3>Author(s)</h3>
<p>
Bj鴕n-Helge Mevik and Ron Wehrens
</p>
<h3>Examples</h3>
<pre>
## Segments for 10-fold randomised cross-validation:
cvsegments(100, 10)
## Segments with four objects, taken consecutive:
cvsegments(60, length.seg = 4, type = "cons")
## Incomplete segments
segs <- cvsegments(50, length.seg = 3)
attr(segs, "incomplete")
## Leave-one-out cross-validation:
cvsegments(100, 100)
## Leave-one-out with variable/unknown data set size n:
n <- 50
cvsegments(n, length.seg = 1)
</pre>
<hr><div align="center">[Package <em>pls</em> version 2.0-1 <a href="00Index.html">Index]</a></div>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -