ext/libsvm/libsvm.c in rb-libsvm-1.1.5 vs ext/libsvm/libsvm.c in rb-libsvm-1.2.0

- old
+ new

@@ -409,10 +409,17 @@ const struct svm_model *model; Data_Get_Struct(obj, struct svm_model, model); return INT2NUM(svm_get_nr_class(model)); } +static VALUE cModel_support_vectors(VALUE obj) +{ + const struct svm_model *model; + Data_Get_Struct(obj, struct svm_model, model); + return INT2NUM(svm_get_nr_sv(model)); +} + static VALUE cModel_class_load(VALUE cls, VALUE filename) { struct svm_model *model; char *path; path = StringValueCStr(filename); @@ -491,9 +498,10 @@ rb_define_singleton_method(cModel, "cross_validation", cModel_class_cross_validation, 3); rb_define_singleton_method(cModel, "load", cModel_class_load, 1); rb_define_method(cModel, "save", cModel_save, 1); rb_define_method(cModel, "svm_type", cModel_svm_type, 0); rb_define_method(cModel, "classes", cModel_classes, 0); + rb_define_method(cModel, "support_vectors", cModel_support_vectors, 0); rb_define_method(cModel, "predict", cModel_predict, 1); rb_define_method(cModel, "predict_probability", cModel_predict_probability, 1); mKernelType = rb_define_module_under(mLibsvm, "KernelType"); rb_define_const(mKernelType, "LINEAR", INT2NUM(LINEAR));