shogun-rust

This is a Rust crate with bindings to the Shogun machine learning framework.

Note: this crate is in very early development and only supports a very limited part of the Shogun library.
Note: this is just a Rust wrapper for the shogun C++ library so the internals/API are not very Rust-like.

More information about the design can be found here.

Example

Basic API

```rust use shogun_rust::shogun::{Kernel, Version};

fn main() { let version = Version::new(); println!("Shogun version {}", version.main_version().unwrap());

// shogun-rust supports Shogun's factory functions
let k = match Kernel::new("GaussianKernel") {
    Ok(obj) => obj,
    Err(msg) => {
        panic!("No can do: {}", msg);
    },
};

// also supports put
match k.put("log_width", &1.0) {
    Err(msg) => println!("Failed to put value."),
    _ => (),
}

// and get
match k.get("log_width") {
    Ok(value) => match value.downcast_ref::<f64>() {
        Some(fvalue) => println!("GaussianKernel::log_width: {}", fvalue),
        None => println!("GaussianKernel::log_width not of type f64"),
    },
    Err(msg) => panic!("{}", msg),
}

} ```

Training a Random Forest

```rust let ffeatstrain = File::readcsv("classifier4class2dlinearfeaturestrain.dat".tostring())?; let ffeatstest = File::readcsv("classifier4class2dlinearfeaturestest.dat".tostring())?; let flabelstrain = File::readcsv("classifier4class2dlinearlabelstrain.dat".tostring())?; let flabelstest = File::readcsv("classifier4class2dlinearlabelstest.dat".tostring())?;

let featurestrain = Features::fromfile(&ffeatstrain)?; let featurestest = Features::fromfile(&ffeatstest)?; let labelstrain = Labels::fromfile(&flabelstrain)?; let labelstest = Labels::fromfile(&flabelstest)?;

let mut randforest = Machine::new("RandomForest")?; let mvote = CombinationRule::new("MajorityVote")?;

randforest.put("labels", &labelstrain)?; randforest.put("numbags", &100)?; randforest.put("combinationrule", &mvote)?; randforest.put("seed", &1)?;

randforest.train(&featurestrain)?;

let predictions = randforest.apply(&featurestest)?;

println!("{}", predictions); ```