Module MrsCake
In: mrscake.rb.c

Ruby interface to the mrscake machine-learning library

Methods

Classes and Modules

Class MrsCake::DataSet
Class MrsCake::Model

Public Class methods

A training run can be distributed across servers. In order to do that, run "mrscake-job-server" on every server (by default, it listens on port 3075), and then add the servers using add_server().

[Source]

/* call-seq:
 *   mrscake::add_server(host, port=3075)
 *
 * A training run can be distributed across servers. In order
 * to do that, run "mrscake-job-server" on every server (by default,
 * it listens on port 3075), and then add the servers using add_server().
 */
static VALUE rb_add_server(int argc, VALUE* argv, VALUE cls)
{
    VALUE _server;
    VALUE _port;
    int count = rb_scan_args(argc, argv, "11", &_server, &_port);
    if(NIL_P(_port)){
        _port = INT2FIX(MRSCAKE_DEFAULT_PORT);
    }
    const char*server = StringValuePtr(_server);
    int port = FIX2INT(_port);
    config_add_remote_server(server, port);
    return Qnil;
}

Load a dataset that has been saved using DataSet.save().

[Source]

/* call-seq:
 *   mrscake::load_dataset(filename) -> dataset
 *
 * Load a dataset that has been saved using DataSet.save().
 */
static VALUE rb_load_dataset(VALUE module, VALUE _filename)
{
    Check_Type(_filename, T_STRING);
    const char*filename = StringValuePtr(_filename);
    VALUE cls = rb_dataset_allocate(DataSet);
    Get_DataSet(dataset,cls);
    dataset->trainingdata = trainingdata_load(filename);
    if(!dataset->trainingdata) {
        rb_raise(rb_eIOError, "couldn't open %s", filename);
    }
    return cls;
}

Load a model that has been saved using Model.save().

[Source]

/* call-seq:
 *   mrscake::load_model(filename) -> model
 *
 * Load a model that has been saved using Model.save().
 */
static VALUE rb_load_model(VALUE module, VALUE _filename)
{
    Check_Type(_filename, T_STRING);
    const char*filename = StringValuePtr(_filename);
    VALUE cls = rb_model_allocate(Model);
    Get_Model(model,cls);
    model->model = model_load(filename);
    if(!model->model) {
        rb_raise(rb_eIOError, "couldn't open %s", filename);
    }
    return cls;
}

Returns an array of model names. Any of these model names can be passed to DataSet.train() to train a specific model. Notice that not every model type works for every data set.

[Source]

/* call-seq:
 *   mrscake::model_names() -> array
 *
 * Returns an array of model names. Any of these model names can be passed
 * to DataSet.train() to train a specific model. Notice that not every model
 * type works for every data set.
 */
static VALUE rb_model_names(VALUE cls)
{
    const char*const*model_names = mrscake_get_model_names();
    int count = 0;
    const char*const*m = model_names;
    while(*m++) {
        count++;
    }

    volatile VALUE list = rb_ary_new2(count);
    int i;
    for(i=0;i<count;i++) {
        rb_ary_store(list, i, rb_str_new2(model_names[i]));
    }
    return list;
}

[Validate]