% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/krnn.R
\name{predict.krnn_fit}
\alias{predict.krnn_fit}
\title{Predict Method for krnn_fit Objects}
\usage{
\method{predict}{krnn_fit}(object, newdata, y_true = NULL, ...)
}
\arguments{
\item{object}{A \code{"krnn_fit"} object.}

\item{newdata}{Numeric matrix of new curves
(\eqn{n_{\mathrm{new}} \times M}).}

\item{y_true}{Optional integer vector of true labels for computing the
misclassification rate.}

\item{...}{Ignored.}
}
\value{
A list with components \code{predicted}, \code{prob}, and (if
\code{y_true} is supplied) \code{misclass}.
}
\description{
Classifies new functional observations using a fitted
\code{\link{krnn_fit}} object.
}
\examples{
set.seed(7)
M <- 100; n <- 80
t <- seq(0, 1, length.out = M)
X0 <- t(replicate(n / 2, sin(2 * pi * t) + rnorm(M, sd = 0.4)))
X1 <- t(replicate(n / 2, cos(2 * pi * t) + rnorm(M, sd = 0.4)))
X  <- rbind(X0, X1)
y  <- rep(0:1, each = n / 2)
idx_tr <- sample(n, 60)
fit  <- krnn_fit(X[idx_tr, ], y[idx_tr], k = 5)
pred <- predict(fit, newdata = X[-idx_tr, ], y_true = y[-idx_tr])
pred$misclass

}
