Making progress.

This commit is contained in:
2020-02-12 22:31:06 +01:00
parent dc545e4063
commit a54bb70138
9 changed files with 243 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
use kickscore as ks;
fn main() {
let mut model = ks::BinaryModel {};
let mut model = ks::BinaryModel::new(ks::BinaryModelObservation::Probit);
// Spike's skill does not change over time.
let k_spike = ks::kernel::Constant::new(0.5);
@@ -16,9 +16,9 @@ fn main() {
];
// Now we are ready to add the items in the model.
model.add_item("Spike", k_spike);
model.add_item("Tom", k_tom);
model.add_item("Jerry", k_jerry);
model.add_item("Spike", Box::new(k_spike));
model.add_item("Tom", Box::new(k_tom));
model.add_item("Jerry", Box::new(k_jerry));
// At first, Jerry beats Tom a couple of times.
model.observe(&["Jerry"], &["Tom"], 0.0);
@@ -35,20 +35,20 @@ fn main() {
model.fit(true);
// We can predict a future outcome...
let (p_win, p_los) = model.probabilities(&[&"Jerry"], &[&"Tom"], 4.0);
let (p_win, _p_los) = model.probabilities(&[&"Jerry"], &[&"Tom"], 4.0);
println!(
"Chances that Jerry beats Tom at t = 4.0: {:.1}%",
100.0 * p_win
);
// ... or simulate what could have happened in the past.
let (p_win, p_los) = model.probabilities(&[&"Jerry"], &[&"Tom"], 2.0);
let (p_win, _p_los) = model.probabilities(&[&"Jerry"], &[&"Tom"], 2.0);
println!(
"Chances that Jerry beats Tom at t = 2.0: {:.1}%",
100.0 * p_win
);
let (p_win, p_los) = model.probabilities(&[&"Jerry"], &[&"Tom"], -1.0);
let (p_win, _p_los) = model.probabilities(&[&"Jerry"], &[&"Tom"], -1.0);
println!(
"Chances that Jerry beats Tom at t = -1.0: {:.1}%",
100.0 * p_win