diff --git a/src/FeaturizerPrep/SharedLibrary/GeneratedCode/SharedLibrary_RobustScalarFeaturizer.cpp b/src/FeaturizerPrep/SharedLibrary/GeneratedCode/SharedLibrary_RobustScalarFeaturizer.cpp new file mode 100644 index 0000000..eb9ad98 --- /dev/null +++ b/src/FeaturizerPrep/SharedLibrary/GeneratedCode/SharedLibrary_RobustScalarFeaturizer.cpp @@ -0,0 +1,3130 @@ +/* ---------------------------------------------------------------------- */ +/* Copyright (c) Microsoft Corporation. All rights reserved. */ +/* Licensed under the MIT License */ +/* ---------------------------------------------------------------------- */ +#define DLL_EXPORT_COMPILE + +#include "SharedLibrary_RobustScalarFeaturizer.h" +#include "SharedLibrary_PointerTable.h" + +#include "Archive.h" +#include "RobustScalarFeaturizer.h" + +// These method(s) are defined in SharedLibrary_Common.cpp +ErrorInfoHandle * CreateErrorInfo(std::exception const &ex); + +extern "C" { + +// I don't know why MSVC thinks that there is unreachable +// code in these methods during release builds. +#if (defined _MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4702) // Unreachable code +#endif + +/* ---------------------------------------------------------------------- */ +/* | */ +/* | RobustScalarFeaturizer */ +/* | */ +/* ---------------------------------------------------------------------- */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_int8_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + // No validation + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer* pEstimator = new Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer(std::make_shared(1)); + size_t index(g_pointerTable.Add(pEstimator)); + *ppHandle = reinterpret_cast(index); + + + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_int8_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer * pEstimator = g_pointerTable.Get>(index); + g_pointerTable.Remove(index); + + delete pEstimator; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_int8_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pIsTrainingComplete == nullptr) throw std::invalid_argument("'pIsTrainingComplete' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer const & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pIsTrainingComplete = estimator.is_training_complete(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_Fit(/*in*/ RobustScalarFeaturizer_int8_t_EstimatorHandle *pHandle, /*in*/ int8_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + // No validation + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pFitResult = static_cast(estimator.fit(input)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_FitBuffer(/*in*/ RobustScalarFeaturizer_int8_t_EstimatorHandle *pHandle, /*in*/ int8_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + if(input_ptr == nullptr) throw std::invalid_argument("'input_ptr' is null"); + if(input_items == 0) throw std::invalid_argument("'input_items' is 0"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.fit(input_ptr, input_items)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_int8_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.complete_training()); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_int8_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_int8_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pEstimatorHandle == nullptr) throw std::invalid_argument("'pEstimatorHandle' is null"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pEstimatorHandle))); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType * pTransformer = reinterpret_cast::TransformerType*>(estimator.create_transformer().release()); + + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_int8_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + Microsoft::Featurizer::Archive archive(pBuffer, cBufferSize); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer= (std::make_unique::TransformerType>(archive).release()); + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_int8_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer = g_pointerTable.Get::TransformerType>(index); + g_pointerTable.Remove(index); + + + delete pTransformer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_int8_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(ppBuffer == nullptr) throw std::invalid_argument("'ppBuffer' is null"); + if(pBufferSize == nullptr) throw std::invalid_argument("'pBufferSize' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + Microsoft::Featurizer::Archive archive; + + transformer.save(archive); + + Microsoft::Featurizer::Archive::ByteArray const buffer(archive.commit()); + + unsigned char * new_buffer(new unsigned char[buffer.size()]); + + std::copy(buffer.begin(), buffer.end(), new_buffer); + + *ppBuffer = new_buffer; + *pBufferSize = buffer.size(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + + delete [] pBuffer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_Transform(/*in*/ RobustScalarFeaturizer_int8_t_TransformerHandle *pHandle, /*in*/ int8_t input, /*out*/ float * output, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + + // No input validation + if(output == nullptr) throw std::invalid_argument("'output' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + + // Input + auto result(transformer.execute(input)); + + // Output + *output = result; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +/* ---------------------------------------------------------------------- */ +/* | */ +/* | RobustScalarFeaturizer */ +/* | */ +/* ---------------------------------------------------------------------- */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_int16_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + // No validation + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer* pEstimator = new Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer(std::make_shared(1)); + size_t index(g_pointerTable.Add(pEstimator)); + *ppHandle = reinterpret_cast(index); + + + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_int16_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer * pEstimator = g_pointerTable.Get>(index); + g_pointerTable.Remove(index); + + delete pEstimator; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_int16_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pIsTrainingComplete == nullptr) throw std::invalid_argument("'pIsTrainingComplete' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer const & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pIsTrainingComplete = estimator.is_training_complete(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_Fit(/*in*/ RobustScalarFeaturizer_int16_t_EstimatorHandle *pHandle, /*in*/ int16_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + // No validation + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pFitResult = static_cast(estimator.fit(input)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_FitBuffer(/*in*/ RobustScalarFeaturizer_int16_t_EstimatorHandle *pHandle, /*in*/ int16_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + if(input_ptr == nullptr) throw std::invalid_argument("'input_ptr' is null"); + if(input_items == 0) throw std::invalid_argument("'input_items' is 0"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.fit(input_ptr, input_items)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_int16_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.complete_training()); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_int16_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_int16_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pEstimatorHandle == nullptr) throw std::invalid_argument("'pEstimatorHandle' is null"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pEstimatorHandle))); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType * pTransformer = reinterpret_cast::TransformerType*>(estimator.create_transformer().release()); + + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_int16_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + Microsoft::Featurizer::Archive archive(pBuffer, cBufferSize); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer= (std::make_unique::TransformerType>(archive).release()); + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_int16_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer = g_pointerTable.Get::TransformerType>(index); + g_pointerTable.Remove(index); + + + delete pTransformer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_int16_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(ppBuffer == nullptr) throw std::invalid_argument("'ppBuffer' is null"); + if(pBufferSize == nullptr) throw std::invalid_argument("'pBufferSize' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + Microsoft::Featurizer::Archive archive; + + transformer.save(archive); + + Microsoft::Featurizer::Archive::ByteArray const buffer(archive.commit()); + + unsigned char * new_buffer(new unsigned char[buffer.size()]); + + std::copy(buffer.begin(), buffer.end(), new_buffer); + + *ppBuffer = new_buffer; + *pBufferSize = buffer.size(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + + delete [] pBuffer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_Transform(/*in*/ RobustScalarFeaturizer_int16_t_TransformerHandle *pHandle, /*in*/ int16_t input, /*out*/ float * output, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + + // No input validation + if(output == nullptr) throw std::invalid_argument("'output' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + + // Input + auto result(transformer.execute(input)); + + // Output + *output = result; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +/* ---------------------------------------------------------------------- */ +/* | */ +/* | RobustScalarFeaturizer */ +/* | */ +/* ---------------------------------------------------------------------- */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + // No validation + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer* pEstimator = new Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer(std::make_shared(1)); + size_t index(g_pointerTable.Add(pEstimator)); + *ppHandle = reinterpret_cast(index); + + + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer * pEstimator = g_pointerTable.Get>(index); + g_pointerTable.Remove(index); + + delete pEstimator; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pIsTrainingComplete == nullptr) throw std::invalid_argument("'pIsTrainingComplete' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer const & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pIsTrainingComplete = estimator.is_training_complete(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_Fit(/*in*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle *pHandle, /*in*/ uint8_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + // No validation + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pFitResult = static_cast(estimator.fit(input)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_FitBuffer(/*in*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle *pHandle, /*in*/ uint8_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + if(input_ptr == nullptr) throw std::invalid_argument("'input_ptr' is null"); + if(input_items == 0) throw std::invalid_argument("'input_items' is 0"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.fit(input_ptr, input_items)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.complete_training()); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_uint8_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pEstimatorHandle == nullptr) throw std::invalid_argument("'pEstimatorHandle' is null"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pEstimatorHandle))); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType * pTransformer = reinterpret_cast::TransformerType*>(estimator.create_transformer().release()); + + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_uint8_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + Microsoft::Featurizer::Archive archive(pBuffer, cBufferSize); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer= (std::make_unique::TransformerType>(archive).release()); + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_uint8_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer = g_pointerTable.Get::TransformerType>(index); + g_pointerTable.Remove(index); + + + delete pTransformer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_uint8_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(ppBuffer == nullptr) throw std::invalid_argument("'ppBuffer' is null"); + if(pBufferSize == nullptr) throw std::invalid_argument("'pBufferSize' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + Microsoft::Featurizer::Archive archive; + + transformer.save(archive); + + Microsoft::Featurizer::Archive::ByteArray const buffer(archive.commit()); + + unsigned char * new_buffer(new unsigned char[buffer.size()]); + + std::copy(buffer.begin(), buffer.end(), new_buffer); + + *ppBuffer = new_buffer; + *pBufferSize = buffer.size(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + + delete [] pBuffer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_Transform(/*in*/ RobustScalarFeaturizer_uint8_t_TransformerHandle *pHandle, /*in*/ uint8_t input, /*out*/ float * output, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + + // No input validation + if(output == nullptr) throw std::invalid_argument("'output' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + + // Input + auto result(transformer.execute(input)); + + // Output + *output = result; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +/* ---------------------------------------------------------------------- */ +/* | */ +/* | RobustScalarFeaturizer */ +/* | */ +/* ---------------------------------------------------------------------- */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + // No validation + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer* pEstimator = new Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer(std::make_shared(1)); + size_t index(g_pointerTable.Add(pEstimator)); + *ppHandle = reinterpret_cast(index); + + + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer * pEstimator = g_pointerTable.Get>(index); + g_pointerTable.Remove(index); + + delete pEstimator; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pIsTrainingComplete == nullptr) throw std::invalid_argument("'pIsTrainingComplete' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer const & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pIsTrainingComplete = estimator.is_training_complete(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_Fit(/*in*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle *pHandle, /*in*/ uint16_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + // No validation + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pFitResult = static_cast(estimator.fit(input)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_FitBuffer(/*in*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle *pHandle, /*in*/ uint16_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + if(input_ptr == nullptr) throw std::invalid_argument("'input_ptr' is null"); + if(input_items == 0) throw std::invalid_argument("'input_items' is 0"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.fit(input_ptr, input_items)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.complete_training()); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_uint16_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pEstimatorHandle == nullptr) throw std::invalid_argument("'pEstimatorHandle' is null"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pEstimatorHandle))); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType * pTransformer = reinterpret_cast::TransformerType*>(estimator.create_transformer().release()); + + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_uint16_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + Microsoft::Featurizer::Archive archive(pBuffer, cBufferSize); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer= (std::make_unique::TransformerType>(archive).release()); + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_uint16_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer = g_pointerTable.Get::TransformerType>(index); + g_pointerTable.Remove(index); + + + delete pTransformer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_uint16_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(ppBuffer == nullptr) throw std::invalid_argument("'ppBuffer' is null"); + if(pBufferSize == nullptr) throw std::invalid_argument("'pBufferSize' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + Microsoft::Featurizer::Archive archive; + + transformer.save(archive); + + Microsoft::Featurizer::Archive::ByteArray const buffer(archive.commit()); + + unsigned char * new_buffer(new unsigned char[buffer.size()]); + + std::copy(buffer.begin(), buffer.end(), new_buffer); + + *ppBuffer = new_buffer; + *pBufferSize = buffer.size(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + + delete [] pBuffer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_Transform(/*in*/ RobustScalarFeaturizer_uint16_t_TransformerHandle *pHandle, /*in*/ uint16_t input, /*out*/ float * output, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + + // No input validation + if(output == nullptr) throw std::invalid_argument("'output' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + + // Input + auto result(transformer.execute(input)); + + // Output + *output = result; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +/* ---------------------------------------------------------------------- */ +/* | */ +/* | RobustScalarFeaturizer */ +/* | */ +/* ---------------------------------------------------------------------- */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_float_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + // No validation + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer* pEstimator = new Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer(std::make_shared(1)); + size_t index(g_pointerTable.Add(pEstimator)); + *ppHandle = reinterpret_cast(index); + + + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_float_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer * pEstimator = g_pointerTable.Get>(index); + g_pointerTable.Remove(index); + + delete pEstimator; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_float_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pIsTrainingComplete == nullptr) throw std::invalid_argument("'pIsTrainingComplete' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer const & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pIsTrainingComplete = estimator.is_training_complete(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_Fit(/*in*/ RobustScalarFeaturizer_float_t_EstimatorHandle *pHandle, /*in*/ float input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + // No validation + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pFitResult = static_cast(estimator.fit(input)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_FitBuffer(/*in*/ RobustScalarFeaturizer_float_t_EstimatorHandle *pHandle, /*in*/ float const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + if(input_ptr == nullptr) throw std::invalid_argument("'input_ptr' is null"); + if(input_items == 0) throw std::invalid_argument("'input_items' is 0"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.fit(input_ptr, input_items)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_float_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.complete_training()); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_float_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_float_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pEstimatorHandle == nullptr) throw std::invalid_argument("'pEstimatorHandle' is null"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pEstimatorHandle))); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType * pTransformer = reinterpret_cast::TransformerType*>(estimator.create_transformer().release()); + + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_float_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + Microsoft::Featurizer::Archive archive(pBuffer, cBufferSize); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer= (std::make_unique::TransformerType>(archive).release()); + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_float_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer = g_pointerTable.Get::TransformerType>(index); + g_pointerTable.Remove(index); + + + delete pTransformer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_float_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(ppBuffer == nullptr) throw std::invalid_argument("'ppBuffer' is null"); + if(pBufferSize == nullptr) throw std::invalid_argument("'pBufferSize' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + Microsoft::Featurizer::Archive archive; + + transformer.save(archive); + + Microsoft::Featurizer::Archive::ByteArray const buffer(archive.commit()); + + unsigned char * new_buffer(new unsigned char[buffer.size()]); + + std::copy(buffer.begin(), buffer.end(), new_buffer); + + *ppBuffer = new_buffer; + *pBufferSize = buffer.size(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + + delete [] pBuffer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_Transform(/*in*/ RobustScalarFeaturizer_float_t_TransformerHandle *pHandle, /*in*/ float input, /*out*/ float * output, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + + // No input validation + if(output == nullptr) throw std::invalid_argument("'output' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + + // Input + auto result(transformer.execute(input)); + + // Output + *output = result; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +/* ---------------------------------------------------------------------- */ +/* | */ +/* | RobustScalarFeaturizer */ +/* | */ +/* ---------------------------------------------------------------------- */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_int32_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + // No validation + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer* pEstimator = new Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer(std::make_shared(1)); + size_t index(g_pointerTable.Add(pEstimator)); + *ppHandle = reinterpret_cast(index); + + + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_int32_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer * pEstimator = g_pointerTable.Get>(index); + g_pointerTable.Remove(index); + + delete pEstimator; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_int32_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pIsTrainingComplete == nullptr) throw std::invalid_argument("'pIsTrainingComplete' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer const & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pIsTrainingComplete = estimator.is_training_complete(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_Fit(/*in*/ RobustScalarFeaturizer_int32_t_EstimatorHandle *pHandle, /*in*/ int32_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + // No validation + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pFitResult = static_cast(estimator.fit(input)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_FitBuffer(/*in*/ RobustScalarFeaturizer_int32_t_EstimatorHandle *pHandle, /*in*/ int32_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + if(input_ptr == nullptr) throw std::invalid_argument("'input_ptr' is null"); + if(input_items == 0) throw std::invalid_argument("'input_items' is 0"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.fit(input_ptr, input_items)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_int32_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.complete_training()); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_int32_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_int32_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pEstimatorHandle == nullptr) throw std::invalid_argument("'pEstimatorHandle' is null"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pEstimatorHandle))); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType * pTransformer = reinterpret_cast::TransformerType*>(estimator.create_transformer().release()); + + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_int32_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + Microsoft::Featurizer::Archive archive(pBuffer, cBufferSize); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer= (std::make_unique::TransformerType>(archive).release()); + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_int32_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer = g_pointerTable.Get::TransformerType>(index); + g_pointerTable.Remove(index); + + + delete pTransformer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_int32_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(ppBuffer == nullptr) throw std::invalid_argument("'ppBuffer' is null"); + if(pBufferSize == nullptr) throw std::invalid_argument("'pBufferSize' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + Microsoft::Featurizer::Archive archive; + + transformer.save(archive); + + Microsoft::Featurizer::Archive::ByteArray const buffer(archive.commit()); + + unsigned char * new_buffer(new unsigned char[buffer.size()]); + + std::copy(buffer.begin(), buffer.end(), new_buffer); + + *ppBuffer = new_buffer; + *pBufferSize = buffer.size(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + + delete [] pBuffer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_Transform(/*in*/ RobustScalarFeaturizer_int32_t_TransformerHandle *pHandle, /*in*/ int32_t input, /*out*/ double * output, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + + // No input validation + if(output == nullptr) throw std::invalid_argument("'output' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + + // Input + auto result(transformer.execute(input)); + + // Output + *output = result; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +/* ---------------------------------------------------------------------- */ +/* | */ +/* | RobustScalarFeaturizer */ +/* | */ +/* ---------------------------------------------------------------------- */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_int64_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + // No validation + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer* pEstimator = new Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer(std::make_shared(1)); + size_t index(g_pointerTable.Add(pEstimator)); + *ppHandle = reinterpret_cast(index); + + + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_int64_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer * pEstimator = g_pointerTable.Get>(index); + g_pointerTable.Remove(index); + + delete pEstimator; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_int64_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pIsTrainingComplete == nullptr) throw std::invalid_argument("'pIsTrainingComplete' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer const & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pIsTrainingComplete = estimator.is_training_complete(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_Fit(/*in*/ RobustScalarFeaturizer_int64_t_EstimatorHandle *pHandle, /*in*/ int64_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + // No validation + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pFitResult = static_cast(estimator.fit(input)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_FitBuffer(/*in*/ RobustScalarFeaturizer_int64_t_EstimatorHandle *pHandle, /*in*/ int64_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + if(input_ptr == nullptr) throw std::invalid_argument("'input_ptr' is null"); + if(input_items == 0) throw std::invalid_argument("'input_items' is 0"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.fit(input_ptr, input_items)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_int64_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.complete_training()); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_int64_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_int64_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pEstimatorHandle == nullptr) throw std::invalid_argument("'pEstimatorHandle' is null"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pEstimatorHandle))); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType * pTransformer = reinterpret_cast::TransformerType*>(estimator.create_transformer().release()); + + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_int64_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + Microsoft::Featurizer::Archive archive(pBuffer, cBufferSize); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer= (std::make_unique::TransformerType>(archive).release()); + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_int64_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer = g_pointerTable.Get::TransformerType>(index); + g_pointerTable.Remove(index); + + + delete pTransformer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_int64_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(ppBuffer == nullptr) throw std::invalid_argument("'ppBuffer' is null"); + if(pBufferSize == nullptr) throw std::invalid_argument("'pBufferSize' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + Microsoft::Featurizer::Archive archive; + + transformer.save(archive); + + Microsoft::Featurizer::Archive::ByteArray const buffer(archive.commit()); + + unsigned char * new_buffer(new unsigned char[buffer.size()]); + + std::copy(buffer.begin(), buffer.end(), new_buffer); + + *ppBuffer = new_buffer; + *pBufferSize = buffer.size(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + + delete [] pBuffer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_Transform(/*in*/ RobustScalarFeaturizer_int64_t_TransformerHandle *pHandle, /*in*/ int64_t input, /*out*/ double * output, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + + // No input validation + if(output == nullptr) throw std::invalid_argument("'output' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + + // Input + auto result(transformer.execute(input)); + + // Output + *output = result; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +/* ---------------------------------------------------------------------- */ +/* | */ +/* | RobustScalarFeaturizer */ +/* | */ +/* ---------------------------------------------------------------------- */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + // No validation + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer* pEstimator = new Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer(std::make_shared(1)); + size_t index(g_pointerTable.Add(pEstimator)); + *ppHandle = reinterpret_cast(index); + + + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer * pEstimator = g_pointerTable.Get>(index); + g_pointerTable.Remove(index); + + delete pEstimator; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pIsTrainingComplete == nullptr) throw std::invalid_argument("'pIsTrainingComplete' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer const & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pIsTrainingComplete = estimator.is_training_complete(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_Fit(/*in*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle *pHandle, /*in*/ uint32_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + // No validation + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pFitResult = static_cast(estimator.fit(input)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_FitBuffer(/*in*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle *pHandle, /*in*/ uint32_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + if(input_ptr == nullptr) throw std::invalid_argument("'input_ptr' is null"); + if(input_items == 0) throw std::invalid_argument("'input_items' is 0"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.fit(input_ptr, input_items)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.complete_training()); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_uint32_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pEstimatorHandle == nullptr) throw std::invalid_argument("'pEstimatorHandle' is null"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pEstimatorHandle))); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType * pTransformer = reinterpret_cast::TransformerType*>(estimator.create_transformer().release()); + + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_uint32_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + Microsoft::Featurizer::Archive archive(pBuffer, cBufferSize); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer= (std::make_unique::TransformerType>(archive).release()); + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_uint32_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer = g_pointerTable.Get::TransformerType>(index); + g_pointerTable.Remove(index); + + + delete pTransformer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_uint32_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(ppBuffer == nullptr) throw std::invalid_argument("'ppBuffer' is null"); + if(pBufferSize == nullptr) throw std::invalid_argument("'pBufferSize' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + Microsoft::Featurizer::Archive archive; + + transformer.save(archive); + + Microsoft::Featurizer::Archive::ByteArray const buffer(archive.commit()); + + unsigned char * new_buffer(new unsigned char[buffer.size()]); + + std::copy(buffer.begin(), buffer.end(), new_buffer); + + *ppBuffer = new_buffer; + *pBufferSize = buffer.size(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + + delete [] pBuffer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_Transform(/*in*/ RobustScalarFeaturizer_uint32_t_TransformerHandle *pHandle, /*in*/ uint32_t input, /*out*/ double * output, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + + // No input validation + if(output == nullptr) throw std::invalid_argument("'output' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + + // Input + auto result(transformer.execute(input)); + + // Output + *output = result; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +/* ---------------------------------------------------------------------- */ +/* | */ +/* | RobustScalarFeaturizer */ +/* | */ +/* ---------------------------------------------------------------------- */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + // No validation + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer* pEstimator = new Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer(std::make_shared(1)); + size_t index(g_pointerTable.Add(pEstimator)); + *ppHandle = reinterpret_cast(index); + + + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer * pEstimator = g_pointerTable.Get>(index); + g_pointerTable.Remove(index); + + delete pEstimator; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pIsTrainingComplete == nullptr) throw std::invalid_argument("'pIsTrainingComplete' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer const & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pIsTrainingComplete = estimator.is_training_complete(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_Fit(/*in*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle *pHandle, /*in*/ uint64_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + // No validation + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pFitResult = static_cast(estimator.fit(input)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_FitBuffer(/*in*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle *pHandle, /*in*/ uint64_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + if(input_ptr == nullptr) throw std::invalid_argument("'input_ptr' is null"); + if(input_items == 0) throw std::invalid_argument("'input_items' is 0"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.fit(input_ptr, input_items)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.complete_training()); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_uint64_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pEstimatorHandle == nullptr) throw std::invalid_argument("'pEstimatorHandle' is null"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pEstimatorHandle))); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType * pTransformer = reinterpret_cast::TransformerType*>(estimator.create_transformer().release()); + + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_uint64_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + Microsoft::Featurizer::Archive archive(pBuffer, cBufferSize); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer= (std::make_unique::TransformerType>(archive).release()); + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_uint64_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer = g_pointerTable.Get::TransformerType>(index); + g_pointerTable.Remove(index); + + + delete pTransformer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_uint64_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(ppBuffer == nullptr) throw std::invalid_argument("'ppBuffer' is null"); + if(pBufferSize == nullptr) throw std::invalid_argument("'pBufferSize' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + Microsoft::Featurizer::Archive archive; + + transformer.save(archive); + + Microsoft::Featurizer::Archive::ByteArray const buffer(archive.commit()); + + unsigned char * new_buffer(new unsigned char[buffer.size()]); + + std::copy(buffer.begin(), buffer.end(), new_buffer); + + *ppBuffer = new_buffer; + *pBufferSize = buffer.size(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + + delete [] pBuffer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_Transform(/*in*/ RobustScalarFeaturizer_uint64_t_TransformerHandle *pHandle, /*in*/ uint64_t input, /*out*/ double * output, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + + // No input validation + if(output == nullptr) throw std::invalid_argument("'output' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + + // Input + auto result(transformer.execute(input)); + + // Output + *output = result; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +/* ---------------------------------------------------------------------- */ +/* | */ +/* | RobustScalarFeaturizer */ +/* | */ +/* ---------------------------------------------------------------------- */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_double_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + // No validation + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer* pEstimator = new Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer(std::make_shared(1)); + size_t index(g_pointerTable.Add(pEstimator)); + *ppHandle = reinterpret_cast(index); + + + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_double_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer * pEstimator = g_pointerTable.Get>(index); + g_pointerTable.Remove(index); + + delete pEstimator; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_double_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pIsTrainingComplete == nullptr) throw std::invalid_argument("'pIsTrainingComplete' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer const & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pIsTrainingComplete = estimator.is_training_complete(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_Fit(/*in*/ RobustScalarFeaturizer_double_t_EstimatorHandle *pHandle, /*in*/ double input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + // No validation + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + + *pFitResult = static_cast(estimator.fit(input)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_FitBuffer(/*in*/ RobustScalarFeaturizer_double_t_EstimatorHandle *pHandle, /*in*/ double const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + if(input_ptr == nullptr) throw std::invalid_argument("'input_ptr' is null"); + if(input_items == 0) throw std::invalid_argument("'input_items' is 0"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.fit(input_ptr, input_items)); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_double_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(pFitResult == nullptr) throw std::invalid_argument("'pFitResult' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pHandle))); + + *pFitResult = static_cast(estimator.complete_training()); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_double_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_double_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pEstimatorHandle == nullptr) throw std::invalid_argument("'pEstimatorHandle' is null"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer & estimator(*g_pointerTable.Get>(reinterpret_cast(pEstimatorHandle))); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType * pTransformer = reinterpret_cast::TransformerType*>(estimator.create_transformer().release()); + + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_double_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + if(ppTransformerHandle == nullptr) throw std::invalid_argument("'ppTransformerHandle' is null"); + + Microsoft::Featurizer::Archive archive(pBuffer, cBufferSize); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer= (std::make_unique::TransformerType>(archive).release()); + + size_t index = g_pointerTable.Add(pTransformer); + *ppTransformerHandle = reinterpret_cast(index); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_double_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + size_t index = reinterpret_cast(pHandle); + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType* pTransformer = g_pointerTable.Get::TransformerType>(index); + g_pointerTable.Remove(index); + + + delete pTransformer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_double_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + if(ppBuffer == nullptr) throw std::invalid_argument("'ppBuffer' is null"); + if(pBufferSize == nullptr) throw std::invalid_argument("'pBufferSize' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + Microsoft::Featurizer::Archive archive; + + transformer.save(archive); + + Microsoft::Featurizer::Archive::ByteArray const buffer(archive.commit()); + + unsigned char * new_buffer(new unsigned char[buffer.size()]); + + std::copy(buffer.begin(), buffer.end(), new_buffer); + + *ppBuffer = new_buffer; + *pBufferSize = buffer.size(); + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pBuffer == nullptr) throw std::invalid_argument("'pBuffer' is null"); + if(cBufferSize == 0) throw std::invalid_argument("'cBufferSize' is 0"); + + delete [] pBuffer; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_Transform(/*in*/ RobustScalarFeaturizer_double_t_TransformerHandle *pHandle, /*in*/ double input, /*out*/ double * output, /*out*/ ErrorInfoHandle **ppErrorInfo) { + if(ppErrorInfo == nullptr) + return false; + + try { + *ppErrorInfo = nullptr; + + if(pHandle == nullptr) throw std::invalid_argument("'pHandle' is null"); + + + // No input validation + if(output == nullptr) throw std::invalid_argument("'output' is null"); + + Microsoft::Featurizer::Featurizers::RobustScalarFeaturizer::TransformerType & transformer(*g_pointerTable.Get::TransformerType>(reinterpret_cast(pHandle))); + + // Input + auto result(transformer.execute(input)); + + // Output + *output = result; + + return true; + } + catch(std::exception const &ex) { + *ppErrorInfo = CreateErrorInfo(ex); + return false; + } +} + + +#if (defined _MSC_VER) +# pragma warning(pop) +#endif + +} // extern "C" diff --git a/src/FeaturizerPrep/SharedLibrary/GeneratedCode/SharedLibrary_RobustScalarFeaturizer.h b/src/FeaturizerPrep/SharedLibrary/GeneratedCode/SharedLibrary_RobustScalarFeaturizer.h new file mode 100644 index 0000000..6662ca4 --- /dev/null +++ b/src/FeaturizerPrep/SharedLibrary/GeneratedCode/SharedLibrary_RobustScalarFeaturizer.h @@ -0,0 +1,251 @@ +/* ---------------------------------------------------------------------- */ +/* Copyright (c) Microsoft Corporation. All rights reserved. */ +/* Licensed under the MIT License */ +/* ---------------------------------------------------------------------- */ +#pragma once + +#include "SharedLibrary_Common.h" + +extern "C" { + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +struct RobustScalarFeaturizer_int8_t_EstimatorHandle {}; +struct RobustScalarFeaturizer_int8_t_TransformerHandle {}; + +/* Training Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_int8_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_int8_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_int8_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_Fit(/*in*/ RobustScalarFeaturizer_int8_t_EstimatorHandle *pHandle, /*in*/ int8_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_FitBuffer(/*in*/ RobustScalarFeaturizer_int8_t_EstimatorHandle *pHandle, /*in*/ int8_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_int8_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* Inference Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_int8_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_int8_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_int8_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_int8_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_int8_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int8_t_Transform(/*in*/ RobustScalarFeaturizer_int8_t_TransformerHandle *pHandle, /*in*/ int8_t input, /*out*/ float * output, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +struct RobustScalarFeaturizer_int16_t_EstimatorHandle {}; +struct RobustScalarFeaturizer_int16_t_TransformerHandle {}; + +/* Training Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_int16_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_int16_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_int16_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_Fit(/*in*/ RobustScalarFeaturizer_int16_t_EstimatorHandle *pHandle, /*in*/ int16_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_FitBuffer(/*in*/ RobustScalarFeaturizer_int16_t_EstimatorHandle *pHandle, /*in*/ int16_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_int16_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* Inference Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_int16_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_int16_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_int16_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_int16_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_int16_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int16_t_Transform(/*in*/ RobustScalarFeaturizer_int16_t_TransformerHandle *pHandle, /*in*/ int16_t input, /*out*/ float * output, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +struct RobustScalarFeaturizer_uint8_t_EstimatorHandle {}; +struct RobustScalarFeaturizer_uint8_t_TransformerHandle {}; + +/* Training Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_Fit(/*in*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle *pHandle, /*in*/ uint8_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_FitBuffer(/*in*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle *pHandle, /*in*/ uint8_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* Inference Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_uint8_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_uint8_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_uint8_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_uint8_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_uint8_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint8_t_Transform(/*in*/ RobustScalarFeaturizer_uint8_t_TransformerHandle *pHandle, /*in*/ uint8_t input, /*out*/ float * output, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +struct RobustScalarFeaturizer_uint16_t_EstimatorHandle {}; +struct RobustScalarFeaturizer_uint16_t_TransformerHandle {}; + +/* Training Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_Fit(/*in*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle *pHandle, /*in*/ uint16_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_FitBuffer(/*in*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle *pHandle, /*in*/ uint16_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* Inference Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_uint16_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_uint16_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_uint16_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_uint16_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_uint16_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint16_t_Transform(/*in*/ RobustScalarFeaturizer_uint16_t_TransformerHandle *pHandle, /*in*/ uint16_t input, /*out*/ float * output, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +struct RobustScalarFeaturizer_float_t_EstimatorHandle {}; +struct RobustScalarFeaturizer_float_t_TransformerHandle {}; + +/* Training Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_float_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_float_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_float_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_Fit(/*in*/ RobustScalarFeaturizer_float_t_EstimatorHandle *pHandle, /*in*/ float input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_FitBuffer(/*in*/ RobustScalarFeaturizer_float_t_EstimatorHandle *pHandle, /*in*/ float const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_float_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* Inference Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_float_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_float_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_float_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_float_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_float_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_float_t_Transform(/*in*/ RobustScalarFeaturizer_float_t_TransformerHandle *pHandle, /*in*/ float input, /*out*/ float * output, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +struct RobustScalarFeaturizer_int32_t_EstimatorHandle {}; +struct RobustScalarFeaturizer_int32_t_TransformerHandle {}; + +/* Training Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_int32_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_int32_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_int32_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_Fit(/*in*/ RobustScalarFeaturizer_int32_t_EstimatorHandle *pHandle, /*in*/ int32_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_FitBuffer(/*in*/ RobustScalarFeaturizer_int32_t_EstimatorHandle *pHandle, /*in*/ int32_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_int32_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* Inference Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_int32_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_int32_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_int32_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_int32_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_int32_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int32_t_Transform(/*in*/ RobustScalarFeaturizer_int32_t_TransformerHandle *pHandle, /*in*/ int32_t input, /*out*/ double * output, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +struct RobustScalarFeaturizer_int64_t_EstimatorHandle {}; +struct RobustScalarFeaturizer_int64_t_TransformerHandle {}; + +/* Training Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_int64_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_int64_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_int64_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_Fit(/*in*/ RobustScalarFeaturizer_int64_t_EstimatorHandle *pHandle, /*in*/ int64_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_FitBuffer(/*in*/ RobustScalarFeaturizer_int64_t_EstimatorHandle *pHandle, /*in*/ int64_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_int64_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* Inference Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_int64_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_int64_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_int64_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_int64_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_int64_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_int64_t_Transform(/*in*/ RobustScalarFeaturizer_int64_t_TransformerHandle *pHandle, /*in*/ int64_t input, /*out*/ double * output, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +struct RobustScalarFeaturizer_uint32_t_EstimatorHandle {}; +struct RobustScalarFeaturizer_uint32_t_TransformerHandle {}; + +/* Training Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_Fit(/*in*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle *pHandle, /*in*/ uint32_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_FitBuffer(/*in*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle *pHandle, /*in*/ uint32_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* Inference Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_uint32_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_uint32_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_uint32_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_uint32_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_uint32_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint32_t_Transform(/*in*/ RobustScalarFeaturizer_uint32_t_TransformerHandle *pHandle, /*in*/ uint32_t input, /*out*/ double * output, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +struct RobustScalarFeaturizer_uint64_t_EstimatorHandle {}; +struct RobustScalarFeaturizer_uint64_t_TransformerHandle {}; + +/* Training Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_Fit(/*in*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle *pHandle, /*in*/ uint64_t input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_FitBuffer(/*in*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle *pHandle, /*in*/ uint64_t const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* Inference Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_uint64_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_uint64_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_uint64_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_uint64_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_uint64_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_uint64_t_Transform(/*in*/ RobustScalarFeaturizer_uint64_t_TransformerHandle *pHandle, /*in*/ uint64_t input, /*out*/ double * output, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +struct RobustScalarFeaturizer_double_t_EstimatorHandle {}; +struct RobustScalarFeaturizer_double_t_TransformerHandle {}; + +/* Training Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_CreateEstimator(/*out*/ RobustScalarFeaturizer_double_t_EstimatorHandle **ppHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_DestroyEstimator(/*in*/ RobustScalarFeaturizer_double_t_EstimatorHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_IsTrainingComplete(/*in*/ RobustScalarFeaturizer_double_t_EstimatorHandle *pHandle, /*out*/ bool *pIsTrainingComplete, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_Fit(/*in*/ RobustScalarFeaturizer_double_t_EstimatorHandle *pHandle, /*in*/ double input, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_FitBuffer(/*in*/ RobustScalarFeaturizer_double_t_EstimatorHandle *pHandle, /*in*/ double const * input_ptr, /*in*/ std::size_t input_items, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_CompleteTraining(/*in*/ RobustScalarFeaturizer_double_t_EstimatorHandle *pHandle, /*out*/ FitResult *pFitResult, /*out*/ ErrorInfoHandle **ppErrorInfo); + +/* Inference Methods */ +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_CreateTransformerFromEstimator(/*in*/ RobustScalarFeaturizer_double_t_EstimatorHandle *pEstimatorHandle, /*out*/ RobustScalarFeaturizer_double_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_CreateTransformerFromSavedData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ RobustScalarFeaturizer_double_t_TransformerHandle **ppTransformerHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_DestroyTransformer(/*in*/ RobustScalarFeaturizer_double_t_TransformerHandle *pHandle, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_CreateTransformerSaveData(/*in*/ RobustScalarFeaturizer_double_t_TransformerHandle *pHandle, /*out*/ unsigned char const **ppBuffer, /*out*/ std::size_t *pBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_DestroyTransformerSaveData(/*in*/ unsigned char const *pBuffer, /*in*/ std::size_t cBufferSize, /*out*/ ErrorInfoHandle **ppErrorInfo); + +FEATURIZER_LIBRARY_API bool RobustScalarFeaturizer_double_t_Transform(/*in*/ RobustScalarFeaturizer_double_t_TransformerHandle *pHandle, /*in*/ double input, /*out*/ double * output, /*out*/ ErrorInfoHandle **ppErrorInfo); + +} // extern "C" diff --git a/src/FeaturizerPrep/SharedLibrary/IntegrationTests/GeneratedCode/SharedLibraryTests_RobustScalarFeaturizer.h b/src/FeaturizerPrep/SharedLibrary/IntegrationTests/GeneratedCode/SharedLibraryTests_RobustScalarFeaturizer.h new file mode 100644 index 0000000..07c7687 --- /dev/null +++ b/src/FeaturizerPrep/SharedLibrary/IntegrationTests/GeneratedCode/SharedLibraryTests_RobustScalarFeaturizer.h @@ -0,0 +1,1039 @@ +/* ---------------------------------------------------------------------- */ +/* Copyright (c) Microsoft Corporation. All rights reserved. */ +/* Licensed under the MIT License */ +/* ---------------------------------------------------------------------- */ +#pragma once + +#include "SharedLibrary_RobustScalarFeaturizer.h" +#include "Traits.h" + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +template +void RobustScalarFeaturizer_int8_t_Test( + std::vector const &training_input, + std::vector const &inference_input, + std::function const &)> const &verify_func +) { + ErrorInfoHandle * pErrorInfo(nullptr); + + // Create the estimator + RobustScalarFeaturizer_int8_t_EstimatorHandle *pEstimatorHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_int8_t_CreateEstimator(&pEstimatorHandle, &pErrorInfo)); + REQUIRE(pEstimatorHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Train + if(training_input.empty() == false) { + typename std::vector::const_iterator iter(training_input.begin()); + + while(true) { + FitResult result(Continue); + auto const & input(*iter); + + REQUIRE(RobustScalarFeaturizer_int8_t_Fit(pEstimatorHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + + if(result == Continue) { + ++iter; + + if(iter != training_input.end()) + continue; + + REQUIRE(RobustScalarFeaturizer_int8_t_CompleteTraining(pEstimatorHandle, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + } + + INFO("Value is " << result) + REQUIRE(false); + } + } + + // Once here, training should be complete + { + bool is_complete(false); + + REQUIRE(RobustScalarFeaturizer_int8_t_IsTrainingComplete(pEstimatorHandle, &is_complete, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + REQUIRE(is_complete); + } + + // Create the Transformer + RobustScalarFeaturizer_int8_t_TransformerHandle * pTransformerHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_int8_t_CreateTransformerFromEstimator(pEstimatorHandle, &pTransformerHandle, &pErrorInfo)); + REQUIRE(pTransformerHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Destroy the estimator + REQUIRE(RobustScalarFeaturizer_int8_t_DestroyEstimator(pEstimatorHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + // Inference + std::vector results; + + results.reserve(inference_input.size()); + + for(auto const & input : inference_input) { + std::float_t result; + + REQUIRE(RobustScalarFeaturizer_int8_t_Transform(pTransformerHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + results.emplace_back(std::move(result)); + // No inline destroy statement + } + + REQUIRE(verify_func(results)); + + // No trailing destroy statement + + // Destroy the transformer + REQUIRE(RobustScalarFeaturizer_int8_t_DestroyTransformer(pTransformerHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); +} + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +template +void RobustScalarFeaturizer_int16_t_Test( + std::vector const &training_input, + std::vector const &inference_input, + std::function const &)> const &verify_func +) { + ErrorInfoHandle * pErrorInfo(nullptr); + + // Create the estimator + RobustScalarFeaturizer_int16_t_EstimatorHandle *pEstimatorHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_int16_t_CreateEstimator(&pEstimatorHandle, &pErrorInfo)); + REQUIRE(pEstimatorHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Train + if(training_input.empty() == false) { + typename std::vector::const_iterator iter(training_input.begin()); + + while(true) { + FitResult result(Continue); + auto const & input(*iter); + + REQUIRE(RobustScalarFeaturizer_int16_t_Fit(pEstimatorHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + + if(result == Continue) { + ++iter; + + if(iter != training_input.end()) + continue; + + REQUIRE(RobustScalarFeaturizer_int16_t_CompleteTraining(pEstimatorHandle, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + } + + INFO("Value is " << result) + REQUIRE(false); + } + } + + // Once here, training should be complete + { + bool is_complete(false); + + REQUIRE(RobustScalarFeaturizer_int16_t_IsTrainingComplete(pEstimatorHandle, &is_complete, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + REQUIRE(is_complete); + } + + // Create the Transformer + RobustScalarFeaturizer_int16_t_TransformerHandle * pTransformerHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_int16_t_CreateTransformerFromEstimator(pEstimatorHandle, &pTransformerHandle, &pErrorInfo)); + REQUIRE(pTransformerHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Destroy the estimator + REQUIRE(RobustScalarFeaturizer_int16_t_DestroyEstimator(pEstimatorHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + // Inference + std::vector results; + + results.reserve(inference_input.size()); + + for(auto const & input : inference_input) { + std::float_t result; + + REQUIRE(RobustScalarFeaturizer_int16_t_Transform(pTransformerHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + results.emplace_back(std::move(result)); + // No inline destroy statement + } + + REQUIRE(verify_func(results)); + + // No trailing destroy statement + + // Destroy the transformer + REQUIRE(RobustScalarFeaturizer_int16_t_DestroyTransformer(pTransformerHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); +} + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +template +void RobustScalarFeaturizer_uint8_t_Test( + std::vector const &training_input, + std::vector const &inference_input, + std::function const &)> const &verify_func +) { + ErrorInfoHandle * pErrorInfo(nullptr); + + // Create the estimator + RobustScalarFeaturizer_uint8_t_EstimatorHandle *pEstimatorHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_uint8_t_CreateEstimator(&pEstimatorHandle, &pErrorInfo)); + REQUIRE(pEstimatorHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Train + if(training_input.empty() == false) { + typename std::vector::const_iterator iter(training_input.begin()); + + while(true) { + FitResult result(Continue); + auto const & input(*iter); + + REQUIRE(RobustScalarFeaturizer_uint8_t_Fit(pEstimatorHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + + if(result == Continue) { + ++iter; + + if(iter != training_input.end()) + continue; + + REQUIRE(RobustScalarFeaturizer_uint8_t_CompleteTraining(pEstimatorHandle, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + } + + INFO("Value is " << result) + REQUIRE(false); + } + } + + // Once here, training should be complete + { + bool is_complete(false); + + REQUIRE(RobustScalarFeaturizer_uint8_t_IsTrainingComplete(pEstimatorHandle, &is_complete, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + REQUIRE(is_complete); + } + + // Create the Transformer + RobustScalarFeaturizer_uint8_t_TransformerHandle * pTransformerHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_uint8_t_CreateTransformerFromEstimator(pEstimatorHandle, &pTransformerHandle, &pErrorInfo)); + REQUIRE(pTransformerHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Destroy the estimator + REQUIRE(RobustScalarFeaturizer_uint8_t_DestroyEstimator(pEstimatorHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + // Inference + std::vector results; + + results.reserve(inference_input.size()); + + for(auto const & input : inference_input) { + std::float_t result; + + REQUIRE(RobustScalarFeaturizer_uint8_t_Transform(pTransformerHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + results.emplace_back(std::move(result)); + // No inline destroy statement + } + + REQUIRE(verify_func(results)); + + // No trailing destroy statement + + // Destroy the transformer + REQUIRE(RobustScalarFeaturizer_uint8_t_DestroyTransformer(pTransformerHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); +} + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +template +void RobustScalarFeaturizer_uint16_t_Test( + std::vector const &training_input, + std::vector const &inference_input, + std::function const &)> const &verify_func +) { + ErrorInfoHandle * pErrorInfo(nullptr); + + // Create the estimator + RobustScalarFeaturizer_uint16_t_EstimatorHandle *pEstimatorHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_uint16_t_CreateEstimator(&pEstimatorHandle, &pErrorInfo)); + REQUIRE(pEstimatorHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Train + if(training_input.empty() == false) { + typename std::vector::const_iterator iter(training_input.begin()); + + while(true) { + FitResult result(Continue); + auto const & input(*iter); + + REQUIRE(RobustScalarFeaturizer_uint16_t_Fit(pEstimatorHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + + if(result == Continue) { + ++iter; + + if(iter != training_input.end()) + continue; + + REQUIRE(RobustScalarFeaturizer_uint16_t_CompleteTraining(pEstimatorHandle, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + } + + INFO("Value is " << result) + REQUIRE(false); + } + } + + // Once here, training should be complete + { + bool is_complete(false); + + REQUIRE(RobustScalarFeaturizer_uint16_t_IsTrainingComplete(pEstimatorHandle, &is_complete, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + REQUIRE(is_complete); + } + + // Create the Transformer + RobustScalarFeaturizer_uint16_t_TransformerHandle * pTransformerHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_uint16_t_CreateTransformerFromEstimator(pEstimatorHandle, &pTransformerHandle, &pErrorInfo)); + REQUIRE(pTransformerHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Destroy the estimator + REQUIRE(RobustScalarFeaturizer_uint16_t_DestroyEstimator(pEstimatorHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + // Inference + std::vector results; + + results.reserve(inference_input.size()); + + for(auto const & input : inference_input) { + std::float_t result; + + REQUIRE(RobustScalarFeaturizer_uint16_t_Transform(pTransformerHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + results.emplace_back(std::move(result)); + // No inline destroy statement + } + + REQUIRE(verify_func(results)); + + // No trailing destroy statement + + // Destroy the transformer + REQUIRE(RobustScalarFeaturizer_uint16_t_DestroyTransformer(pTransformerHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); +} + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +template +void RobustScalarFeaturizer_float_t_Test( + std::vector const &training_input, + std::vector const &inference_input, + std::function const &)> const &verify_func +) { + ErrorInfoHandle * pErrorInfo(nullptr); + + // Create the estimator + RobustScalarFeaturizer_float_t_EstimatorHandle *pEstimatorHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_float_t_CreateEstimator(&pEstimatorHandle, &pErrorInfo)); + REQUIRE(pEstimatorHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Train + if(training_input.empty() == false) { + typename std::vector::const_iterator iter(training_input.begin()); + + while(true) { + FitResult result(Continue); + auto const & input(*iter); + + REQUIRE(RobustScalarFeaturizer_float_t_Fit(pEstimatorHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + + if(result == Continue) { + ++iter; + + if(iter != training_input.end()) + continue; + + REQUIRE(RobustScalarFeaturizer_float_t_CompleteTraining(pEstimatorHandle, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + } + + INFO("Value is " << result) + REQUIRE(false); + } + } + + // Once here, training should be complete + { + bool is_complete(false); + + REQUIRE(RobustScalarFeaturizer_float_t_IsTrainingComplete(pEstimatorHandle, &is_complete, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + REQUIRE(is_complete); + } + + // Create the Transformer + RobustScalarFeaturizer_float_t_TransformerHandle * pTransformerHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_float_t_CreateTransformerFromEstimator(pEstimatorHandle, &pTransformerHandle, &pErrorInfo)); + REQUIRE(pTransformerHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Destroy the estimator + REQUIRE(RobustScalarFeaturizer_float_t_DestroyEstimator(pEstimatorHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + // Inference + std::vector results; + + results.reserve(inference_input.size()); + + for(auto const & input : inference_input) { + std::float_t result; + + REQUIRE(RobustScalarFeaturizer_float_t_Transform(pTransformerHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + results.emplace_back(std::move(result)); + // No inline destroy statement + } + + REQUIRE(verify_func(results)); + + // No trailing destroy statement + + // Destroy the transformer + REQUIRE(RobustScalarFeaturizer_float_t_DestroyTransformer(pTransformerHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); +} + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +template +void RobustScalarFeaturizer_int32_t_Test( + std::vector const &training_input, + std::vector const &inference_input, + std::function const &)> const &verify_func +) { + ErrorInfoHandle * pErrorInfo(nullptr); + + // Create the estimator + RobustScalarFeaturizer_int32_t_EstimatorHandle *pEstimatorHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_int32_t_CreateEstimator(&pEstimatorHandle, &pErrorInfo)); + REQUIRE(pEstimatorHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Train + if(training_input.empty() == false) { + typename std::vector::const_iterator iter(training_input.begin()); + + while(true) { + FitResult result(Continue); + auto const & input(*iter); + + REQUIRE(RobustScalarFeaturizer_int32_t_Fit(pEstimatorHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + + if(result == Continue) { + ++iter; + + if(iter != training_input.end()) + continue; + + REQUIRE(RobustScalarFeaturizer_int32_t_CompleteTraining(pEstimatorHandle, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + } + + INFO("Value is " << result) + REQUIRE(false); + } + } + + // Once here, training should be complete + { + bool is_complete(false); + + REQUIRE(RobustScalarFeaturizer_int32_t_IsTrainingComplete(pEstimatorHandle, &is_complete, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + REQUIRE(is_complete); + } + + // Create the Transformer + RobustScalarFeaturizer_int32_t_TransformerHandle * pTransformerHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_int32_t_CreateTransformerFromEstimator(pEstimatorHandle, &pTransformerHandle, &pErrorInfo)); + REQUIRE(pTransformerHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Destroy the estimator + REQUIRE(RobustScalarFeaturizer_int32_t_DestroyEstimator(pEstimatorHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + // Inference + std::vector results; + + results.reserve(inference_input.size()); + + for(auto const & input : inference_input) { + std::double_t result; + + REQUIRE(RobustScalarFeaturizer_int32_t_Transform(pTransformerHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + results.emplace_back(std::move(result)); + // No inline destroy statement + } + + REQUIRE(verify_func(results)); + + // No trailing destroy statement + + // Destroy the transformer + REQUIRE(RobustScalarFeaturizer_int32_t_DestroyTransformer(pTransformerHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); +} + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +template +void RobustScalarFeaturizer_int64_t_Test( + std::vector const &training_input, + std::vector const &inference_input, + std::function const &)> const &verify_func +) { + ErrorInfoHandle * pErrorInfo(nullptr); + + // Create the estimator + RobustScalarFeaturizer_int64_t_EstimatorHandle *pEstimatorHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_int64_t_CreateEstimator(&pEstimatorHandle, &pErrorInfo)); + REQUIRE(pEstimatorHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Train + if(training_input.empty() == false) { + typename std::vector::const_iterator iter(training_input.begin()); + + while(true) { + FitResult result(Continue); + auto const & input(*iter); + + REQUIRE(RobustScalarFeaturizer_int64_t_Fit(pEstimatorHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + + if(result == Continue) { + ++iter; + + if(iter != training_input.end()) + continue; + + REQUIRE(RobustScalarFeaturizer_int64_t_CompleteTraining(pEstimatorHandle, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + } + + INFO("Value is " << result) + REQUIRE(false); + } + } + + // Once here, training should be complete + { + bool is_complete(false); + + REQUIRE(RobustScalarFeaturizer_int64_t_IsTrainingComplete(pEstimatorHandle, &is_complete, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + REQUIRE(is_complete); + } + + // Create the Transformer + RobustScalarFeaturizer_int64_t_TransformerHandle * pTransformerHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_int64_t_CreateTransformerFromEstimator(pEstimatorHandle, &pTransformerHandle, &pErrorInfo)); + REQUIRE(pTransformerHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Destroy the estimator + REQUIRE(RobustScalarFeaturizer_int64_t_DestroyEstimator(pEstimatorHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + // Inference + std::vector results; + + results.reserve(inference_input.size()); + + for(auto const & input : inference_input) { + std::double_t result; + + REQUIRE(RobustScalarFeaturizer_int64_t_Transform(pTransformerHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + results.emplace_back(std::move(result)); + // No inline destroy statement + } + + REQUIRE(verify_func(results)); + + // No trailing destroy statement + + // Destroy the transformer + REQUIRE(RobustScalarFeaturizer_int64_t_DestroyTransformer(pTransformerHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); +} + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +template +void RobustScalarFeaturizer_uint32_t_Test( + std::vector const &training_input, + std::vector const &inference_input, + std::function const &)> const &verify_func +) { + ErrorInfoHandle * pErrorInfo(nullptr); + + // Create the estimator + RobustScalarFeaturizer_uint32_t_EstimatorHandle *pEstimatorHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_uint32_t_CreateEstimator(&pEstimatorHandle, &pErrorInfo)); + REQUIRE(pEstimatorHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Train + if(training_input.empty() == false) { + typename std::vector::const_iterator iter(training_input.begin()); + + while(true) { + FitResult result(Continue); + auto const & input(*iter); + + REQUIRE(RobustScalarFeaturizer_uint32_t_Fit(pEstimatorHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + + if(result == Continue) { + ++iter; + + if(iter != training_input.end()) + continue; + + REQUIRE(RobustScalarFeaturizer_uint32_t_CompleteTraining(pEstimatorHandle, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + } + + INFO("Value is " << result) + REQUIRE(false); + } + } + + // Once here, training should be complete + { + bool is_complete(false); + + REQUIRE(RobustScalarFeaturizer_uint32_t_IsTrainingComplete(pEstimatorHandle, &is_complete, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + REQUIRE(is_complete); + } + + // Create the Transformer + RobustScalarFeaturizer_uint32_t_TransformerHandle * pTransformerHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_uint32_t_CreateTransformerFromEstimator(pEstimatorHandle, &pTransformerHandle, &pErrorInfo)); + REQUIRE(pTransformerHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Destroy the estimator + REQUIRE(RobustScalarFeaturizer_uint32_t_DestroyEstimator(pEstimatorHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + // Inference + std::vector results; + + results.reserve(inference_input.size()); + + for(auto const & input : inference_input) { + std::double_t result; + + REQUIRE(RobustScalarFeaturizer_uint32_t_Transform(pTransformerHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + results.emplace_back(std::move(result)); + // No inline destroy statement + } + + REQUIRE(verify_func(results)); + + // No trailing destroy statement + + // Destroy the transformer + REQUIRE(RobustScalarFeaturizer_uint32_t_DestroyTransformer(pTransformerHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); +} + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +template +void RobustScalarFeaturizer_uint64_t_Test( + std::vector const &training_input, + std::vector const &inference_input, + std::function const &)> const &verify_func +) { + ErrorInfoHandle * pErrorInfo(nullptr); + + // Create the estimator + RobustScalarFeaturizer_uint64_t_EstimatorHandle *pEstimatorHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_uint64_t_CreateEstimator(&pEstimatorHandle, &pErrorInfo)); + REQUIRE(pEstimatorHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Train + if(training_input.empty() == false) { + typename std::vector::const_iterator iter(training_input.begin()); + + while(true) { + FitResult result(Continue); + auto const & input(*iter); + + REQUIRE(RobustScalarFeaturizer_uint64_t_Fit(pEstimatorHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + + if(result == Continue) { + ++iter; + + if(iter != training_input.end()) + continue; + + REQUIRE(RobustScalarFeaturizer_uint64_t_CompleteTraining(pEstimatorHandle, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + } + + INFO("Value is " << result) + REQUIRE(false); + } + } + + // Once here, training should be complete + { + bool is_complete(false); + + REQUIRE(RobustScalarFeaturizer_uint64_t_IsTrainingComplete(pEstimatorHandle, &is_complete, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + REQUIRE(is_complete); + } + + // Create the Transformer + RobustScalarFeaturizer_uint64_t_TransformerHandle * pTransformerHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_uint64_t_CreateTransformerFromEstimator(pEstimatorHandle, &pTransformerHandle, &pErrorInfo)); + REQUIRE(pTransformerHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Destroy the estimator + REQUIRE(RobustScalarFeaturizer_uint64_t_DestroyEstimator(pEstimatorHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + // Inference + std::vector results; + + results.reserve(inference_input.size()); + + for(auto const & input : inference_input) { + std::double_t result; + + REQUIRE(RobustScalarFeaturizer_uint64_t_Transform(pTransformerHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + results.emplace_back(std::move(result)); + // No inline destroy statement + } + + REQUIRE(verify_func(results)); + + // No trailing destroy statement + + // Destroy the transformer + REQUIRE(RobustScalarFeaturizer_uint64_t_DestroyTransformer(pTransformerHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); +} + +/* ---------------------------------------------------------------------- */ +/* | RobustScalarFeaturizer */ +template +void RobustScalarFeaturizer_double_t_Test( + std::vector const &training_input, + std::vector const &inference_input, + std::function const &)> const &verify_func +) { + ErrorInfoHandle * pErrorInfo(nullptr); + + // Create the estimator + RobustScalarFeaturizer_double_t_EstimatorHandle *pEstimatorHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_double_t_CreateEstimator(&pEstimatorHandle, &pErrorInfo)); + REQUIRE(pEstimatorHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Train + if(training_input.empty() == false) { + typename std::vector::const_iterator iter(training_input.begin()); + + while(true) { + FitResult result(Continue); + auto const & input(*iter); + + REQUIRE(RobustScalarFeaturizer_double_t_Fit(pEstimatorHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + + if(result == Continue) { + ++iter; + + if(iter != training_input.end()) + continue; + + REQUIRE(RobustScalarFeaturizer_double_t_CompleteTraining(pEstimatorHandle, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + if(result == Complete) + break; + + if(result == ResetAndContinue) { + iter = training_input.begin(); + continue; + } + } + + INFO("Value is " << result) + REQUIRE(false); + } + } + + // Once here, training should be complete + { + bool is_complete(false); + + REQUIRE(RobustScalarFeaturizer_double_t_IsTrainingComplete(pEstimatorHandle, &is_complete, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + REQUIRE(is_complete); + } + + // Create the Transformer + RobustScalarFeaturizer_double_t_TransformerHandle * pTransformerHandle(nullptr); + + REQUIRE(RobustScalarFeaturizer_double_t_CreateTransformerFromEstimator(pEstimatorHandle, &pTransformerHandle, &pErrorInfo)); + REQUIRE(pTransformerHandle != nullptr); + REQUIRE(pErrorInfo == nullptr); + + // Destroy the estimator + REQUIRE(RobustScalarFeaturizer_double_t_DestroyEstimator(pEstimatorHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + // Inference + std::vector results; + + results.reserve(inference_input.size()); + + for(auto const & input : inference_input) { + std::double_t result; + + REQUIRE(RobustScalarFeaturizer_double_t_Transform(pTransformerHandle, input, &result, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); + + results.emplace_back(std::move(result)); + // No inline destroy statement + } + + REQUIRE(verify_func(results)); + + // No trailing destroy statement + + // Destroy the transformer + REQUIRE(RobustScalarFeaturizer_double_t_DestroyTransformer(pTransformerHandle, &pErrorInfo)); + REQUIRE(pErrorInfo == nullptr); +} + diff --git a/src/FeaturizerPrep/Tools/CodeGenerator/Featurizers.SimpleSchema b/src/FeaturizerPrep/Tools/CodeGenerator/Featurizers.SimpleSchema index 8d6edc0..51040bf 100644 --- a/src/FeaturizerPrep/Tools/CodeGenerator/Featurizers.SimpleSchema +++ b/src/FeaturizerPrep/Tools/CodeGenerator/Featurizers.SimpleSchema @@ -14,12 +14,13 @@ -