OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MLTableFunctionsCommon.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc., Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
20 
21 #include <map>
22 
24 
25 inline MLFramework get_ml_framework(const std::string& ml_framework_str) {
26  const auto upper_ml_framework_str = to_upper(ml_framework_str);
27  const static std::map<std::string, MLFramework> ml_framework_map = {
28  {"DEFAULT", MLFramework::DEFAULT},
29  {"ONEDAL", MLFramework::ONEDAL},
30  {"ONEAPI", MLFramework::ONEAPI},
31  {"MLPACK", MLFramework::MLPACK}};
32  const auto itr = ml_framework_map.find(upper_ml_framework_str);
33  if (itr == ml_framework_map.end()) {
34  return MLFramework::INVALID;
35  }
36  return itr->second;
37 }
38 
40 
41 inline KMeansInitStrategy get_kmeans_init_type(const std::string& init_type_str) {
42  const auto upper_init_type_str = to_upper(init_type_str);
43  const static std::map<std::string, KMeansInitStrategy> kmeans_init_type_map = {
44  {"DEFAULT", KMeansInitStrategy::DEFAULT},
45  {"DETERMINISTIC", KMeansInitStrategy::DETERMINISTIC},
46  {"RANDOM", KMeansInitStrategy::RANDOM},
47  {"PLUS_PLUS", KMeansInitStrategy::PLUS_PLUS}};
48  const auto itr = kmeans_init_type_map.find(upper_init_type_str);
49  if (itr == kmeans_init_type_map.end()) {
51  }
52  return itr->second;
53 }
54 
56 
58  const std::string& var_importance_metric_str) {
59  const auto upper_var_importance_metric_str = to_upper(var_importance_metric_str);
60  const static std::map<std::string, VarImportanceMetric> var_importance_metric_map = {
61  {"DEFAULT", VarImportanceMetric::DEFAULT},
62  {"NONE", VarImportanceMetric::NONE},
63  {"MDI", VarImportanceMetric::MDI},
64  {"MDA", VarImportanceMetric::MDA},
65  {"MDA_SCALED", VarImportanceMetric::MDA_SCALED}};
66  const auto itr = var_importance_metric_map.find(upper_var_importance_metric_str);
67  if (itr == var_importance_metric_map.end()) {
69  }
70  return itr->second;
71 }
KMeansInitStrategy get_kmeans_init_type(const std::string &init_type_str)
VarImportanceMetric
MLFramework get_ml_framework(const std::string &ml_framework_str)
KMeansInitStrategy
VarImportanceMetric get_var_importance_metric(const std::string &var_importance_metric_str)
std::string to_upper(const std::string &str)