% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/score.R
\name{lms_score_expected}
\alias{lms_score_expected}
\title{Calculate Expected Scores and Uncertainty from Logprobs}
\usage{
lms_score_expected(lp_df, scale = 1:5)
}
\arguments{
\item{lp_df}{A dataframe of logprobs (e.g., \code{x$logprobs}).}

\item{scale}{Numeric vector. The valid labels (e.g., \code{1:5}).}
}
\value{
A named list containing three numeric elements
(\code{expected_value}, \code{weighted_sd}, \code{entropy}) and a
\code{data.frame} named \code{probabilities} with columns \code{label} and
\code{prob}. Returns \code{NULL} if the input dataframe is empty or
invalid.
}
\description{
Takes a logprobs dataframe (from an \code{lms_chat_result}) and calculates
the weighted average score, normalized probabilities, and uncertainty
metrics.
}
\examples{
# Create a sample logprobs dataframe representing a model's generation step
mock_logprobs <- data.frame(
  step_token = rep("4", 3),
  step_logprob = rep(0, 3),
  candidate_token = c("4", "5", "3"),
  candidate_logprob = c(-0.105, -2.302, -3.506),
  stringsAsFactors = FALSE
)

# Calculate the expected score and uncertainty metrics
lms_score_expected(mock_logprobs, scale = 1:5)
}
