Small fixes
This commit is contained in:
28
tests/binary-1.rs
Normal file
28
tests/binary-1.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
extern crate intel_mkl_src;
|
||||
|
||||
use approx::assert_abs_diff_eq;
|
||||
use kickscore as ks;
|
||||
|
||||
#[test]
|
||||
fn binary_1() {
|
||||
let mut model = ks::BinaryModel::new(ks::BinaryModelObservation::Probit);
|
||||
|
||||
let k_audrey = ks::kernel::Matern52::new(1.0, 2.0);
|
||||
let k_benjamin = ks::kernel::Matern52::new(1.0, 2.0);
|
||||
|
||||
model.add_item("audrey", Box::new(k_audrey));
|
||||
model.add_item("benjamin", Box::new(k_benjamin));
|
||||
|
||||
model.observe(&["audrey"], &["benjamin"], 0.0);
|
||||
model.observe(&["audrey"], &["benjamin"], 1.0);
|
||||
model.observe(&["audrey"], &["benjamin"], 2.0);
|
||||
|
||||
model.observe(&["audrey"], &["benjamin"], 3.0);
|
||||
|
||||
model.observe(&["benjamin"], &["audrey"], 4.0);
|
||||
model.observe(&["benjamin"], &["audrey"], 5.0);
|
||||
model.observe(&["benjamin"], &["audrey"], 6.0);
|
||||
model.observe(&["benjamin"], &["audrey"], 7.0);
|
||||
|
||||
model.fit();
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
extern crate intel_mkl_src;
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashSet;
|
||||
use std::fs;
|
||||
use std::io::{self, BufRead};
|
||||
@@ -43,12 +44,14 @@ fn nba_history() {
|
||||
let score_1: u16 = data[3].parse().unwrap();
|
||||
let score_2: u16 = data[4].parse().unwrap();
|
||||
|
||||
if score_1 > score_2 {
|
||||
observations.push((data[1].to_string(), data[2].to_string(), t));
|
||||
} else if score_1 < score_2 {
|
||||
observations.push((data[2].to_string(), data[1].to_string(), t));
|
||||
} else {
|
||||
panic!("there shouldn't be any tie games");
|
||||
match score_1.cmp(&score_2) {
|
||||
Ordering::Greater => {
|
||||
observations.push((data[1].to_string(), data[2].to_string(), t));
|
||||
}
|
||||
Ordering::Less => {
|
||||
observations.push((data[2].to_string(), data[1].to_string(), t));
|
||||
}
|
||||
_ => panic!("there shouldn't be any tie games"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user