Turi Create
4.0
|
#include <toolkits/supervised_learning/linear_svm.hpp>
Public Member Functions | |
virtual | ~linear_svm () |
void | set_default_evaluation_metric () override |
void | set_default_tracking_metric () override |
void | model_specific_init (const ml_data &data, const ml_data &valid_data) override |
bool | is_classifier () const override |
void | train () override |
void | init_options (const std::map< std::string, flexible_type > &_opts) override |
size_t | get_version () const override |
void | set_coefs (const DenseVector &_coefs) override |
void | save_impl (turi::oarchive &oarc) const override |
void | load_version (turi::iarchive &iarc, size_t version) override |
flexible_type | predict_single_example (const DenseVector &x, const prediction_type_enum &output_type=prediction_type_enum::NA) override |
flexible_type | predict_single_example (const SparseVector &x, const prediction_type_enum &output_type=prediction_type_enum::NA) override |
sframe | classify (const ml_data &test_data, const std::string &output_type="") override |
gl_sframe | fast_classify (const std::vector< flexible_type > &rows, const std::string &missing_value_action="error") override |
void | get_coefficients (DenseVector &_coefs) const |
std::shared_ptr< coreml::MLModelWrapper > | export_to_coreml () override |
std::vector< std::vector< flexible_type > > | get_metadata_mapping () |
virtual flexible_type | predict_single_example (const ml_data_iterator &it, const prediction_type_enum &output_type=prediction_type_enum::NA) |
virtual std::map< std::string, variant_type > | evaluate (const ml_data &test_data, const std::string &evaluation_type="", bool with_prediction=false) |
virtual std::map< std::string, variant_type > | evaluate (const sframe &X, const sframe &y, const std::string &evaluation_type="", bool with_prediction=false) |
virtual std::shared_ptr< sarray< flexible_type > > | predict (const ml_data &test_data, const std::string &output_type="") |
virtual std::shared_ptr< sarray< flexible_type > > | predict (const sframe &X, const std::string &output_type="") |
virtual std::shared_ptr< sarray< flexible_type > > | extract_features (const sframe &X, ml_missing_value_action missing_value_action) |
virtual sframe | predict_topk (const sframe &test_data, const std::string &output_type="", size_t topk=5) |
virtual sframe | predict_topk (const ml_data &test_data, const std::string &output_type="", size_t topk=5) |
virtual sframe | classify (const sframe &X, const std::string &output_type="") |
virtual gl_sarray | fast_predict (const std::vector< flexible_type > &rows, const std::string &missing_value_action="error", const std::string &output_type="") |
virtual gl_sframe | fast_predict_topk (const std::vector< flexible_type > &rows, const std::string &missing_value_action="error", const std::string &output_type="", const size_t topk=5) |
virtual void | init (const sframe &X, const sframe &y, const sframe &valid_X=sframe(), const sframe &valid_y=sframe(), ml_missing_value_action mva=ml_missing_value_action::ERROR) |
void | set_evaluation_metric (std::vector< std::string > _metrics) |
void | set_tracking_metric (std::vector< std::string > _metrics) |
void | set_more_warnings (bool more_warnings) |
std::map< std::string, flexible_type > | get_train_stats () const |
sframe | impute_missing_columns_using_current_metadata (const sframe &X) const |
ml_data | construct_ml_data_using_current_metadata (const sframe &X, const sframe &y, ml_missing_value_action mva=ml_missing_value_action::ERROR) const |
ml_data | construct_ml_data_using_current_metadata (const sframe &X, ml_missing_value_action mva=ml_missing_value_action::ERROR) const |
size_t | num_features () const |
size_t | num_examples () const |
size_t | num_unpacked_features () const |
std::vector< std::string > | get_feature_names () const |
std::string | get_target_name () const |
std::shared_ptr< ml_metadata > | get_ml_metadata () const |
bool | is_dense () |
std::vector< std::string > | get_metrics () const |
std::vector< std::string > | get_tracking_metrics () const |
std::string | get_metric_display_name (const std::string &metric) const |
void | display_regression_training_summary (std::string model_display_name) const |
void | display_classifier_training_summary (std::string model_display_name, bool simple_mode=false) const |
virtual bool | support_missing_value () const |
void | api_train (gl_sframe data, const std::string &target, const variant_type &validation_data, const std::map< std::string, flexible_type > &_options) |
gl_sarray | api_predict (gl_sframe data, std::string missing_value_action, std::string output_type) |
gl_sframe | api_predict_topk (gl_sframe data, std::string missing_value_action, std::string output_type, size_t topk=5) |
gl_sframe | api_classify (gl_sframe data, std::string missing_value_action, std::string output_type) |
variant_map_type | api_evaluate (gl_sframe data, std::string missing_value_action, std::string metric, gl_sarray predictions=gl_sarray(), bool with_prediction=false) |
gl_sarray | api_extract_features (gl_sframe data, std::string missing_value_action) |
std::vector< std::string > | list_fields () |
const variant_type & | get_value_from_state (std::string key) |
const std::map< std::string, flexible_type > & | get_current_options () const |
std::map< std::string, flexible_type > | get_default_options () const |
const flexible_type & | get_option_value (const std::string &name) const |
const std::map< std::string, variant_type > & | get_state () const |
bool | is_trained () const |
void | set_options (const std::map< std::string, flexible_type > &_options) |
void | add_or_update_state (const std::map< std::string, variant_type > &dict) |
const std::vector< option_handling::option_info > & | get_option_info () const |
virtual const char * | name ()=0 |
virtual const std::string & | uid ()=0 |
void | save_to_url (const std::string &url, const variant_map_type &side_data={}) |
void | save_model_to_data (std::ostream &out) |
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_defaults (const std::string &fnname, const variant_map_type &arguments) |
void | register_function (std::string fnname, const std::vector< std::string > &arguments, impl_fn fn) |
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) |
Protected Attributes | |
Eigen::Matrix< double, Eigen::Dynamic, 1 > | coefs |
std::map< std::string, variant_type > | state |
SVM svm model class definition.
Definition at line 36 of file linear_svm.hpp.
|
virtual |
Destructor. Make sure bad things don't happen
|
inherited |
Append the key value store of the model.
[in] | dict | Options (Key-Value pairs) to set |
|
inherited |
API interface through the unity server.
Run classification.
|
inherited |
API interface through the unity server.
Evaluate the model
|
inherited |
API interface through the unity server.
Extract features!
|
inherited |
API interface through the unity server.
Run prediction.
|
inherited |
API interface through the unity server.
Run multiclass prediction.
|
inherited |
API interface through the unity server.
Train the model
|
inherited |
Calls a user defined function.
|
overridevirtual |
Make classification using a trained supervised_learning model.
[in] | X | Test data (only independent variables) |
[in] | output_type | Type of classifcation (future proof). |
Reimplemented from turi::supervised::supervised_learning_model_base.
|
inlinevirtualinherited |
Same as classify(ml_data), but takes SFrame as input.
Definition at line 361 of file supervised_learning.hpp.
|
inherited |
Construct ml-data from the predictors and target using the current value of the metadata.
[in] | X | Predictors |
[in] | y | target |
[in] | new_opts | Additional options. |
|
inherited |
Construct ml-data from the predictors using the current value of the metadata.
[in] | X | Predictors |
[in] | new_opts | Additional options. |
|
inherited |
Display model training data summary for classifier.
[in] | model_display_name | Name to be displayed |
|
inherited |
Display model training data summary for regression.
[in] | model_display_name | Name to be displayed |
|
virtualinherited |
Evaluate the model.
[in] | test_data | Test data. |
[in] | evaluation_type | Evalution type. |
Reimplemented in turi::supervised::xgboost::xgboost_model.
|
inlinevirtualinherited |
Same as evaluate(ml_data), but take SFrame as input.
Definition at line 278 of file supervised_learning.hpp.
|
overridevirtual |
Export to CoreML.
Implements turi::supervised::supervised_learning_model_base.
|
inlinevirtualinherited |
Extract features!
Reimplemented in turi::supervised::xgboost::xgboost_model.
Definition at line 309 of file supervised_learning.hpp.
|
overridevirtual |
Fast path predictions given a row of flexible_types
[in] | rows | List of rows (each row is a flex_dict) |
[in] | output_type | Output type. |
Reimplemented from turi::supervised::supervised_learning_model_base.
|
virtualinherited |
Fast path predictions given a row of flexible_types.
[in] | rows | List of rows (each row is a flex_dict) |
[in] | missing_value_action | Missing value action string |
[in] | output_type | Output type. |
Reimplemented in turi::supervised::xgboost::xgboost_model.
|
inlinevirtualinherited |
Fast path predictions given a row of flexible_types.
[in] | rows | List of rows (each row is a flex_dict) |
[in] | missing_value_action | Missing value action string |
[in] | output_type | Output type. |
[in] | topk | Number of classes to return |
Reimplemented in turi::supervised::logistic_regression, and turi::supervised::xgboost::xgboost_model.
Definition at line 388 of file supervised_learning.hpp.
|
inline |
Get coefficients for a trained model.
Definition at line 171 of file linear_svm.hpp.
|
inherited |
Get current options.
Interfaces with the get_current_options function in the Python side.
|
inherited |
Get default options.
Interfaces with the get_default_options function in the Python side.
|
inherited |
Returns the toolkit documentation for a function or property.
|
inherited |
Get names of predictor variables.
|
inherited |
Get metadata mapping.
|
inherited |
Get metric display name.
|
inherited |
Get metrics strings.
|
inlineinherited |
Get ml_metadata.
Definition at line 564 of file supervised_learning.hpp.
|
inherited |
Returns the option information struct for each of the set parameters.
|
inherited |
Returns the value of an option. Throws an error if the option does not exist.
[in] | name | Name of the option to get. |
|
inherited |
Reads a property.
|
inherited |
Get model.
|
inherited |
Get name of the target column.
|
inherited |
Get tracking metrics strings.
|
inherited |
Get training stats.
The dictionary returned to the user can be transfered as is to the python side. You MUST use this to return a dictionary to the object.
|
inherited |
Returns the value of a particular key from the state.
From the python side, this is interfaced with the get() function or the [] operator in python.
|
overridevirtual |
Gets the model version number
Reimplemented from turi::model_base.
|
inherited |
Impute missing columns with 'None' values.
[in] | X | Predictors |
|
virtualinherited |
Init the model with the data.
[in] | X | Predictors |
[in] | y | target |
NA.
|
overridevirtual |
|
inlineoverridevirtual |
Returns true if the model is a classifier.
Implements turi::supervised::supervised_learning_model_base.
Definition at line 84 of file linear_svm.hpp.
|
inlineinherited |
Returns true if the model is a classifier.
Definition at line 576 of file supervised_learning.hpp.
|
inherited |
Is this model trained.
|
inherited |
Lists all the keys accessible in the "model" map.
This is the function that the list_fields should call in python.
|
inherited |
Lists all the registered functions. Returns a map of function name to array of argument names for the function.
|
inherited |
Lists all the get-table properties of the class.
|
inherited |
Lists all the set-table properties of the class.
|
overridevirtual |
Load the object
Reimplemented from turi::model_base.
|
overridevirtual |
Internal init after the ml_data is built.
[in] | data | Training data |
[in] | valid_data | Validation data |
Reimplemented from turi::supervised::supervised_learning_model_base.
|
pure virtualinherited |
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.
|
inherited |
Get the number of examples in the model
|
inherited |
Get the number of feature columns in the model
|
inherited |
Get the number of features in the model (unpacked)
|
virtualinherited |
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.
|
virtualinherited |
Make predictions using a trained supervised_learning model.
[in] | test_X | Test data (only independent variables) |
[in] | output_type | Type of prediction. |
Reimplemented in turi::supervised::xgboost::xgboost_model.
|
inlinevirtualinherited |
Same as predict(ml_data), but takes SFrame as input.
Definition at line 299 of file supervised_learning.hpp.
|
overridevirtual |
Predict for a single example.
[in] | x | Single example. |
[in] | output_type | Type of prediction. |
Reimplemented from turi::supervised::supervised_learning_model_base.
|
overridevirtual |
Predict for a single example.
[in] | x | Single example. |
[in] | output_type | Type of prediction. |
Reimplemented from turi::supervised::supervised_learning_model_base.
|
inlinevirtualinherited |
Methods with default implementations but are in-flux during the
Predict for a single example.
[in] | x | Single example. |
[in] | output_type | Type of prediction. |
Definition at line 226 of file supervised_learning.hpp.
|
inlinevirtualinherited |
Make multiclass predictions using a trained supervised_learning model.
[in] | test_X | Test data (only independent variables) |
[in] | output_type | Type of prediction. |
[in] | topk | Number of classes to return. |
Definition at line 326 of file supervised_learning.hpp.
|
virtualinherited |
Make multiclass predictions using a trained supervised_learning model.
[in] | test_X | Test data (only independent variables) |
[in] | output_type | Type of prediction. |
[in] | topk | Number of classes to return. |
Reimplemented in turi::supervised::xgboost::xgboost_model.
|
protectedinherited |
Registers default argument values
|
protectedinherited |
Adds a docstring for the specified function or property name.
|
protectedinherited |
Adds a function with the specified name, and argument list.
|
protectedinherited |
Adds a property getter with the specified name.
|
protectedinherited |
Adds a property setter with the specified name.
|
overridevirtual |
Serialize the object.
Reimplemented from turi::model_base.
|
inherited |
Save a toolkit class to a data stream.
|
inherited |
Save a toolkit class to disk.
url | The destination url to store the class. |
sidedata | Any additional side information |
|
overridevirtual |
Setter for model coefficieints.
Reimplemented from turi::supervised::supervised_learning_model_base.
|
inlineoverridevirtual |
Set the default evaluation metric during model evaluation..
Reimplemented from turi::supervised::supervised_learning_model_base.
Definition at line 55 of file linear_svm.hpp.
|
inlineoverridevirtual |
Set the default evaluation metric for progress tracking.
Reimplemented from turi::supervised::supervised_learning_model_base.
Definition at line 68 of file linear_svm.hpp.
|
inlineinherited |
Set the evaluation metric. Set to RMSE by default.
Definition at line 439 of file supervised_learning.hpp.
|
inlineinherited |
Set the Extra Warnings output. These warnings include telling the user about low-variance features, etc...
Definition at line 455 of file supervised_learning.hpp.
|
inherited |
Set one of the options in the algorithm.
The value are checked with the requirements given by the option instance.
[in] | name | Name of the option. |
[in] | value | Value for the option. |
|
inherited |
Sets a property. The new value of the property should appear in the argument map under the key "value".
|
inlineinherited |
Set the evaluation metric. Set to RMSE by default.
Definition at line 447 of file supervised_learning.hpp.
|
inlinevirtualinherited |
Returns true if the model can handle missing value
Reimplemented in turi::supervised::xgboost::xgboost_model.
Definition at line 628 of file supervised_learning.hpp.
|
overridevirtual |
Train a svm model.
Implements turi::supervised::supervised_learning_model_base.
|
pure virtualinherited |
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.
|
protected |
Primal sol
Definition at line 40 of file linear_svm.hpp.
|
protectedinherited |
All things python
Definition at line 206 of file ml_model.hpp.