OpenNN
Open-source neural networks library
Loading...
Searching...
No Matches
opennn::Variable Struct Reference

Single dataset column descriptor: name, role, type, scaler, and optional categories. More...

#include <variable.h>

Public Member Functions

 Variable (const string &={}, const string &="None", const VariableType &=VariableType::Numeric, const string &="MeanStandardDeviation", const vector< string > &={})
 Constructs a Variable with optional name, role, type, scaler and category list.
 
void set (const string &={}, const string &="None", const VariableType &=VariableType::Numeric, const string &="MeanStandardDeviation", const vector< string > &={})
 Resets the Variable fields to the supplied values.
 
const string & get_role () const
 
VariableRole get_role_type () const
 
const string & get_scaler () const
 
ScalerMethod get_scaler_type () const
 
const string & get_type_string () const
 Returns the canonical string name of the Variable type.
 
Index get_categories_number () const
 Returns the number of categories for categorical variables (zero otherwise).
 
void set_scaler (const string &new_scaler)
 
void set_scaler (ScalerMethod new_scaler)
 
void set_role (const string &new_role)
 
void set_role (VariableRole new_role)
 
void set_type (const string &)
 Sets the Variable type from its canonical string name.
 
void set_categories (const vector< string > &new_categories)
 
void from_JSON (const JsonDocument &)
 Loads Variable fields from a JSON document.
 
void to_JSON (JsonWriter &) const
 Writes Variable fields to a JSON writer.
 
bool is_binary () const
 Returns true if the Variable type is Binary.
 
bool is_categorical () const
 Returns true if the Variable type is Categorical.
 
bool is_used () const
 Returns true if the Variable has an active role other than Time.
 
Index feature_count () const
 Returns the number of features generated by this Variable (categories or one).
 
vector< string > get_names () const
 Returns the expanded feature names (one per category for categorical variables).
 

Public Attributes

string name
 
VariableRole role = VariableRole::None
 
VariableType type = VariableType::None
 
vector< string > categories
 
ScalerMethod scaler = ScalerMethod::None
 

Detailed Description

Single dataset column descriptor: name, role, type, scaler, and optional categories.

Constructor & Destructor Documentation

◆ Variable()

opennn::Variable::Variable ( const string & = {},
const string & = "None",
const VariableType & = VariableType::Numeric,
const string & = "MeanStandardDeviation",
const vector< string > & = {} )

Constructs a Variable with optional name, role, type, scaler and category list.

Parameters
nameVariable name.
roleRole string (parsed via string_to_variable_role).
typeVariable data type.
scalerScaler method name (parsed via string_to_scaler_method).
categoriesCategory labels for categorical variables.

Member Function Documentation

◆ feature_count()

Index opennn::Variable::feature_count ( ) const
inline

Returns the number of features generated by this Variable (categories or one).

◆ from_JSON()

void opennn::Variable::from_JSON ( const JsonDocument & )

Loads Variable fields from a JSON document.

◆ get_categories_number()

Index opennn::Variable::get_categories_number ( ) const

Returns the number of categories for categorical variables (zero otherwise).

◆ get_names()

vector< string > opennn::Variable::get_names ( ) const

Returns the expanded feature names (one per category for categorical variables).

◆ get_role()

const string & opennn::Variable::get_role ( ) const
inline

◆ get_role_type()

VariableRole opennn::Variable::get_role_type ( ) const
inline

◆ get_scaler()

const string & opennn::Variable::get_scaler ( ) const
inline

◆ get_scaler_type()

ScalerMethod opennn::Variable::get_scaler_type ( ) const
inline

◆ get_type_string()

const string & opennn::Variable::get_type_string ( ) const

Returns the canonical string name of the Variable type.

◆ is_binary()

bool opennn::Variable::is_binary ( ) const
inline

Returns true if the Variable type is Binary.

◆ is_categorical()

bool opennn::Variable::is_categorical ( ) const
inline

Returns true if the Variable type is Categorical.

◆ is_used()

bool opennn::Variable::is_used ( ) const
inline

Returns true if the Variable has an active role other than Time.

◆ set()

void opennn::Variable::set ( const string & = {},
const string & = "None",
const VariableType & = VariableType::Numeric,
const string & = "MeanStandardDeviation",
const vector< string > & = {} )

Resets the Variable fields to the supplied values.

Parameters
nameVariable name.
roleRole string (parsed via string_to_variable_role).
typeVariable data type.
scalerScaler method name (parsed via string_to_scaler_method).
categoriesCategory labels for categorical variables.

◆ set_categories()

void opennn::Variable::set_categories ( const vector< string > & new_categories)
inline

◆ set_role() [1/2]

void opennn::Variable::set_role ( const string & new_role)
inline

◆ set_role() [2/2]

void opennn::Variable::set_role ( VariableRole new_role)
inline

◆ set_scaler() [1/2]

void opennn::Variable::set_scaler ( const string & new_scaler)
inline

◆ set_scaler() [2/2]

void opennn::Variable::set_scaler ( ScalerMethod new_scaler)
inline

◆ set_type()

void opennn::Variable::set_type ( const string & )

Sets the Variable type from its canonical string name.

◆ to_JSON()

void opennn::Variable::to_JSON ( JsonWriter & ) const

Writes Variable fields to a JSON writer.

Member Data Documentation

◆ categories

vector<string> opennn::Variable::categories

◆ name

string opennn::Variable::name

◆ role

VariableRole opennn::Variable::role = VariableRole::None

◆ scaler

ScalerMethod opennn::Variable::scaler = ScalerMethod::None

◆ type

VariableType opennn::Variable::type = VariableType::None