Feat C++ API
A feature engineering automation tool
FT::Model::ML Class Reference

class that specifies the machine learning algorithm to pair with Feat. More...

#include <ml.h>

Collaboration diagram for FT::Model::ML:

Public Member Functions

 ML (string ml="LinearRidgeRegression", bool norm=true, bool classification=false, int n_classes=2)
 
void init (bool assign_p_est=true)
 
 ~ML ()
 
vector< float > get_weights (bool norm_adjust=true) const
 
shared_ptr< CLabels > fit (const MatrixXf &X, const VectorXf &y, const Parameters &params, bool &pass, const vector< char > &dtypes=vector< char >())
 
VectorXf fit_vector (const MatrixXf &X, const VectorXf &y, const Parameters &params, bool &pass, const vector< char > &dtypes=vector< char >())
 
shared_ptr< CLabels > predict (const MatrixXf &X, bool print=false)
 
VectorXf predict_vector (const MatrixXf &X)
 
ArrayXXf predict_proba (const MatrixXf &X)
 
VectorXf labels_to_vector (const shared_ptr< CLabels > &labels)
 utility function to convert CLabels types to VectorXd types. More...
 
shared_ptr< CLabels > retrieve_labels (CDenseFeatures< float64_t > *features, bool proba, bool &pass)
 returns labels of a fitted model estimating on features More...
 
void set_dtypes (const vector< char > &dtypes)
 
float get_bias (bool norm_adjust=true) const
 returns bias for linear machines
More...
 
void set_bias (float b)
 
shared_ptr< CLabels > fit_tune (MatrixXf &X, VectorXf &y, const Parameters &params, bool &pass, const vector< char > &dtypes=vector< char >(), bool set_default=false)
 tune algorithm parameters More...
 

Public Attributes

std::map< string, ML_TYPEml_hash
 
shared_ptr< sh::CMachine > p_est
 pointer to the ML object More...
 
ML_TYPE ml_type
 user specified ML type More...
 
string ml_str
 user specified ML type (string) More...
 
sh::EProblemType prob_type
 type of learning problem; binary, multiclass or regression More...
 
Normalizer N
 normalization More...
 
int max_train_time
 max seconds allowed for training More...
 
bool normalize
 control whether ML normalizes its input before training More...
 
float C
 

Private Attributes

vector< char > dtypes
 

Detailed Description

class that specifies the machine learning algorithm to pair with Feat.

Definition at line 79 of file ml.h.

Constructor & Destructor Documentation

◆ ML()

FT::Model::ML::ML ( string  ml = "LinearRidgeRegression",
bool  norm = true,
bool  classification = false,
int  n_classes = 2 
)

use string to specify a desired ML algorithm from shogun.

Definition at line 21 of file ml.cc.

◆ ~ML()

FT::Model::ML::~ML ( )

Definition at line 187 of file ml.cc.

Member Function Documentation

◆ fit()

shared_ptr< CLabels > FT::Model::ML::fit ( const MatrixXf &  X,
const VectorXf &  y,
const Parameters params,
bool &  pass,
const vector< char > &  dtypes = vector<char>() 
)

Trains ml on X, y to generate output yhat = f(X).

Parameters
Xn_features x n_samples matrix
yn_samples vector of training labels
paramsfeat parameters
[out]passreturns True if fit was successful, False if not
dtypesthe data types of features in X
Returns
yhat: n_samples vector of outputs

Definition at line 282 of file ml.cc.

◆ fit_tune()

shared_ptr< CLabels > FT::Model::ML::fit_tune ( MatrixXf &  X,
VectorXf &  y,
const Parameters params,
bool &  pass,
const vector< char > &  dtypes = vector<char>(),
bool  set_default = false 
)

tune algorithm parameters

Definition at line 676 of file ml.cc.

◆ fit_vector()

VectorXf FT::Model::ML::fit_vector ( const MatrixXf &  X,
const VectorXf &  y,
const Parameters params,
bool &  pass,
const vector< char > &  dtypes = vector<char>() 
)

Definition at line 413 of file ml.cc.

◆ get_bias()

float FT::Model::ML::get_bias ( bool  norm_adjust = true) const

returns bias for linear machines

Definition at line 565 of file ml.cc.

◆ get_weights()

vector< float > FT::Model::ML::get_weights ( bool  norm_adjust = true) const
Returns
weight vector from model.

Definition at line 211 of file ml.cc.

◆ init()

void FT::Model::ML::init ( bool  assign_p_est = true)

Definition at line 71 of file ml.cc.

◆ labels_to_vector()

VectorXf FT::Model::ML::labels_to_vector ( const shared_ptr< CLabels > &  labels)

utility function to convert CLabels types to VectorXd types.

Definition at line 539 of file ml.cc.

◆ predict()

shared_ptr< CLabels > FT::Model::ML::predict ( const MatrixXf &  X,
bool  print = false 
)

Definition at line 423 of file ml.cc.

◆ predict_proba()

ArrayXXf FT::Model::ML::predict_proba ( const MatrixXf &  X)

Definition at line 499 of file ml.cc.

◆ predict_vector()

VectorXf FT::Model::ML::predict_vector ( const MatrixXf &  X)

Definition at line 492 of file ml.cc.

◆ retrieve_labels()

shared_ptr< CLabels > FT::Model::ML::retrieve_labels ( CDenseFeatures< float64_t > *  features,
bool  proba,
bool &  pass 
)

returns labels of a fitted model estimating on features

Definition at line 614 of file ml.cc.

◆ set_bias()

void FT::Model::ML::set_bias ( float  b)

Definition at line 600 of file ml.cc.

◆ set_dtypes()

void FT::Model::ML::set_dtypes ( const vector< char > &  dtypes)

Definition at line 192 of file ml.cc.

Member Data Documentation

◆ C

float FT::Model::ML::C

Definition at line 146 of file ml.h.

◆ dtypes

vector<char> FT::Model::ML::dtypes
private

Definition at line 149 of file ml.h.

◆ max_train_time

int FT::Model::ML::max_train_time

max seconds allowed for training

Definition at line 143 of file ml.h.

◆ ml_hash

std::map<string, ML_TYPE> FT::Model::ML::ml_hash

Definition at line 92 of file ml.h.

◆ ml_str

string FT::Model::ML::ml_str

user specified ML type (string)

Definition at line 139 of file ml.h.

◆ ml_type

ML_TYPE FT::Model::ML::ml_type

user specified ML type

Definition at line 138 of file ml.h.

◆ N

Normalizer FT::Model::ML::N

normalization

Definition at line 142 of file ml.h.

◆ normalize

bool FT::Model::ML::normalize

control whether ML normalizes its input before training

Definition at line 144 of file ml.h.

◆ p_est

shared_ptr<sh::CMachine> FT::Model::ML::p_est

pointer to the ML object

Definition at line 137 of file ml.h.

◆ prob_type

sh::EProblemType FT::Model::ML::prob_type

type of learning problem; binary, multiclass or regression

Definition at line 140 of file ml.h.


The documentation for this class was generated from the following files: