% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/splitting.R
\name{best_split_free}
\alias{best_split_free}
\title{Best Split for Binary Labels (Free Assignment)}
\usage{
best_split_free(labels)
}
\arguments{
\item{labels}{Integer vector containing only 1 and 2.}
}
\value{
A list with:
\describe{
\item{index}{The optimal split location (between index and index + 1).}
\item{total_correct}{Maximum number of correctly assigned labels.}
\item{left_majority}{Majority class on the left segment.}
\item{right_majority}{Majority class on the right segment.}
\item{accuracy_if_assigning_majorities}{Proportion correctly assigned.}
}
}
\description{
Given a sequence of labels in \{1, 2\}, this function finds the best split
point that maximizes the number of correctly assigned labels on each side.
The left and right segments are each assigned their majority class.
}
\details{
For each possible split point \(i\), the function computes:
\itemize{
\item left correct = max(#1_left, #2_left)
\item right correct = max(#1_right, #2_right)
}
and selects the split maximizing their sum.
}
\examples{
labels <- c(1,1,1,2,2,2)
best_split_free(labels)

}
