Turi Create  4.0
turi::v2::ml_data_internal::column_unique_indexer Class Referencefinal

#include <toolkits/ml_data_2/indexing/column_unique_indexer.hpp>

Public Member Functions

 column_unique_indexer ()
 
void initialize ()
 
size_t map_value_to_index (size_t thread_idx, const flexible_type &feature) GL_HOT
 
size_t immutable_map_value_to_index (const flexible_type &feature) const
 
void insert_values_into_index (const std::vector< flexible_type > &features)
 
void register_real_value (const flexible_type &feature)
 
void finalize ()
 
flexible_type map_index_to_value (size_t idx) const
 
std::set< flex_type_enumextract_key_types () const
 
size_t indexed_column_size () const
 
size_t get_version () const
 
void save_impl (turi::oarchive &oarc) const
 
void load_version (turi::iarchive &iarc, size_t version)
 
void set_values (std::vector< flexible_type > &&values)
 
std::shared_ptr< column_indexercreate_cleared_copy () const
 
std::function< flexible_type(const flexible_type &)> deindexing_lambda () const
 
std::function< flexible_type(const flexible_type &)> indexing_lambda () const
 

Static Public Member Functions

static std::shared_ptr< column_indexerfactory_create (const std::map< std::string, variant_type > &creation_options)
 

Public Attributes

std::string column_name
 
ml_column_mode mode
 
flex_type_enum original_column_type
 
std::map< std::string, flexible_typeoptions
 

Detailed Description

column_metadata contains "meta data" concerning indexing of a single column of an SFrame. A collection of meta_data column objects is "all" the metadata required in the ml_data container.

Definition at line 34 of file column_unique_indexer.hpp.

Constructor & Destructor Documentation

◆ column_unique_indexer()

turi::v2::ml_data_internal::column_unique_indexer::column_unique_indexer ( )

Default constructor; does nothing; Initialize from a serialization stream

Member Function Documentation

◆ create_cleared_copy()

std::shared_ptr<column_indexer> turi::v2::ml_data_internal::column_unique_indexer::create_cleared_copy ( ) const
virtual

Create a copy with the index cleared.

Implements turi::v2::ml_data_internal::column_indexer.

◆ deindexing_lambda()

std::function<flexible_type(const flexible_type&)> turi::v2::ml_data_internal::column_unique_indexer::deindexing_lambda ( ) const
virtual

Returns a lambda function that can be used as a lambda function for deindexing a column.

Implements turi::v2::ml_data_internal::column_indexer.

◆ extract_key_types()

std::set<flex_type_enum> turi::v2::ml_data_internal::column_unique_indexer::extract_key_types ( ) const
virtual

Calculates the type of the values held in the index. This may be different from original_column_type – if the original_column_type is a DICT or LIST, this will return a set of the actual types present. If the values are inconsistent, then an error is raised.

This method is useful when a metadata built with a dictionary is also used to map simple categorical variables.

Reimplemented from turi::v2::ml_data_internal::column_indexer.

◆ factory_create()

static std::shared_ptr<column_indexer> turi::v2::ml_data_internal::column_indexer::factory_create ( const std::map< std::string, variant_type > &  creation_options)
staticinherited

The factory method for loading and instantiating the proper class

◆ finalize()

void turi::v2::ml_data_internal::column_unique_indexer::finalize ( )
virtual

Call this when all calls to map_value_to_index are completed.

Implements turi::v2::ml_data_internal::column_indexer.

◆ get_version()

size_t turi::v2::ml_data_internal::column_unique_indexer::get_version ( ) const
virtual

Returns the current version used for the serialization.

Implements turi::v2::ml_data_internal::column_indexer.

◆ immutable_map_value_to_index()

size_t turi::v2::ml_data_internal::column_unique_indexer::immutable_map_value_to_index ( const flexible_type feature) const
virtual

Returns the index associated with the "feature" value.

Note
Only used if is_categorical is true.

If the value in the feature column was already seen, then the index already associated with that value is returned. If not, size_t(-1) is returned.

Parameters
[in]featureThe value in the feature column to map to the index.
Returns
An index associated with the given value. If the index is not present. We return size_t(-1).

Implements turi::v2::ml_data_internal::column_indexer.

◆ indexed_column_size()

size_t turi::v2::ml_data_internal::column_unique_indexer::indexed_column_size ( ) const
inlinevirtual

Returns the size of the column.

Numeric : 1 Categorical : # Unique categories Vector : Size of the vector.

Returns
Column size.

Implements turi::v2::ml_data_internal::column_indexer.

Definition at line 138 of file column_unique_indexer.hpp.

◆ indexing_lambda()

std::function<flexible_type(const flexible_type&)> turi::v2::ml_data_internal::column_unique_indexer::indexing_lambda ( ) const
virtual

Returns a lambda function that can be used as a lambda function for indexing a column.

Does not add any new index values.

Implements turi::v2::ml_data_internal::column_indexer.

◆ initialize()

void turi::v2::ml_data_internal::column_unique_indexer::initialize ( )
virtual

Initialize the index mapping and setup. There are certain internal parallel things that need to be set up before map_value_to_index works. Call this before looping over map_value_to_index, then call finalize() when done.

Implements turi::v2::ml_data_internal::column_indexer.

◆ insert_values_into_index()

void turi::v2::ml_data_internal::column_unique_indexer::insert_values_into_index ( const std::vector< flexible_type > &  features)
virtual

Some of the ml_data tests currently depend on the order of insertion into the index, which is now done in parallel and thus not deterministic. This function allows the user to remove that randomness by inserting all indices in a specified order.

NOTE: This function is not thread safe; only call it from one thread.

Reimplemented from turi::v2::ml_data_internal::column_indexer.

◆ load_version()

void turi::v2::ml_data_internal::column_unique_indexer::load_version ( turi::iarchive iarc,
size_t  version 
)
virtual

Load the object.

Implements turi::v2::ml_data_internal::column_indexer.

◆ map_index_to_value()

flexible_type turi::v2::ml_data_internal::column_unique_indexer::map_index_to_value ( size_t  idx) const
virtual

Returns the feature "value" associated an index.

Note
Only used if is_categorical is true.
Parameters

Reimplemented from turi::v2::ml_data_internal::column_indexer.

◆ map_value_to_index()

size_t turi::v2::ml_data_internal::column_unique_indexer::map_value_to_index ( size_t  thread_idx,
const flexible_type feature 
)
virtual

Returns the index associated with the "feature" value.

Note
Only used if is_categorical is true.

If the value in the feature column was already seen, then the index already associated with that value is returned. If not, a new unique index is added and associated with this feature value.

This method is completely threadsafe and is meant to be called by multiple threads in contention.

Parameters
[in]featureThe value in the feature column to map to the index.
Returns
An index (possibly new) associated with the given value.

Implements turi::v2::ml_data_internal::column_indexer.

◆ register_real_value()

void turi::v2::ml_data_internal::column_unique_indexer::register_real_value ( const flexible_type feature)

When a new value is encountered in translating the data, it should be dealt with through map_value_to_index above if it is categorical, or through register_real_value below if it is numeric. This function handles things like checking the size of the numeric vectors (all must be the same) and setting the column size.

Note that the statistics collection functions below are not always called; hence the error checks in register_real_value can't go there.

◆ save_impl()

void turi::v2::ml_data_internal::column_unique_indexer::save_impl ( turi::oarchive oarc) const
virtual

Serialize the object (save).

Implements turi::v2::ml_data_internal::column_indexer.

◆ set_values()

void turi::v2::ml_data_internal::column_unique_indexer::set_values ( std::vector< flexible_type > &&  values)
virtual

Set data directly.

Implements turi::v2::ml_data_internal::column_indexer.

Member Data Documentation

◆ column_name

std::string turi::v2::ml_data_internal::column_indexer::column_name
inherited

The name of the column.

Definition at line 174 of file column_indexer.hpp.

◆ mode

ml_column_mode turi::v2::ml_data_internal::column_indexer::mode
inherited

The mode of the column;

Definition at line 178 of file column_indexer.hpp.

◆ options

std::map<std::string, flexible_type> turi::v2::ml_data_internal::column_indexer::options
inherited

A map of the options passed in to ml_data. May include options for the indexers.

Definition at line 187 of file column_indexer.hpp.

◆ original_column_type

flex_type_enum turi::v2::ml_data_internal::column_indexer::original_column_type
inherited

Original column type

Definition at line 182 of file column_indexer.hpp.


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