OmniSciDB  72c90bc290
 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  {"MLPACK", MLFramework::MLPACK}};
31  const auto itr = ml_framework_map.find(upper_ml_framework_str);
32  if (itr == ml_framework_map.end()) {
33  return MLFramework::INVALID;
34  }
35  return itr->second;
36 }
37 
39 
40 inline KMeansInitStrategy get_kmeans_init_type(const std::string& init_type_str) {
41  const auto upper_init_type_str = to_upper(init_type_str);
42  const static std::map<std::string, KMeansInitStrategy> kmeans_init_type_map = {
43  {"DEFAULT", KMeansInitStrategy::DEFAULT},
44  {"DETERMINISTIC", KMeansInitStrategy::DETERMINISTIC},
45  {"RANDOM", KMeansInitStrategy::RANDOM},
46  {"PLUS_PLUS", KMeansInitStrategy::PLUS_PLUS}};
47  const auto itr = kmeans_init_type_map.find(upper_init_type_str);
48  if (itr == kmeans_init_type_map.end()) {
50  }
51  return itr->second;
52 }
53 
55 
57  const std::string& var_importance_metric_str) {
58  const auto upper_var_importance_metric_str = to_upper(var_importance_metric_str);
59  const static std::map<std::string, VarImportanceMetric> var_importance_metric_map = {
60  {"DEFAULT", VarImportanceMetric::DEFAULT},
61  {"NONE", VarImportanceMetric::NONE},
62  {"MDI", VarImportanceMetric::MDI},
63  {"MDA", VarImportanceMetric::MDA},
64  {"MDA_SCALED", VarImportanceMetric::MDA_SCALED}};
65  const auto itr = var_importance_metric_map.find(upper_var_importance_metric_str);
66  if (itr == var_importance_metric_map.end()) {
68  }
69  return itr->second;
70 }
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)