Turi Create
4.0
|
#include <model_server/lib/extensions/model_base.hpp>
Public Member Functions | |
virtual const char * | name ()=0 |
virtual const std::string & | uid ()=0 |
virtual void | save_impl (oarchive &oarc) const |
virtual void | load_version (iarchive &iarc, size_t version) |
void | save_to_url (const std::string &url, const variant_map_type &side_data={}) |
void | save_model_to_data (std::ostream &out) |
virtual size_t | get_version () const |
const std::map< std::string, std::vector< std::string > > & | list_functions () |
const std::vector< std::string > & | list_get_properties () |
const std::vector< std::string > & | list_set_properties () |
variant_type | call_function (const std::string &function, variant_map_type argument) |
variant_type | get_property (const std::string &property) |
variant_type | set_property (const std::string &property, variant_map_type argument) |
const std::string & | get_docstring (const std::string &symbol) |
virtual void | perform_registration () |
Protected Member Functions | |
void | register_function (std::string fnname, const std::vector< std::string > &arguments, impl_fn fn) |
void | register_defaults (const std::string &fnname, const variant_map_type &arguments) |
void | register_setter (const std::string &propname, impl_fn setfn) |
void | register_getter (const std::string &propname, impl_fn getfn) |
void | register_docstring (const std::pair< std::string, std::string > &fnname_docstring) |
The base class from which all new toolkit classes must inherit.
This class defines a generic object interface, listing properties and callable methods, so that instances can be naturally wrapped and exposed to other languages, such as Python.
Subclasses should use the macros defined in toolkit_class_macros.hpp to declared the desired properties and methods, and to define their implementations. See that file for details and examples.
Subclasses that wish to support saving and loading should also override the save_impl, load_version, and get_version functions below.
Definition at line 45 of file model_base.hpp.
variant_type turi::model_base::call_function | ( | const std::string & | function, |
variant_map_type | argument | ||
) |
Calls a user defined function.
const std::string& turi::model_base::get_docstring | ( | const std::string & | symbol | ) |
Returns the toolkit documentation for a function or property.
variant_type turi::model_base::get_property | ( | const std::string & | property | ) |
Reads a property.
|
inlinevirtual |
Returns the current version of the toolkit class for this instance, for serialization purposes.
Reimplemented in turi::kmeans::kmeans_model, turi::recsys::recsys_model_base, turi::model_proxy, turi::supervised::xgboost::xgboost_model, turi::text::topic_model, turi::pattern_mining::fp_growth, turi::supervised::logistic_regression, turi::supervised::linear_svm, turi::sdk_model::feature_engineering::random_projection, turi::text::alias_topic_model, turi::sdk_model::feature_engineering::feature_binner, turi::sdk_model::feature_engineering::sample_transformer, turi::supervised::linear_regression, turi::sdk_model::feature_engineering::transformer_base, turi::sdk_model::feature_engineering::count_featurizer, and turi::simple_model.
Definition at line 130 of file model_base.hpp.
const std::map<std::string, std::vector<std::string> >& turi::model_base::list_functions | ( | ) |
Lists all the registered functions. Returns a map of function name to array of argument names for the function.
const std::vector<std::string>& turi::model_base::list_get_properties | ( | ) |
Lists all the get-table properties of the class.
const std::vector<std::string>& turi::model_base::list_set_properties | ( | ) |
Lists all the set-table properties of the class.
|
inlinevirtual |
Loads a toolkit class previously saved at a particular version number. Should raise an exception on failure.
Reimplemented in turi::kmeans::kmeans_model, turi::recsys::recsys_model_base, turi::model_proxy, turi::supervised::xgboost::xgboost_model, turi::pattern_mining::fp_growth, turi::text::topic_model, turi::supervised::logistic_regression, turi::supervised::linear_svm, turi::sdk_model::feature_engineering::random_projection, turi::text::alias_topic_model, turi::supervised::linear_regression, turi::sdk_model::feature_engineering::feature_binner, turi::sdk_model::feature_engineering::sample_transformer, turi::sdk_model::feature_engineering::transformer_base, turi::sdk_model::feature_engineering::count_featurizer, and turi::simple_model.
Definition at line 96 of file model_base.hpp.
|
pure virtual |
Returns the name of the toolkit class, as exposed to client code. For example, the Python proxy for this instance will have a type with this name.
Note: this function is typically overridden using the BEGIN_CLASS_MEMBER_REGISTRATION macro.
|
virtual |
Declare the base registration function. This class has to be handled specially; the macros don't work here due to the override declarations.
Reimplemented in turi::model_proxy.
|
protected |
Registers default argument values
|
protected |
Adds a docstring for the specified function or property name.
|
protected |
Adds a function with the specified name, and argument list.
|
protected |
Adds a property getter with the specified name.
|
protected |
Adds a property setter with the specified name.
|
inlinevirtual |
Serializes the toolkit class. Must save the class to the file format version matching that of get_version().
Reimplemented in turi::kmeans::kmeans_model, turi::recsys::recsys_model_base, turi::model_proxy, turi::supervised::xgboost::xgboost_model, turi::pattern_mining::fp_growth, turi::text::topic_model, turi::supervised::logistic_regression, turi::supervised::linear_svm, turi::sdk_model::feature_engineering::random_projection, turi::text::alias_topic_model, turi::supervised::linear_regression, turi::sdk_model::feature_engineering::feature_binner, turi::sdk_model::feature_engineering::sample_transformer, turi::sdk_model::feature_engineering::transformer_base, turi::sdk_model::feature_engineering::count_featurizer, and turi::simple_model.
Definition at line 87 of file model_base.hpp.
void turi::model_base::save_model_to_data | ( | std::ostream & | out | ) |
Save a toolkit class to a data stream.
void turi::model_base::save_to_url | ( | const std::string & | url, |
const variant_map_type & | side_data = {} |
||
) |
Save a toolkit class to disk.
url | The destination url to store the class. |
sidedata | Any additional side information |
variant_type turi::model_base::set_property | ( | const std::string & | property, |
variant_map_type | argument | ||
) |
Sets a property. The new value of the property should appear in the argument map under the key "value".
|
pure virtual |
Returns a unique identifier for the toolkit class. It can be any unique ID. The UID is only used at runtime (to determine the concrete type of an arbitrary model_base instance) and is never stored.
Note: this function is typically overridden using the BEGIN_CLASS_MEMBER_REGISTRATION macro.
Implemented in turi::model_proxy.