pub struct RankingModel<T: Clone + Debug + Eq + Hash + Display + Send + Sync + 'static> {
pub data: ComparisonMatrix<T>,
pub scores: Option<HashMap<T, f64>>,
/* private fields */
}Expand description
Main ASAP ranking model for inferring scores from pairwise comparisons
Fields§
§data: ComparisonMatrix<T>§scores: Option<HashMap<T, f64>>Implementations§
Source§impl<T: Clone + Debug + Eq + Hash + Display + Send + Sync + 'static> RankingModel<T>
impl<T: Clone + Debug + Eq + Hash + Display + Send + Sync + 'static> RankingModel<T>
Sourcepub fn new_with_options(
items: &[T],
approximate: bool,
selective_eig: bool,
) -> Self
pub fn new_with_options( items: &[T], approximate: bool, selective_eig: bool, ) -> Self
Create a new RankingModel with custom options
Sourcepub fn add_comparison(
&mut self,
comparison: Comparison<T>,
) -> Result<(), AsapError<T>>
pub fn add_comparison( &mut self, comparison: Comparison<T>, ) -> Result<(), AsapError<T>>
Add a pairwise comparison result
pub fn add_item(&mut self, item: T) -> Result<(), AsapError<T>>
pub fn remove_item(&mut self, item: &T) -> Result<(), AsapError<T>>
Sourcepub fn get_ordering(&mut self) -> Result<Vec<T>, AsapError<T>>
pub fn get_ordering(&mut self) -> Result<Vec<T>, AsapError<T>>
Get the items ordered by their inferred scores (highest to lowest)
Sourcepub fn get_scores(&mut self) -> Result<HashMap<T, f64>, AsapError<T>>
pub fn get_scores(&mut self) -> Result<HashMap<T, f64>, AsapError<T>>
Get the inferred scores for all items
Sourcepub fn suggest_comparisons(
&self,
max: usize,
) -> Result<Vec<(T, T)>, AsapError<T>>
pub fn suggest_comparisons( &self, max: usize, ) -> Result<Vec<(T, T)>, AsapError<T>>
Suggest the most informative comparisons to perform next
Sourcepub fn ranking_confidence(&self) -> Result<f64, AsapError<T>>
pub fn ranking_confidence(&self) -> Result<f64, AsapError<T>>
Confidence metric calibrated for Bradley-Terry MLE.
Measures two things:
- Coverage (50% weight): fraction of items with >= MIN_COMPARISONS_PER_ITEM comparisons. BT needs ~5-10 per item, not N² total.
- Discrimination (50% weight): whether scores are spread out enough to distinguish items. Uses coefficient of variation of the BT strengths.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for RankingModel<T>
impl<'de, T> Deserialize<'de> for RankingModel<T>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<T> Freeze for RankingModel<T>
impl<T> RefUnwindSafe for RankingModel<T>where
T: RefUnwindSafe,
impl<T> Send for RankingModel<T>
impl<T> Sync for RankingModel<T>
impl<T> Unpin for RankingModel<T>where
T: Unpin,
impl<T> UnsafeUnpin for RankingModel<T>
impl<T> UnwindSafe for RankingModel<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more