Skip to content

Commit

Permalink
Convert FTRL code to a core datatable class (#1417)
Browse files Browse the repository at this point in the history
FTRL code has been converted into a core datatable class:
- added `fit` and `predict` methods for training and making predictions;
- added `reset` method to reset the model;
- added getters and setters for all the model parameters;
- the `model` itself can now be returned and loaded as a separate frame;
- some other refactoring and modifications.

The algo itself was also slightly optimized, however, it still gets the same score on Kaggle. 
So we're ok from the accuracy point of view.
  • Loading branch information
oleksiyskononenko authored and st-pasha committed Nov 20, 2018
1 parent 67abbdd commit ed297dc
Show file tree
Hide file tree
Showing 9 changed files with 758 additions and 192 deletions.
5 changes: 3 additions & 2 deletions c/datatablemodule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "csv/writer.h"
#include "expr/py_expr.h"
#include "extras/aggregator.h"
#include "extras/ftrl.h"
#include "extras/py_ftrl.h"
#include "frame/py_frame.h"
#include "options.h"
#include "py_column.h"
Expand Down Expand Up @@ -199,7 +199,6 @@ void DatatableModule::init_methods() {
add(METHODv(expr_unaryop));
add(METHOD0(is_debug_mode));
add(METHOD0(has_omp_support));
init_methods_ftrl();
init_methods_aggregate();
init_methods_str();
init_methods_options();
Expand Down Expand Up @@ -234,6 +233,8 @@ PyInit__datatable()

try {
py::Frame::Type::init(m);
py::Ftrl::Type::init(m);

} catch (const std::exception& e) {
exception_to_python(e);
return nullptr;
Expand Down
1 change: 0 additions & 1 deletion c/datatablemodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class DatatableModule : public py::ExtModule<DatatableModule> {

void init_methods();
void init_methods_aggregate();// extra/aggergate.cc
void init_methods_ftrl(); // extra/ftrl.cc
void init_methods_str(); // str/py_str.cc
void init_methods_options(); // options.cc
void init_methods_sets(); // set_funcs.cc
Expand Down
4 changes: 2 additions & 2 deletions c/extras/aggregator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ namespace py {

// dt changes in-place with a new column added to the end of it
DataTable* dt_members = agg.aggregate(dt).release();
py::Frame* frame_members = py::Frame::from_datatable(dt_members);
py::oobj df_members = py::oobj::from_new_reference(py::Frame::from_datatable(dt_members));

return frame_members;
return df_members;
}
);
}
Expand Down
Loading

0 comments on commit ed297dc

Please sign in to comment.