schalkdaniel / compboost

C++ implementation and R API for componentwise boosting
https://schalkdaniel.github.io/compboost/
GNU Lesser General Public License v3.0
24 stars 3 forks source link

Export Baselearnerlist to JSON #364

Closed schalkdaniel closed 1 year ago

schalkdaniel commented 1 year ago
schalkdaniel commented 1 year ago

Problem: Each base learner stores the data which leads to many replicated matrices in the JSON. INSTEAD: After serializing the base learner factories (that hold the unique data objects) initialize the data objects from the base learners as real pointers from the factory data objects.

schalkdaniel commented 1 year ago

This may require a more sophisticated loading method for the std::vector<blearner::Baselearner> that gets the JSON with the base learners and a JSON with the data container or factories.

schalkdaniel commented 1 year ago

Then do something like:

Baselearner::BaselearnerXYZ (const json& jbl, const json& jdat)
  : xyz          ( jbl["xyz"] ),
    _sh_ptr_data ( jsonToData(jdat[jbl["data_id"]] ) 
{ }
schalkdaniel commented 1 year ago

Actually, the list of base learner factories must be initialized first, then given to the construction which copies the required data.

schalkdaniel commented 1 year ago

Also for the base learner factories: Initialize a map with data objects first and the use in blearnerfactory::jsonToFactory(json j, std::map<std::string, std::shared_ptr<data::Data>> dmap) to adequately copy the data by reference. The same for the base learner.