use crate::pack::{FetchProgress, Pack, PackFile};
use oa::{Engine, Result};
use std::path::PathBuf;
pub(crate) const TITANIC_PACK: Pack = Pack {
name: "titanic",
version: "1.0.0",
license: "UNSPECIFIED",
files: &[PackFile {
name: "titanic.csv",
size: 60_302,
shake256: "f2633850d881726f82fe8afaec62694aa126dc5d39ba48d61cee8ae3d01fe56f",
urls: &["https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv"],
}],
};
pub const FEATURE_COUNT: usize = 9;
#[derive(Clone, Debug)]
pub struct TitanicConfig {
pub normalize: bool,
pub cache_dir: Option<PathBuf>,
}
impl Default for TitanicConfig {
fn default() -> Self {
Self {
normalize: true,
cache_dir: None,
}
}
}
impl TitanicConfig {
#[inline]
#[must_use]
pub fn new() -> Self {
Self::default()
}
}
impl super::Titanic {
#[inline]
pub fn load(config: &TitanicConfig) -> Result<Self> {
Self::load_on(&Engine::current()?, config)
}
#[inline]
pub fn load_on(engine: &Engine, config: &TitanicConfig) -> Result<Self> {
Self::load_with_progress_on(engine, config, &mut |_| true)
}
#[inline]
pub fn load_with_progress(
config: &TitanicConfig,
progress: &mut impl FnMut(FetchProgress) -> bool,
) -> Result<Self> {
Self::load_with_progress_on(&Engine::current()?, config, progress)
}
}