⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 predict.nnet.html

📁 本程序是基于linux系统下c++代码
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Predict New Examples by a Trained Neural Net</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 predict.nnet {nnet}"><tr><td>predict.nnet {nnet}</td><td align="right">R Documentation</td></tr></table>
<h2>Predict New Examples by a Trained Neural Net</h2>


<h3>Description</h3>

<p>
Predict new examples by a trained neural net.
</p>


<h3>Usage</h3>

<pre>
## S3 method for class 'nnet':
predict(object, newdata, type = c("raw","class"), ...)
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>object</code></td>
<td>
an object of class <code>nnet</code> as  returned by <code>nnet</code>.
</td></tr>
<tr valign="top"><td><code>newdata</code></td>
<td>
matrix or data frame of test examples. A vector is considered to be
a row vector comprising a single case.
</td></tr>
<tr valign="top"><td><code>type</code></td>
<td>
Type of output
</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
arguments passed to or from other methods.
</td></tr>
</table>

<h3>Details</h3>

<p>
This function is a method for the generic function
<code>predict()</code> for class <code>"nnet"</code>.
It can be invoked by calling <code>predict(x)</code> for an
object <code>x</code> of the appropriate class, or directly by
calling <code>predict.nnet(x)</code> regardless of the
class of the object.
</p>


<h3>Value</h3>

<p>
If <code>type = "raw"</code>, the matrix of values returned by the trained network;
if <code>type = "class"</code>, the corresponding class (which is probably only
useful if the net was generated by <code>nnet.formula</code>).</p>

<h3>References</h3>

<p>
Ripley, B. D. (1996)
<EM>Pattern Recognition and Neural Networks.</EM> Cambridge.
</p>
<p>
Venables, W. N. and Ripley, B. D. (2002)
<EM>Modern Applied Statistics with S.</EM> Fourth edition.  Springer.
</p>


<h3>See Also</h3>

<p>
<code><a href="nnet.html">nnet</a></code>, <code><a href="which.is.max.html">which.is.max</a></code>
</p>


<h3>Examples</h3>

<pre>
data(iris3)
# use half the iris data
ir &lt;- rbind(iris3[,,1], iris3[,,2], iris3[,,3])
targets &lt;- class.ind( c(rep("s", 50), rep("c", 50), rep("v", 50)) )
samp &lt;- c(sample(1:50,25), sample(51:100,25), sample(101:150,25))
ir1 &lt;- nnet(ir[samp,], targets[samp,],size = 2, rang = 0.1,
            decay = 5e-4, maxit = 200)
test.cl &lt;- function(true, pred){
        true &lt;- max.col(true)
        cres &lt;- max.col(pred)
        table(true, cres)
}
test.cl(targets[-samp,], predict(ir1, ir[-samp,]))

# or
ird &lt;- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]),
        species=factor(c(rep("s",50), rep("c", 50), rep("v", 50))))
ir.nn2 &lt;- nnet(species ~ ., data = ird, subset = samp, size = 2, rang = 0.1,
            decay = 5e-4, maxit = 200)
table(ird$species[-samp], predict(ir.nn2, ird[-samp,], type = "class"))
</pre>



<hr><div align="center">[Package <em>nnet</em> version 7.2-44 <a href="00Index.html">Index]</a></div>

</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -