teradataml 17.20.0.7__py3-none-any.whl → 20.0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of teradataml might be problematic. Click here for more details.

Files changed (1303) hide show
  1. teradataml/LICENSE-3RD-PARTY.pdf +0 -0
  2. teradataml/LICENSE.pdf +0 -0
  3. teradataml/README.md +1935 -1640
  4. teradataml/__init__.py +70 -60
  5. teradataml/_version.py +11 -11
  6. teradataml/analytics/Transformations.py +2995 -2995
  7. teradataml/analytics/__init__.py +81 -83
  8. teradataml/analytics/analytic_function_executor.py +2040 -2010
  9. teradataml/analytics/analytic_query_generator.py +958 -958
  10. teradataml/analytics/byom/H2OPredict.py +514 -514
  11. teradataml/analytics/byom/PMMLPredict.py +437 -437
  12. teradataml/analytics/byom/__init__.py +14 -14
  13. teradataml/analytics/json_parser/__init__.py +130 -130
  14. teradataml/analytics/json_parser/analytic_functions_argument.py +1707 -1707
  15. teradataml/analytics/json_parser/json_store.py +191 -191
  16. teradataml/analytics/json_parser/metadata.py +1637 -1637
  17. teradataml/analytics/json_parser/utils.py +798 -803
  18. teradataml/analytics/meta_class.py +196 -196
  19. teradataml/analytics/sqle/DecisionTreePredict.py +455 -470
  20. teradataml/analytics/sqle/NaiveBayesPredict.py +419 -428
  21. teradataml/analytics/sqle/__init__.py +97 -110
  22. teradataml/analytics/sqle/json/decisiontreepredict_sqle.json +78 -78
  23. teradataml/analytics/sqle/json/naivebayespredict_sqle.json +62 -62
  24. teradataml/analytics/table_operator/__init__.py +10 -10
  25. teradataml/analytics/uaf/__init__.py +63 -63
  26. teradataml/analytics/utils.py +693 -692
  27. teradataml/analytics/valib.py +1603 -1600
  28. teradataml/automl/__init__.py +1683 -0
  29. teradataml/automl/custom_json_utils.py +1270 -0
  30. teradataml/automl/data_preparation.py +1011 -0
  31. teradataml/automl/data_transformation.py +789 -0
  32. teradataml/automl/feature_engineering.py +1580 -0
  33. teradataml/automl/feature_exploration.py +554 -0
  34. teradataml/automl/model_evaluation.py +151 -0
  35. teradataml/automl/model_training.py +1026 -0
  36. teradataml/catalog/__init__.py +1 -3
  37. teradataml/catalog/byom.py +1759 -1716
  38. teradataml/catalog/function_argument_mapper.py +859 -861
  39. teradataml/catalog/model_cataloging_utils.py +491 -1510
  40. teradataml/clients/auth_client.py +133 -0
  41. teradataml/clients/pkce_client.py +481 -481
  42. teradataml/common/aed_utils.py +7 -2
  43. teradataml/common/bulk_exposed_utils.py +111 -111
  44. teradataml/common/constants.py +1438 -1441
  45. teradataml/common/deprecations.py +160 -0
  46. teradataml/common/exceptions.py +73 -73
  47. teradataml/common/formula.py +742 -742
  48. teradataml/common/garbagecollector.py +597 -635
  49. teradataml/common/messagecodes.py +424 -431
  50. teradataml/common/messages.py +228 -231
  51. teradataml/common/sqlbundle.py +693 -693
  52. teradataml/common/td_coltype_code_to_tdtype.py +48 -48
  53. teradataml/common/utils.py +2424 -2500
  54. teradataml/common/warnings.py +25 -25
  55. teradataml/common/wrapper_utils.py +1 -110
  56. teradataml/config/dummy_file1.cfg +4 -4
  57. teradataml/config/dummy_file2.cfg +2 -2
  58. teradataml/config/sqlengine_alias_definitions_v1.0 +13 -13
  59. teradataml/config/sqlengine_alias_definitions_v1.1 +19 -19
  60. teradataml/config/sqlengine_alias_definitions_v1.3 +18 -18
  61. teradataml/context/aed_context.py +217 -217
  62. teradataml/context/context.py +1091 -999
  63. teradataml/data/A_loan.csv +19 -19
  64. teradataml/data/BINARY_REALS_LEFT.csv +11 -11
  65. teradataml/data/BINARY_REALS_RIGHT.csv +11 -11
  66. teradataml/data/B_loan.csv +49 -49
  67. teradataml/data/BuoyData2.csv +17 -17
  68. teradataml/data/CONVOLVE2_COMPLEX_LEFT.csv +5 -5
  69. teradataml/data/CONVOLVE2_COMPLEX_RIGHT.csv +5 -5
  70. teradataml/data/Convolve2RealsLeft.csv +5 -5
  71. teradataml/data/Convolve2RealsRight.csv +5 -5
  72. teradataml/data/Convolve2ValidLeft.csv +11 -11
  73. teradataml/data/Convolve2ValidRight.csv +11 -11
  74. teradataml/data/DFFTConv_Real_8_8.csv +65 -65
  75. teradataml/data/Orders1_12mf.csv +24 -24
  76. teradataml/data/Pi_loan.csv +7 -7
  77. teradataml/data/SMOOTHED_DATA.csv +7 -7
  78. teradataml/data/TestDFFT8.csv +9 -9
  79. teradataml/data/TestRiver.csv +109 -109
  80. teradataml/data/Traindata.csv +28 -28
  81. teradataml/data/acf.csv +17 -17
  82. teradataml/data/adaboost_example.json +34 -34
  83. teradataml/data/adaboostpredict_example.json +24 -24
  84. teradataml/data/additional_table.csv +10 -10
  85. teradataml/data/admissions_test.csv +21 -21
  86. teradataml/data/admissions_train.csv +41 -41
  87. teradataml/data/admissions_train_nulls.csv +41 -41
  88. teradataml/data/advertising.csv +201 -0
  89. teradataml/data/ageandheight.csv +13 -13
  90. teradataml/data/ageandpressure.csv +31 -31
  91. teradataml/data/antiselect_example.json +36 -36
  92. teradataml/data/antiselect_input.csv +8 -8
  93. teradataml/data/antiselect_input_mixed_case.csv +8 -8
  94. teradataml/data/applicant_external.csv +6 -6
  95. teradataml/data/applicant_reference.csv +6 -6
  96. teradataml/data/arima_example.json +9 -9
  97. teradataml/data/assortedtext_input.csv +8 -8
  98. teradataml/data/attribution_example.json +33 -33
  99. teradataml/data/attribution_sample_table.csv +27 -27
  100. teradataml/data/attribution_sample_table1.csv +6 -6
  101. teradataml/data/attribution_sample_table2.csv +11 -11
  102. teradataml/data/bank_churn.csv +10001 -0
  103. teradataml/data/bank_marketing.csv +11163 -0
  104. teradataml/data/bank_web_clicks1.csv +42 -42
  105. teradataml/data/bank_web_clicks2.csv +91 -91
  106. teradataml/data/bank_web_url.csv +85 -85
  107. teradataml/data/barrier.csv +2 -2
  108. teradataml/data/barrier_new.csv +3 -3
  109. teradataml/data/betweenness_example.json +13 -13
  110. teradataml/data/bike_sharing.csv +732 -0
  111. teradataml/data/bin_breaks.csv +8 -8
  112. teradataml/data/bin_fit_ip.csv +3 -3
  113. teradataml/data/binary_complex_left.csv +11 -11
  114. teradataml/data/binary_complex_right.csv +11 -11
  115. teradataml/data/binary_matrix_complex_left.csv +21 -21
  116. teradataml/data/binary_matrix_complex_right.csv +21 -21
  117. teradataml/data/binary_matrix_real_left.csv +21 -21
  118. teradataml/data/binary_matrix_real_right.csv +21 -21
  119. teradataml/data/blood2ageandweight.csv +26 -26
  120. teradataml/data/bmi.csv +501 -0
  121. teradataml/data/boston.csv +507 -507
  122. teradataml/data/boston2cols.csv +721 -0
  123. teradataml/data/breast_cancer.csv +570 -0
  124. teradataml/data/buoydata_mix.csv +11 -11
  125. teradataml/data/burst_data.csv +5 -5
  126. teradataml/data/burst_example.json +20 -20
  127. teradataml/data/byom_example.json +17 -17
  128. teradataml/data/bytes_table.csv +3 -3
  129. teradataml/data/cal_housing_ex_raw.csv +70 -70
  130. teradataml/data/callers.csv +7 -7
  131. teradataml/data/calls.csv +10 -10
  132. teradataml/data/cars_hist.csv +33 -33
  133. teradataml/data/cat_table.csv +24 -24
  134. teradataml/data/ccm_example.json +31 -31
  135. teradataml/data/ccm_input.csv +91 -91
  136. teradataml/data/ccm_input2.csv +13 -13
  137. teradataml/data/ccmexample.csv +101 -101
  138. teradataml/data/ccmprepare_example.json +8 -8
  139. teradataml/data/ccmprepare_input.csv +91 -91
  140. teradataml/data/cfilter_example.json +12 -12
  141. teradataml/data/changepointdetection_example.json +18 -18
  142. teradataml/data/changepointdetectionrt_example.json +8 -8
  143. teradataml/data/chi_sq.csv +2 -2
  144. teradataml/data/churn_data.csv +14 -14
  145. teradataml/data/churn_emission.csv +35 -35
  146. teradataml/data/churn_initial.csv +3 -3
  147. teradataml/data/churn_state_transition.csv +5 -5
  148. teradataml/data/citedges_2.csv +745 -745
  149. teradataml/data/citvertices_2.csv +1210 -1210
  150. teradataml/data/clicks2.csv +16 -16
  151. teradataml/data/clickstream.csv +12 -12
  152. teradataml/data/clickstream1.csv +11 -11
  153. teradataml/data/closeness_example.json +15 -15
  154. teradataml/data/complaints.csv +21 -21
  155. teradataml/data/complaints_mini.csv +3 -3
  156. teradataml/data/complaints_testtoken.csv +224 -224
  157. teradataml/data/complaints_tokens_test.csv +353 -353
  158. teradataml/data/complaints_traintoken.csv +472 -472
  159. teradataml/data/computers_category.csv +1001 -1001
  160. teradataml/data/computers_test1.csv +1252 -1252
  161. teradataml/data/computers_train1.csv +5009 -5009
  162. teradataml/data/computers_train1_clustered.csv +5009 -5009
  163. teradataml/data/confusionmatrix_example.json +9 -9
  164. teradataml/data/conversion_event_table.csv +3 -3
  165. teradataml/data/corr_input.csv +17 -17
  166. teradataml/data/correlation_example.json +11 -11
  167. teradataml/data/coxhazardratio_example.json +39 -39
  168. teradataml/data/coxph_example.json +15 -15
  169. teradataml/data/coxsurvival_example.json +28 -28
  170. teradataml/data/cpt.csv +41 -41
  171. teradataml/data/credit_ex_merged.csv +45 -45
  172. teradataml/data/customer_loyalty.csv +301 -301
  173. teradataml/data/customer_loyalty_newseq.csv +31 -31
  174. teradataml/data/customer_segmentation_test.csv +2628 -0
  175. teradataml/data/customer_segmentation_train.csv +8069 -0
  176. teradataml/data/dataframe_example.json +146 -146
  177. teradataml/data/decisionforest_example.json +37 -37
  178. teradataml/data/decisionforestpredict_example.json +38 -38
  179. teradataml/data/decisiontree_example.json +21 -21
  180. teradataml/data/decisiontreepredict_example.json +45 -45
  181. teradataml/data/dfft2_size4_real.csv +17 -17
  182. teradataml/data/dfft2_test_matrix16.csv +17 -17
  183. teradataml/data/dfft2conv_real_4_4.csv +65 -65
  184. teradataml/data/diabetes.csv +443 -443
  185. teradataml/data/diabetes_test.csv +89 -89
  186. teradataml/data/dict_table.csv +5 -5
  187. teradataml/data/docperterm_table.csv +4 -4
  188. teradataml/data/docs/__init__.py +1 -1
  189. teradataml/data/docs/byom/docs/DataRobotPredict.py +180 -180
  190. teradataml/data/docs/byom/docs/DataikuPredict.py +177 -177
  191. teradataml/data/docs/byom/docs/H2OPredict.py +324 -324
  192. teradataml/data/docs/byom/docs/ONNXPredict.py +283 -283
  193. teradataml/data/docs/byom/docs/PMMLPredict.py +277 -277
  194. teradataml/data/docs/sqle/docs_17_10/Antiselect.py +82 -82
  195. teradataml/data/docs/sqle/docs_17_10/Attribution.py +199 -199
  196. teradataml/data/docs/sqle/docs_17_10/BincodeFit.py +171 -171
  197. teradataml/data/docs/sqle/docs_17_10/BincodeTransform.py +131 -130
  198. teradataml/data/docs/sqle/docs_17_10/CategoricalSummary.py +86 -86
  199. teradataml/data/docs/sqle/docs_17_10/ChiSq.py +90 -90
  200. teradataml/data/docs/sqle/docs_17_10/ColumnSummary.py +85 -85
  201. teradataml/data/docs/sqle/docs_17_10/ConvertTo.py +95 -95
  202. teradataml/data/docs/sqle/docs_17_10/DecisionForestPredict.py +139 -139
  203. teradataml/data/docs/sqle/docs_17_10/DecisionTreePredict.py +151 -151
  204. teradataml/data/docs/sqle/docs_17_10/FTest.py +160 -160
  205. teradataml/data/docs/sqle/docs_17_10/FillRowId.py +82 -82
  206. teradataml/data/docs/sqle/docs_17_10/Fit.py +87 -87
  207. teradataml/data/docs/sqle/docs_17_10/GLMPredict.py +144 -144
  208. teradataml/data/docs/sqle/docs_17_10/GetRowsWithMissingValues.py +84 -84
  209. teradataml/data/docs/sqle/docs_17_10/GetRowsWithoutMissingValues.py +81 -81
  210. teradataml/data/docs/sqle/docs_17_10/Histogram.py +164 -164
  211. teradataml/data/docs/sqle/docs_17_10/MovingAverage.py +134 -134
  212. teradataml/data/docs/sqle/docs_17_10/NGramSplitter.py +208 -208
  213. teradataml/data/docs/sqle/docs_17_10/NPath.py +265 -265
  214. teradataml/data/docs/sqle/docs_17_10/NaiveBayesPredict.py +116 -116
  215. teradataml/data/docs/sqle/docs_17_10/NaiveBayesTextClassifierPredict.py +176 -176
  216. teradataml/data/docs/sqle/docs_17_10/NumApply.py +147 -147
  217. teradataml/data/docs/sqle/docs_17_10/OneHotEncodingFit.py +134 -132
  218. teradataml/data/docs/sqle/docs_17_10/OneHotEncodingTransform.py +109 -103
  219. teradataml/data/docs/sqle/docs_17_10/OutlierFilterFit.py +165 -165
  220. teradataml/data/docs/sqle/docs_17_10/OutlierFilterTransform.py +105 -101
  221. teradataml/data/docs/sqle/docs_17_10/Pack.py +128 -128
  222. teradataml/data/docs/sqle/docs_17_10/PolynomialFeaturesFit.py +111 -111
  223. teradataml/data/docs/sqle/docs_17_10/PolynomialFeaturesTransform.py +102 -102
  224. teradataml/data/docs/sqle/docs_17_10/QQNorm.py +104 -104
  225. teradataml/data/docs/sqle/docs_17_10/RoundColumns.py +109 -109
  226. teradataml/data/docs/sqle/docs_17_10/RowNormalizeFit.py +117 -117
  227. teradataml/data/docs/sqle/docs_17_10/RowNormalizeTransform.py +99 -98
  228. teradataml/data/docs/sqle/docs_17_10/SVMSparsePredict.py +152 -152
  229. teradataml/data/docs/sqle/docs_17_10/ScaleFit.py +197 -197
  230. teradataml/data/docs/sqle/docs_17_10/ScaleTransform.py +99 -98
  231. teradataml/data/docs/sqle/docs_17_10/Sessionize.py +113 -113
  232. teradataml/data/docs/sqle/docs_17_10/SimpleImputeFit.py +116 -116
  233. teradataml/data/docs/sqle/docs_17_10/SimpleImputeTransform.py +98 -98
  234. teradataml/data/docs/sqle/docs_17_10/StrApply.py +187 -187
  235. teradataml/data/docs/sqle/docs_17_10/StringSimilarity.py +145 -145
  236. teradataml/data/docs/sqle/docs_17_10/Transform.py +105 -104
  237. teradataml/data/docs/sqle/docs_17_10/UnivariateStatistics.py +141 -141
  238. teradataml/data/docs/sqle/docs_17_10/Unpack.py +214 -214
  239. teradataml/data/docs/sqle/docs_17_10/WhichMax.py +83 -83
  240. teradataml/data/docs/sqle/docs_17_10/WhichMin.py +83 -83
  241. teradataml/data/docs/sqle/docs_17_10/ZTest.py +155 -155
  242. teradataml/data/docs/sqle/docs_17_20/ANOVA.py +186 -126
  243. teradataml/data/docs/sqle/docs_17_20/Antiselect.py +82 -82
  244. teradataml/data/docs/sqle/docs_17_20/Attribution.py +200 -200
  245. teradataml/data/docs/sqle/docs_17_20/BincodeFit.py +171 -171
  246. teradataml/data/docs/sqle/docs_17_20/BincodeTransform.py +139 -138
  247. teradataml/data/docs/sqle/docs_17_20/CategoricalSummary.py +86 -86
  248. teradataml/data/docs/sqle/docs_17_20/ChiSq.py +90 -90
  249. teradataml/data/docs/sqle/docs_17_20/ClassificationEvaluator.py +166 -166
  250. teradataml/data/docs/sqle/docs_17_20/ColumnSummary.py +85 -85
  251. teradataml/data/docs/sqle/docs_17_20/ColumnTransformer.py +245 -243
  252. teradataml/data/docs/sqle/docs_17_20/ConvertTo.py +113 -113
  253. teradataml/data/docs/sqle/docs_17_20/DecisionForest.py +279 -279
  254. teradataml/data/docs/sqle/docs_17_20/DecisionForestPredict.py +144 -144
  255. teradataml/data/docs/sqle/docs_17_20/DecisionTreePredict.py +135 -135
  256. teradataml/data/docs/sqle/docs_17_20/FTest.py +239 -160
  257. teradataml/data/docs/sqle/docs_17_20/FillRowId.py +82 -82
  258. teradataml/data/docs/sqle/docs_17_20/Fit.py +87 -87
  259. teradataml/data/docs/sqle/docs_17_20/GLM.py +541 -380
  260. teradataml/data/docs/sqle/docs_17_20/GLMPerSegment.py +414 -414
  261. teradataml/data/docs/sqle/docs_17_20/GLMPredict.py +144 -144
  262. teradataml/data/docs/sqle/docs_17_20/GLMPredictPerSegment.py +233 -234
  263. teradataml/data/docs/sqle/docs_17_20/GetFutileColumns.py +125 -123
  264. teradataml/data/docs/sqle/docs_17_20/GetRowsWithMissingValues.py +108 -108
  265. teradataml/data/docs/sqle/docs_17_20/GetRowsWithoutMissingValues.py +105 -105
  266. teradataml/data/docs/sqle/docs_17_20/Histogram.py +223 -223
  267. teradataml/data/docs/sqle/docs_17_20/KMeans.py +251 -204
  268. teradataml/data/docs/sqle/docs_17_20/KMeansPredict.py +144 -143
  269. teradataml/data/docs/sqle/docs_17_20/KNN.py +214 -214
  270. teradataml/data/docs/sqle/docs_17_20/MovingAverage.py +134 -134
  271. teradataml/data/docs/sqle/docs_17_20/NGramSplitter.py +208 -208
  272. teradataml/data/docs/sqle/docs_17_20/NPath.py +265 -265
  273. teradataml/data/docs/sqle/docs_17_20/NaiveBayesPredict.py +116 -116
  274. teradataml/data/docs/sqle/docs_17_20/NaiveBayesTextClassifierPredict.py +177 -176
  275. teradataml/data/docs/sqle/docs_17_20/NaiveBayesTextClassifierTrainer.py +126 -126
  276. teradataml/data/docs/sqle/docs_17_20/NonLinearCombineFit.py +118 -117
  277. teradataml/data/docs/sqle/docs_17_20/NonLinearCombineTransform.py +112 -112
  278. teradataml/data/docs/sqle/docs_17_20/NumApply.py +147 -147
  279. teradataml/data/docs/sqle/docs_17_20/OneClassSVM.py +307 -307
  280. teradataml/data/docs/sqle/docs_17_20/OneClassSVMPredict.py +185 -184
  281. teradataml/data/docs/sqle/docs_17_20/OneHotEncodingFit.py +230 -225
  282. teradataml/data/docs/sqle/docs_17_20/OneHotEncodingTransform.py +121 -115
  283. teradataml/data/docs/sqle/docs_17_20/OrdinalEncodingFit.py +219 -219
  284. teradataml/data/docs/sqle/docs_17_20/OrdinalEncodingTransform.py +127 -127
  285. teradataml/data/docs/sqle/docs_17_20/OutlierFilterFit.py +189 -189
  286. teradataml/data/docs/sqle/docs_17_20/OutlierFilterTransform.py +117 -112
  287. teradataml/data/docs/sqle/docs_17_20/Pack.py +128 -128
  288. teradataml/data/docs/sqle/docs_17_20/PolynomialFeaturesFit.py +111 -111
  289. teradataml/data/docs/sqle/docs_17_20/PolynomialFeaturesTransform.py +112 -111
  290. teradataml/data/docs/sqle/docs_17_20/QQNorm.py +104 -104
  291. teradataml/data/docs/sqle/docs_17_20/ROC.py +164 -163
  292. teradataml/data/docs/sqle/docs_17_20/RandomProjectionFit.py +154 -154
  293. teradataml/data/docs/sqle/docs_17_20/RandomProjectionMinComponents.py +106 -106
  294. teradataml/data/docs/sqle/docs_17_20/RandomProjectionTransform.py +120 -120
  295. teradataml/data/docs/sqle/docs_17_20/RegressionEvaluator.py +211 -211
  296. teradataml/data/docs/sqle/docs_17_20/RoundColumns.py +108 -108
  297. teradataml/data/docs/sqle/docs_17_20/RowNormalizeFit.py +117 -117
  298. teradataml/data/docs/sqle/docs_17_20/RowNormalizeTransform.py +111 -110
  299. teradataml/data/docs/sqle/docs_17_20/SVM.py +413 -413
  300. teradataml/data/docs/sqle/docs_17_20/SVMPredict.py +213 -202
  301. teradataml/data/docs/sqle/docs_17_20/SVMSparsePredict.py +152 -152
  302. teradataml/data/docs/sqle/docs_17_20/ScaleFit.py +315 -197
  303. teradataml/data/docs/sqle/docs_17_20/ScaleTransform.py +202 -109
  304. teradataml/data/docs/sqle/docs_17_20/SentimentExtractor.py +206 -206
  305. teradataml/data/docs/sqle/docs_17_20/Sessionize.py +113 -113
  306. teradataml/data/docs/sqle/docs_17_20/Silhouette.py +152 -152
  307. teradataml/data/docs/sqle/docs_17_20/SimpleImputeFit.py +116 -116
  308. teradataml/data/docs/sqle/docs_17_20/SimpleImputeTransform.py +109 -108
  309. teradataml/data/docs/sqle/docs_17_20/StrApply.py +187 -187
  310. teradataml/data/docs/sqle/docs_17_20/StringSimilarity.py +145 -145
  311. teradataml/data/docs/sqle/docs_17_20/TDDecisionForestPredict.py +207 -207
  312. teradataml/data/docs/sqle/docs_17_20/TDGLMPredict.py +333 -171
  313. teradataml/data/docs/sqle/docs_17_20/TargetEncodingFit.py +266 -266
  314. teradataml/data/docs/sqle/docs_17_20/TargetEncodingTransform.py +141 -140
  315. teradataml/data/docs/sqle/docs_17_20/TextParser.py +172 -172
  316. teradataml/data/docs/sqle/docs_17_20/TrainTestSplit.py +159 -159
  317. teradataml/data/docs/sqle/docs_17_20/Transform.py +123 -123
  318. teradataml/data/docs/sqle/docs_17_20/UnivariateStatistics.py +141 -141
  319. teradataml/data/docs/sqle/docs_17_20/Unpack.py +214 -214
  320. teradataml/data/docs/sqle/docs_17_20/VectorDistance.py +168 -168
  321. teradataml/data/docs/sqle/docs_17_20/WhichMax.py +83 -83
  322. teradataml/data/docs/sqle/docs_17_20/WhichMin.py +83 -83
  323. teradataml/data/docs/sqle/docs_17_20/WordEmbeddings.py +236 -236
  324. teradataml/data/docs/sqle/docs_17_20/XGBoost.py +361 -353
  325. teradataml/data/docs/sqle/docs_17_20/XGBoostPredict.py +281 -275
  326. teradataml/data/docs/sqle/docs_17_20/ZTest.py +220 -155
  327. teradataml/data/docs/tableoperator/docs_17_00/ReadNOS.py +429 -429
  328. teradataml/data/docs/tableoperator/docs_17_05/ReadNOS.py +429 -429
  329. teradataml/data/docs/tableoperator/docs_17_05/WriteNOS.py +347 -347
  330. teradataml/data/docs/tableoperator/docs_17_10/ReadNOS.py +428 -428
  331. teradataml/data/docs/tableoperator/docs_17_10/WriteNOS.py +347 -347
  332. teradataml/data/docs/tableoperator/docs_17_20/ReadNOS.py +439 -439
  333. teradataml/data/docs/tableoperator/docs_17_20/WriteNOS.py +386 -386
  334. teradataml/data/docs/uaf/docs_17_20/ACF.py +195 -195
  335. teradataml/data/docs/uaf/docs_17_20/ArimaEstimate.py +369 -369
  336. teradataml/data/docs/uaf/docs_17_20/ArimaForecast.py +142 -142
  337. teradataml/data/docs/uaf/docs_17_20/ArimaValidate.py +159 -159
  338. teradataml/data/docs/uaf/docs_17_20/BinaryMatrixOp.py +247 -247
  339. teradataml/data/docs/uaf/docs_17_20/BinarySeriesOp.py +252 -252
  340. teradataml/data/docs/uaf/docs_17_20/BreuschGodfrey.py +177 -177
  341. teradataml/data/docs/uaf/docs_17_20/BreuschPaganGodfrey.py +174 -174
  342. teradataml/data/docs/uaf/docs_17_20/Convolve.py +226 -226
  343. teradataml/data/docs/uaf/docs_17_20/Convolve2.py +214 -214
  344. teradataml/data/docs/uaf/docs_17_20/CumulPeriodogram.py +183 -183
  345. teradataml/data/docs/uaf/docs_17_20/DFFT.py +203 -203
  346. teradataml/data/docs/uaf/docs_17_20/DFFT2.py +216 -216
  347. teradataml/data/docs/uaf/docs_17_20/DFFT2Conv.py +215 -215
  348. teradataml/data/docs/uaf/docs_17_20/DFFTConv.py +191 -191
  349. teradataml/data/docs/uaf/docs_17_20/DTW.py +179 -179
  350. teradataml/data/docs/uaf/docs_17_20/DickeyFuller.py +144 -144
  351. teradataml/data/docs/uaf/docs_17_20/DurbinWatson.py +183 -183
  352. teradataml/data/docs/uaf/docs_17_20/ExtractResults.py +184 -184
  353. teradataml/data/docs/uaf/docs_17_20/FitMetrics.py +172 -172
  354. teradataml/data/docs/uaf/docs_17_20/GenseriesFormula.py +205 -205
  355. teradataml/data/docs/uaf/docs_17_20/GenseriesSinusoids.py +142 -142
  356. teradataml/data/docs/uaf/docs_17_20/HoltWintersForecaster.py +258 -258
  357. teradataml/data/docs/uaf/docs_17_20/IDFFT.py +164 -164
  358. teradataml/data/docs/uaf/docs_17_20/IDFFT2.py +198 -198
  359. teradataml/data/docs/uaf/docs_17_20/InputValidator.py +120 -120
  360. teradataml/data/docs/uaf/docs_17_20/LineSpec.py +155 -155
  361. teradataml/data/docs/uaf/docs_17_20/LinearRegr.py +214 -214
  362. teradataml/data/docs/uaf/docs_17_20/MAMean.py +173 -173
  363. teradataml/data/docs/uaf/docs_17_20/MInfo.py +133 -133
  364. teradataml/data/docs/uaf/docs_17_20/MatrixMultiply.py +135 -135
  365. teradataml/data/docs/uaf/docs_17_20/MultivarRegr.py +190 -190
  366. teradataml/data/docs/uaf/docs_17_20/PACF.py +158 -158
  367. teradataml/data/docs/uaf/docs_17_20/Portman.py +216 -216
  368. teradataml/data/docs/uaf/docs_17_20/PowerTransform.py +154 -154
  369. teradataml/data/docs/uaf/docs_17_20/Resample.py +228 -228
  370. teradataml/data/docs/uaf/docs_17_20/SInfo.py +122 -122
  371. teradataml/data/docs/uaf/docs_17_20/SeasonalNormalize.py +165 -165
  372. teradataml/data/docs/uaf/docs_17_20/SelectionCriteria.py +173 -173
  373. teradataml/data/docs/uaf/docs_17_20/SignifPeriodicities.py +170 -170
  374. teradataml/data/docs/uaf/docs_17_20/SignifResidmean.py +163 -163
  375. teradataml/data/docs/uaf/docs_17_20/SimpleExp.py +179 -179
  376. teradataml/data/docs/uaf/docs_17_20/Smoothma.py +207 -207
  377. teradataml/data/docs/uaf/docs_17_20/TrackingOp.py +150 -150
  378. teradataml/data/docs/uaf/docs_17_20/UNDIFF.py +171 -171
  379. teradataml/data/docs/uaf/docs_17_20/Unnormalize.py +201 -201
  380. teradataml/data/docs/uaf/docs_17_20/WhitesGeneral.py +169 -169
  381. teradataml/data/dtw_example.json +17 -17
  382. teradataml/data/dtw_t1.csv +11 -11
  383. teradataml/data/dtw_t2.csv +4 -4
  384. teradataml/data/dwt2d_example.json +15 -15
  385. teradataml/data/dwt_example.json +14 -14
  386. teradataml/data/dwt_filter_dim.csv +5 -5
  387. teradataml/data/emission.csv +9 -9
  388. teradataml/data/emp_table_by_dept.csv +19 -19
  389. teradataml/data/employee_info.csv +4 -4
  390. teradataml/data/employee_table.csv +6 -6
  391. teradataml/data/excluding_event_table.csv +2 -2
  392. teradataml/data/finance_data.csv +6 -6
  393. teradataml/data/finance_data2.csv +61 -61
  394. teradataml/data/finance_data3.csv +93 -93
  395. teradataml/data/fish.csv +160 -0
  396. teradataml/data/fm_blood2ageandweight.csv +26 -26
  397. teradataml/data/fmeasure_example.json +11 -11
  398. teradataml/data/followers_leaders.csv +10 -10
  399. teradataml/data/fpgrowth_example.json +12 -12
  400. teradataml/data/frequentpaths_example.json +29 -29
  401. teradataml/data/friends.csv +9 -9
  402. teradataml/data/fs_input.csv +33 -33
  403. teradataml/data/fs_input1.csv +33 -33
  404. teradataml/data/genData.csv +513 -513
  405. teradataml/data/geodataframe_example.json +39 -39
  406. teradataml/data/glass_types.csv +215 -0
  407. teradataml/data/glm_admissions_model.csv +12 -12
  408. teradataml/data/glm_example.json +56 -29
  409. teradataml/data/glml1l2_example.json +28 -28
  410. teradataml/data/glml1l2predict_example.json +54 -54
  411. teradataml/data/glmpredict_example.json +54 -54
  412. teradataml/data/gq_t1.csv +21 -21
  413. teradataml/data/hconvolve_complex_right.csv +5 -5
  414. teradataml/data/hconvolve_complex_rightmulti.csv +5 -5
  415. teradataml/data/histogram_example.json +11 -11
  416. teradataml/data/hmmdecoder_example.json +78 -78
  417. teradataml/data/hmmevaluator_example.json +24 -24
  418. teradataml/data/hmmsupervised_example.json +10 -10
  419. teradataml/data/hmmunsupervised_example.json +7 -7
  420. teradataml/data/house_values.csv +12 -12
  421. teradataml/data/house_values2.csv +13 -13
  422. teradataml/data/housing_cat.csv +7 -7
  423. teradataml/data/housing_data.csv +9 -9
  424. teradataml/data/housing_test.csv +47 -47
  425. teradataml/data/housing_test_binary.csv +47 -47
  426. teradataml/data/housing_train.csv +493 -493
  427. teradataml/data/housing_train_attribute.csv +4 -4
  428. teradataml/data/housing_train_binary.csv +437 -437
  429. teradataml/data/housing_train_parameter.csv +2 -2
  430. teradataml/data/housing_train_response.csv +493 -493
  431. teradataml/data/housing_train_segment.csv +201 -0
  432. teradataml/data/ibm_stock.csv +370 -370
  433. teradataml/data/ibm_stock1.csv +370 -370
  434. teradataml/data/identitymatch_example.json +21 -21
  435. teradataml/data/idf_table.csv +4 -4
  436. teradataml/data/impressions.csv +101 -101
  437. teradataml/data/inflation.csv +21 -21
  438. teradataml/data/initial.csv +3 -3
  439. teradataml/data/insect2Cols.csv +61 -0
  440. teradataml/data/insect_sprays.csv +12 -12
  441. teradataml/data/insurance.csv +1339 -1339
  442. teradataml/data/interpolator_example.json +12 -12
  443. teradataml/data/iris_altinput.csv +481 -481
  444. teradataml/data/iris_attribute_output.csv +8 -8
  445. teradataml/data/iris_attribute_test.csv +121 -121
  446. teradataml/data/iris_attribute_train.csv +481 -481
  447. teradataml/data/iris_category_expect_predict.csv +31 -31
  448. teradataml/data/iris_data.csv +151 -0
  449. teradataml/data/iris_input.csv +151 -151
  450. teradataml/data/iris_response_train.csv +121 -121
  451. teradataml/data/iris_test.csv +31 -31
  452. teradataml/data/iris_train.csv +121 -121
  453. teradataml/data/join_table1.csv +4 -4
  454. teradataml/data/join_table2.csv +4 -4
  455. teradataml/data/jsons/anly_function_name.json +6 -6
  456. teradataml/data/jsons/byom/dataikupredict.json +147 -147
  457. teradataml/data/jsons/byom/datarobotpredict.json +146 -146
  458. teradataml/data/jsons/byom/h2opredict.json +194 -194
  459. teradataml/data/jsons/byom/onnxpredict.json +186 -186
  460. teradataml/data/jsons/byom/pmmlpredict.json +146 -146
  461. teradataml/data/jsons/paired_functions.json +435 -435
  462. teradataml/data/jsons/sqle/16.20/Antiselect.json +56 -56
  463. teradataml/data/jsons/sqle/16.20/Attribution.json +249 -249
  464. teradataml/data/jsons/sqle/16.20/DecisionForestPredict.json +156 -156
  465. teradataml/data/jsons/sqle/16.20/DecisionTreePredict.json +170 -170
  466. teradataml/data/jsons/sqle/16.20/GLMPredict.json +122 -122
  467. teradataml/data/jsons/sqle/16.20/MovingAverage.json +367 -367
  468. teradataml/data/jsons/sqle/16.20/NGramSplitter.json +239 -239
  469. teradataml/data/jsons/sqle/16.20/NaiveBayesPredict.json +136 -136
  470. teradataml/data/jsons/sqle/16.20/NaiveBayesTextClassifierPredict.json +235 -235
  471. teradataml/data/jsons/sqle/16.20/Pack.json +98 -98
  472. teradataml/data/jsons/sqle/16.20/SVMSparsePredict.json +162 -162
  473. teradataml/data/jsons/sqle/16.20/Sessionize.json +105 -105
  474. teradataml/data/jsons/sqle/16.20/StringSimilarity.json +86 -86
  475. teradataml/data/jsons/sqle/16.20/Unpack.json +166 -166
  476. teradataml/data/jsons/sqle/16.20/nPath.json +269 -269
  477. teradataml/data/jsons/sqle/17.00/Antiselect.json +56 -56
  478. teradataml/data/jsons/sqle/17.00/Attribution.json +249 -249
  479. teradataml/data/jsons/sqle/17.00/DecisionForestPredict.json +156 -156
  480. teradataml/data/jsons/sqle/17.00/DecisionTreePredict.json +170 -170
  481. teradataml/data/jsons/sqle/17.00/GLMPredict.json +122 -122
  482. teradataml/data/jsons/sqle/17.00/MovingAverage.json +367 -367
  483. teradataml/data/jsons/sqle/17.00/NGramSplitter.json +239 -239
  484. teradataml/data/jsons/sqle/17.00/NaiveBayesPredict.json +136 -136
  485. teradataml/data/jsons/sqle/17.00/NaiveBayesTextClassifierPredict.json +235 -235
  486. teradataml/data/jsons/sqle/17.00/Pack.json +98 -98
  487. teradataml/data/jsons/sqle/17.00/SVMSparsePredict.json +162 -162
  488. teradataml/data/jsons/sqle/17.00/Sessionize.json +105 -105
  489. teradataml/data/jsons/sqle/17.00/StringSimilarity.json +86 -86
  490. teradataml/data/jsons/sqle/17.00/Unpack.json +166 -166
  491. teradataml/data/jsons/sqle/17.00/nPath.json +269 -269
  492. teradataml/data/jsons/sqle/17.05/Antiselect.json +56 -56
  493. teradataml/data/jsons/sqle/17.05/Attribution.json +249 -249
  494. teradataml/data/jsons/sqle/17.05/DecisionForestPredict.json +156 -156
  495. teradataml/data/jsons/sqle/17.05/DecisionTreePredict.json +170 -170
  496. teradataml/data/jsons/sqle/17.05/GLMPredict.json +122 -122
  497. teradataml/data/jsons/sqle/17.05/MovingAverage.json +367 -367
  498. teradataml/data/jsons/sqle/17.05/NGramSplitter.json +239 -239
  499. teradataml/data/jsons/sqle/17.05/NaiveBayesPredict.json +136 -136
  500. teradataml/data/jsons/sqle/17.05/NaiveBayesTextClassifierPredict.json +235 -235
  501. teradataml/data/jsons/sqle/17.05/Pack.json +98 -98
  502. teradataml/data/jsons/sqle/17.05/SVMSparsePredict.json +162 -162
  503. teradataml/data/jsons/sqle/17.05/Sessionize.json +105 -105
  504. teradataml/data/jsons/sqle/17.05/StringSimilarity.json +86 -86
  505. teradataml/data/jsons/sqle/17.05/Unpack.json +166 -166
  506. teradataml/data/jsons/sqle/17.05/nPath.json +269 -269
  507. teradataml/data/jsons/sqle/17.10/Antiselect.json +56 -56
  508. teradataml/data/jsons/sqle/17.10/Attribution.json +249 -249
  509. teradataml/data/jsons/sqle/17.10/DecisionForestPredict.json +185 -185
  510. teradataml/data/jsons/sqle/17.10/DecisionTreePredict.json +171 -171
  511. teradataml/data/jsons/sqle/17.10/GLMPredict.json +151 -151
  512. teradataml/data/jsons/sqle/17.10/MovingAverage.json +368 -368
  513. teradataml/data/jsons/sqle/17.10/NGramSplitter.json +239 -239
  514. teradataml/data/jsons/sqle/17.10/NaiveBayesPredict.json +149 -149
  515. teradataml/data/jsons/sqle/17.10/NaiveBayesTextClassifierPredict.json +288 -288
  516. teradataml/data/jsons/sqle/17.10/Pack.json +133 -133
  517. teradataml/data/jsons/sqle/17.10/SVMSparsePredict.json +193 -193
  518. teradataml/data/jsons/sqle/17.10/Sessionize.json +105 -105
  519. teradataml/data/jsons/sqle/17.10/StringSimilarity.json +86 -86
  520. teradataml/data/jsons/sqle/17.10/TD_BinCodeFit.json +239 -239
  521. teradataml/data/jsons/sqle/17.10/TD_BinCodeTransform.json +70 -70
  522. teradataml/data/jsons/sqle/17.10/TD_CategoricalSummary.json +53 -53
  523. teradataml/data/jsons/sqle/17.10/TD_Chisq.json +67 -67
  524. teradataml/data/jsons/sqle/17.10/TD_ColumnSummary.json +53 -53
  525. teradataml/data/jsons/sqle/17.10/TD_ConvertTo.json +68 -68
  526. teradataml/data/jsons/sqle/17.10/TD_FTest.json +187 -187
  527. teradataml/data/jsons/sqle/17.10/TD_FillRowID.json +51 -51
  528. teradataml/data/jsons/sqle/17.10/TD_FunctionFit.json +46 -46
  529. teradataml/data/jsons/sqle/17.10/TD_FunctionTransform.json +72 -71
  530. teradataml/data/jsons/sqle/17.10/TD_GetRowsWithMissingValues.json +52 -52
  531. teradataml/data/jsons/sqle/17.10/TD_GetRowsWithoutMissingValues.json +52 -52
  532. teradataml/data/jsons/sqle/17.10/TD_Histogram.json +132 -132
  533. teradataml/data/jsons/sqle/17.10/TD_NumApply.json +147 -147
  534. teradataml/data/jsons/sqle/17.10/TD_OneHotEncodingFit.json +182 -182
  535. teradataml/data/jsons/sqle/17.10/TD_OneHotEncodingTransform.json +65 -64
  536. teradataml/data/jsons/sqle/17.10/TD_OutlierFilterFit.json +196 -196
  537. teradataml/data/jsons/sqle/17.10/TD_OutlierFilterTransform.json +48 -47
  538. teradataml/data/jsons/sqle/17.10/TD_PolynomialFeaturesFit.json +114 -114
  539. teradataml/data/jsons/sqle/17.10/TD_PolynomialFeaturesTransform.json +72 -71
  540. teradataml/data/jsons/sqle/17.10/TD_QQNorm.json +111 -111
  541. teradataml/data/jsons/sqle/17.10/TD_RoundColumns.json +93 -93
  542. teradataml/data/jsons/sqle/17.10/TD_RowNormalizeFit.json +127 -127
  543. teradataml/data/jsons/sqle/17.10/TD_RowNormalizeTransform.json +70 -69
  544. teradataml/data/jsons/sqle/17.10/TD_ScaleFit.json +156 -156
  545. teradataml/data/jsons/sqle/17.10/TD_ScaleTransform.json +70 -69
  546. teradataml/data/jsons/sqle/17.10/TD_SimpleImputeFit.json +147 -147
  547. teradataml/data/jsons/sqle/17.10/TD_SimpleImputeTransform.json +48 -47
  548. teradataml/data/jsons/sqle/17.10/TD_StrApply.json +240 -240
  549. teradataml/data/jsons/sqle/17.10/TD_UnivariateStatistics.json +118 -118
  550. teradataml/data/jsons/sqle/17.10/TD_WhichMax.json +52 -52
  551. teradataml/data/jsons/sqle/17.10/TD_WhichMin.json +52 -52
  552. teradataml/data/jsons/sqle/17.10/TD_ZTest.json +171 -171
  553. teradataml/data/jsons/sqle/17.10/Unpack.json +188 -188
  554. teradataml/data/jsons/sqle/17.10/nPath.json +269 -269
  555. teradataml/data/jsons/sqle/17.20/Antiselect.json +56 -56
  556. teradataml/data/jsons/sqle/17.20/Attribution.json +249 -249
  557. teradataml/data/jsons/sqle/17.20/DecisionForestPredict.json +185 -185
  558. teradataml/data/jsons/sqle/17.20/DecisionTreePredict.json +172 -172
  559. teradataml/data/jsons/sqle/17.20/GLMPredict.json +151 -151
  560. teradataml/data/jsons/sqle/17.20/MovingAverage.json +367 -367
  561. teradataml/data/jsons/sqle/17.20/NGramSplitter.json +239 -239
  562. teradataml/data/jsons/sqle/17.20/NaiveBayesPredict.json +149 -149
  563. teradataml/data/jsons/sqle/17.20/NaiveBayesTextClassifierPredict.json +287 -287
  564. teradataml/data/jsons/sqle/17.20/Pack.json +133 -133
  565. teradataml/data/jsons/sqle/17.20/SVMSparsePredict.json +192 -192
  566. teradataml/data/jsons/sqle/17.20/Sessionize.json +105 -105
  567. teradataml/data/jsons/sqle/17.20/StringSimilarity.json +86 -86
  568. teradataml/data/jsons/sqle/17.20/TD_ANOVA.json +148 -76
  569. teradataml/data/jsons/sqle/17.20/TD_BinCodeFit.json +239 -239
  570. teradataml/data/jsons/sqle/17.20/TD_BinCodeTransform.json +71 -71
  571. teradataml/data/jsons/sqle/17.20/TD_CategoricalSummary.json +53 -53
  572. teradataml/data/jsons/sqle/17.20/TD_Chisq.json +67 -67
  573. teradataml/data/jsons/sqle/17.20/TD_ClassificationEvaluator.json +145 -145
  574. teradataml/data/jsons/sqle/17.20/TD_ColumnSummary.json +53 -53
  575. teradataml/data/jsons/sqle/17.20/TD_ColumnTransformer.json +218 -218
  576. teradataml/data/jsons/sqle/17.20/TD_ConvertTo.json +92 -92
  577. teradataml/data/jsons/sqle/17.20/TD_DecisionForest.json +259 -259
  578. teradataml/data/jsons/sqle/17.20/TD_DecisionForestPredict.json +139 -139
  579. teradataml/data/jsons/sqle/17.20/TD_FTest.json +269 -186
  580. teradataml/data/jsons/sqle/17.20/TD_FillRowID.json +52 -52
  581. teradataml/data/jsons/sqle/17.20/TD_FunctionFit.json +46 -46
  582. teradataml/data/jsons/sqle/17.20/TD_FunctionTransform.json +72 -72
  583. teradataml/data/jsons/sqle/17.20/TD_GLM.json +507 -431
  584. teradataml/data/jsons/sqle/17.20/TD_GLMPREDICT.json +168 -125
  585. teradataml/data/jsons/sqle/17.20/TD_GLMPerSegment.json +411 -411
  586. teradataml/data/jsons/sqle/17.20/TD_GLMPredictPerSegment.json +146 -146
  587. teradataml/data/jsons/sqle/17.20/TD_GetFutileColumns.json +93 -91
  588. teradataml/data/jsons/sqle/17.20/TD_GetRowsWithMissingValues.json +76 -76
  589. teradataml/data/jsons/sqle/17.20/TD_GetRowsWithoutMissingValues.json +76 -76
  590. teradataml/data/jsons/sqle/17.20/TD_Histogram.json +152 -152
  591. teradataml/data/jsons/sqle/17.20/TD_KMeans.json +231 -211
  592. teradataml/data/jsons/sqle/17.20/TD_KMeansPredict.json +86 -86
  593. teradataml/data/jsons/sqle/17.20/TD_KNN.json +262 -262
  594. teradataml/data/jsons/sqle/17.20/TD_NaiveBayesTextClassifierTrainer.json +137 -137
  595. teradataml/data/jsons/sqle/17.20/TD_NonLinearCombineFit.json +102 -101
  596. teradataml/data/jsons/sqle/17.20/TD_NonLinearCombineTransform.json +71 -71
  597. teradataml/data/jsons/sqle/17.20/TD_NumApply.json +147 -147
  598. teradataml/data/jsons/sqle/17.20/TD_OneClassSVM.json +315 -315
  599. teradataml/data/jsons/sqle/17.20/TD_OneClassSVMPredict.json +123 -123
  600. teradataml/data/jsons/sqle/17.20/TD_OneHotEncodingFit.json +271 -271
  601. teradataml/data/jsons/sqle/17.20/TD_OneHotEncodingTransform.json +65 -65
  602. teradataml/data/jsons/sqle/17.20/TD_OrdinalEncodingFit.json +229 -229
  603. teradataml/data/jsons/sqle/17.20/TD_OrdinalEncodingTransform.json +75 -75
  604. teradataml/data/jsons/sqle/17.20/TD_OutlierFilterFit.json +217 -217
  605. teradataml/data/jsons/sqle/17.20/TD_OutlierFilterTransform.json +48 -48
  606. teradataml/data/jsons/sqle/17.20/TD_PolynomialFeaturesFit.json +114 -114
  607. teradataml/data/jsons/sqle/17.20/TD_PolynomialFeaturesTransform.json +72 -72
  608. teradataml/data/jsons/sqle/17.20/TD_QQNorm.json +111 -111
  609. teradataml/data/jsons/sqle/17.20/TD_ROC.json +178 -177
  610. teradataml/data/jsons/sqle/17.20/TD_RandomProjectionFit.json +178 -178
  611. teradataml/data/jsons/sqle/17.20/TD_RandomProjectionMinComponents.json +73 -73
  612. teradataml/data/jsons/sqle/17.20/TD_RandomProjectionTransform.json +74 -74
  613. teradataml/data/jsons/sqle/17.20/TD_RegressionEvaluator.json +137 -137
  614. teradataml/data/jsons/sqle/17.20/TD_RoundColumns.json +93 -93
  615. teradataml/data/jsons/sqle/17.20/TD_RowNormalizeFit.json +127 -127
  616. teradataml/data/jsons/sqle/17.20/TD_RowNormalizeTransform.json +70 -70
  617. teradataml/data/jsons/sqle/17.20/TD_SVM.json +389 -389
  618. teradataml/data/jsons/sqle/17.20/TD_SVMPredict.json +142 -124
  619. teradataml/data/jsons/sqle/17.20/TD_ScaleFit.json +309 -156
  620. teradataml/data/jsons/sqle/17.20/TD_ScaleTransform.json +119 -70
  621. teradataml/data/jsons/sqle/17.20/TD_SentimentExtractor.json +193 -193
  622. teradataml/data/jsons/sqle/17.20/TD_Silhouette.json +142 -142
  623. teradataml/data/jsons/sqle/17.20/TD_SimpleImputeFit.json +147 -147
  624. teradataml/data/jsons/sqle/17.20/TD_SimpleImputeTransform.json +48 -48
  625. teradataml/data/jsons/sqle/17.20/TD_StrApply.json +240 -240
  626. teradataml/data/jsons/sqle/17.20/TD_TargetEncodingFit.json +248 -248
  627. teradataml/data/jsons/sqle/17.20/TD_TargetEncodingTransform.json +75 -75
  628. teradataml/data/jsons/sqle/17.20/TD_TextParser.json +192 -192
  629. teradataml/data/jsons/sqle/17.20/TD_TrainTestSplit.json +142 -142
  630. teradataml/data/jsons/sqle/17.20/TD_UnivariateStatistics.json +117 -117
  631. teradataml/data/jsons/sqle/17.20/TD_VectorDistance.json +182 -182
  632. teradataml/data/jsons/sqle/17.20/TD_WhichMax.json +52 -52
  633. teradataml/data/jsons/sqle/17.20/TD_WhichMin.json +52 -52
  634. teradataml/data/jsons/sqle/17.20/TD_WordEmbeddings.json +241 -241
  635. teradataml/data/jsons/sqle/17.20/TD_XGBoost.json +330 -312
  636. teradataml/data/jsons/sqle/17.20/TD_XGBoostPredict.json +195 -182
  637. teradataml/data/jsons/sqle/17.20/TD_ZTest.json +247 -170
  638. teradataml/data/jsons/sqle/17.20/Unpack.json +188 -188
  639. teradataml/data/jsons/sqle/17.20/nPath.json +269 -269
  640. teradataml/data/jsons/tableoperator/17.00/read_nos.json +197 -197
  641. teradataml/data/jsons/tableoperator/17.05/read_nos.json +197 -197
  642. teradataml/data/jsons/tableoperator/17.05/write_nos.json +194 -194
  643. teradataml/data/jsons/tableoperator/17.10/read_nos.json +183 -183
  644. teradataml/data/jsons/tableoperator/17.10/write_nos.json +194 -194
  645. teradataml/data/jsons/tableoperator/17.20/read_nos.json +182 -182
  646. teradataml/data/jsons/tableoperator/17.20/write_nos.json +223 -223
  647. teradataml/data/jsons/uaf/17.20/TD_ACF.json +149 -149
  648. teradataml/data/jsons/uaf/17.20/TD_ARIMAESTIMATE.json +409 -409
  649. teradataml/data/jsons/uaf/17.20/TD_ARIMAFORECAST.json +79 -79
  650. teradataml/data/jsons/uaf/17.20/TD_ARIMAVALIDATE.json +151 -151
  651. teradataml/data/jsons/uaf/17.20/TD_BINARYMATRIXOP.json +109 -109
  652. teradataml/data/jsons/uaf/17.20/TD_BINARYSERIESOP.json +107 -107
  653. teradataml/data/jsons/uaf/17.20/TD_BREUSCH_GODFREY.json +87 -87
  654. teradataml/data/jsons/uaf/17.20/TD_BREUSCH_PAGAN_GODFREY.json +106 -106
  655. teradataml/data/jsons/uaf/17.20/TD_CONVOLVE.json +80 -80
  656. teradataml/data/jsons/uaf/17.20/TD_CONVOLVE2.json +67 -67
  657. teradataml/data/jsons/uaf/17.20/TD_CUMUL_PERIODOGRAM.json +91 -91
  658. teradataml/data/jsons/uaf/17.20/TD_DFFT.json +136 -136
  659. teradataml/data/jsons/uaf/17.20/TD_DFFT2.json +148 -148
  660. teradataml/data/jsons/uaf/17.20/TD_DFFT2CONV.json +108 -108
  661. teradataml/data/jsons/uaf/17.20/TD_DFFTCONV.json +109 -109
  662. teradataml/data/jsons/uaf/17.20/TD_DICKEY_FULLER.json +86 -86
  663. teradataml/data/jsons/uaf/17.20/TD_DIFF.json +91 -91
  664. teradataml/data/jsons/uaf/17.20/TD_DTW.json +116 -116
  665. teradataml/data/jsons/uaf/17.20/TD_DURBIN_WATSON.json +100 -100
  666. teradataml/data/jsons/uaf/17.20/TD_EXTRACT_RESULTS.json +38 -38
  667. teradataml/data/jsons/uaf/17.20/TD_FITMETRICS.json +100 -100
  668. teradataml/data/jsons/uaf/17.20/TD_GENSERIES4FORMULA.json +84 -84
  669. teradataml/data/jsons/uaf/17.20/TD_GENSERIES4SINUSOIDS.json +70 -70
  670. teradataml/data/jsons/uaf/17.20/TD_GOLDFELD_QUANDT.json +152 -152
  671. teradataml/data/jsons/uaf/17.20/TD_HOLT_WINTERS_FORECAST.json +313 -313
  672. teradataml/data/jsons/uaf/17.20/TD_IDFFT.json +57 -57
  673. teradataml/data/jsons/uaf/17.20/TD_IDFFT2.json +94 -94
  674. teradataml/data/jsons/uaf/17.20/TD_INPUTVALIDATOR.json +63 -63
  675. teradataml/data/jsons/uaf/17.20/TD_LINEAR_REGR.json +181 -181
  676. teradataml/data/jsons/uaf/17.20/TD_LINESPEC.json +102 -102
  677. teradataml/data/jsons/uaf/17.20/TD_MAMEAN.json +182 -182
  678. teradataml/data/jsons/uaf/17.20/TD_MATRIXMULTIPLY.json +67 -67
  679. teradataml/data/jsons/uaf/17.20/TD_MINFO.json +66 -66
  680. teradataml/data/jsons/uaf/17.20/TD_MULTIVAR_REGR.json +178 -178
  681. teradataml/data/jsons/uaf/17.20/TD_PACF.json +114 -114
  682. teradataml/data/jsons/uaf/17.20/TD_PORTMAN.json +118 -118
  683. teradataml/data/jsons/uaf/17.20/TD_POWERSPEC.json +175 -175
  684. teradataml/data/jsons/uaf/17.20/TD_POWERTRANSFORM.json +97 -97
  685. teradataml/data/jsons/uaf/17.20/TD_RESAMPLE.json +173 -173
  686. teradataml/data/jsons/uaf/17.20/TD_SEASONALNORMALIZE.json +136 -136
  687. teradataml/data/jsons/uaf/17.20/TD_SELECTION_CRITERIA.json +89 -89
  688. teradataml/data/jsons/uaf/17.20/TD_SIGNIF_PERIODICITIES.json +79 -79
  689. teradataml/data/jsons/uaf/17.20/TD_SIGNIF_RESIDMEAN.json +67 -67
  690. teradataml/data/jsons/uaf/17.20/TD_SIMPLEEXP.json +184 -184
  691. teradataml/data/jsons/uaf/17.20/TD_SINFO.json +57 -57
  692. teradataml/data/jsons/uaf/17.20/TD_SMOOTHMA.json +162 -162
  693. teradataml/data/jsons/uaf/17.20/TD_TRACKINGOP.json +100 -100
  694. teradataml/data/jsons/uaf/17.20/TD_UNDIFF.json +111 -111
  695. teradataml/data/jsons/uaf/17.20/TD_UNNORMALIZE.json +95 -95
  696. teradataml/data/jsons/uaf/17.20/TD_WHITES_GENERAL.json +77 -77
  697. teradataml/data/kmeans_example.json +22 -17
  698. teradataml/data/kmeans_table.csv +10 -0
  699. teradataml/data/kmeans_us_arrests_data.csv +0 -0
  700. teradataml/data/knn_example.json +18 -18
  701. teradataml/data/knnrecommender_example.json +6 -6
  702. teradataml/data/knnrecommenderpredict_example.json +12 -12
  703. teradataml/data/lar_example.json +17 -17
  704. teradataml/data/larpredict_example.json +30 -30
  705. teradataml/data/lc_new_predictors.csv +5 -5
  706. teradataml/data/lc_new_reference.csv +9 -9
  707. teradataml/data/lda_example.json +8 -8
  708. teradataml/data/ldainference_example.json +14 -14
  709. teradataml/data/ldatopicsummary_example.json +8 -8
  710. teradataml/data/levendist_input.csv +13 -13
  711. teradataml/data/levenshteindistance_example.json +10 -10
  712. teradataml/data/linreg_example.json +9 -9
  713. teradataml/data/load_example_data.py +326 -323
  714. teradataml/data/loan_prediction.csv +295 -295
  715. teradataml/data/lungcancer.csv +138 -138
  716. teradataml/data/mappingdata.csv +12 -12
  717. teradataml/data/milk_timeseries.csv +157 -157
  718. teradataml/data/min_max_titanic.csv +4 -4
  719. teradataml/data/minhash_example.json +6 -6
  720. teradataml/data/ml_ratings.csv +7547 -7547
  721. teradataml/data/ml_ratings_10.csv +2445 -2445
  722. teradataml/data/model1_table.csv +5 -5
  723. teradataml/data/model2_table.csv +5 -5
  724. teradataml/data/models/iris_db_glm_model.pmml +56 -56
  725. teradataml/data/models/iris_db_xgb_model.pmml +4471 -4471
  726. teradataml/data/modularity_example.json +12 -12
  727. teradataml/data/movavg_example.json +7 -7
  728. teradataml/data/mtx1.csv +7 -7
  729. teradataml/data/mtx2.csv +13 -13
  730. teradataml/data/multi_model_classification.csv +401 -0
  731. teradataml/data/multi_model_regression.csv +401 -0
  732. teradataml/data/mvdfft8.csv +9 -9
  733. teradataml/data/naivebayes_example.json +9 -9
  734. teradataml/data/naivebayespredict_example.json +19 -19
  735. teradataml/data/naivebayestextclassifier2_example.json +6 -6
  736. teradataml/data/naivebayestextclassifier_example.json +8 -8
  737. teradataml/data/naivebayestextclassifierpredict_example.json +20 -20
  738. teradataml/data/name_Find_configure.csv +10 -10
  739. teradataml/data/namedentityfinder_example.json +14 -14
  740. teradataml/data/namedentityfinderevaluator_example.json +10 -10
  741. teradataml/data/namedentityfindertrainer_example.json +6 -6
  742. teradataml/data/nb_iris_input_test.csv +31 -31
  743. teradataml/data/nb_iris_input_train.csv +121 -121
  744. teradataml/data/nbp_iris_model.csv +13 -13
  745. teradataml/data/ner_extractor_text.csv +2 -2
  746. teradataml/data/ner_sports_test2.csv +29 -29
  747. teradataml/data/ner_sports_train.csv +501 -501
  748. teradataml/data/nerevaluator_example.json +5 -5
  749. teradataml/data/nerextractor_example.json +18 -18
  750. teradataml/data/nermem_sports_test.csv +17 -17
  751. teradataml/data/nermem_sports_train.csv +50 -50
  752. teradataml/data/nertrainer_example.json +6 -6
  753. teradataml/data/ngrams_example.json +6 -6
  754. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Aggregate Functions using SQLAlchemy.ipynb +1455 -1455
  755. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Arithmetic Functions Using SQLAlchemy.ipynb +1993 -1993
  756. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Bit-Byte Manipulation Functions using SQLAlchemy.ipynb +1492 -1492
  757. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Built-in functions using SQLAlchemy.ipynb +536 -536
  758. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Regular Expressions Using SQLAlchemy.ipynb +570 -570
  759. teradataml/data/notebooks/sqlalchemy/Teradata Vantage String Functions Using SQLAlchemy.ipynb +2559 -2559
  760. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Window Aggregate Functions using SQLAlchemy.ipynb +2911 -2911
  761. teradataml/data/notebooks/sqlalchemy/Using Generic SQLAlchemy ClauseElements teradataml DataFrame assign method.ipynb +698 -698
  762. teradataml/data/notebooks/sqlalchemy/teradataml filtering using SQLAlchemy ClauseElements.ipynb +784 -784
  763. teradataml/data/npath_example.json +23 -23
  764. teradataml/data/ntree_example.json +14 -14
  765. teradataml/data/numeric_strings.csv +4 -4
  766. teradataml/data/numerics.csv +4 -4
  767. teradataml/data/ocean_buoy.csv +17 -17
  768. teradataml/data/ocean_buoy2.csv +17 -17
  769. teradataml/data/ocean_buoys.csv +27 -27
  770. teradataml/data/ocean_buoys2.csv +10 -10
  771. teradataml/data/ocean_buoys_nonpti.csv +28 -28
  772. teradataml/data/ocean_buoys_seq.csv +29 -29
  773. teradataml/data/onehot_encoder_train.csv +4 -0
  774. teradataml/data/openml_example.json +92 -0
  775. teradataml/data/optional_event_table.csv +4 -4
  776. teradataml/data/orders1.csv +11 -11
  777. teradataml/data/orders1_12.csv +12 -12
  778. teradataml/data/orders_ex.csv +4 -4
  779. teradataml/data/pack_example.json +8 -8
  780. teradataml/data/package_tracking.csv +19 -19
  781. teradataml/data/package_tracking_pti.csv +18 -18
  782. teradataml/data/pagerank_example.json +13 -13
  783. teradataml/data/paragraphs_input.csv +6 -6
  784. teradataml/data/pathanalyzer_example.json +7 -7
  785. teradataml/data/pathgenerator_example.json +7 -7
  786. teradataml/data/phrases.csv +7 -7
  787. teradataml/data/pivot_example.json +8 -8
  788. teradataml/data/pivot_input.csv +22 -22
  789. teradataml/data/playerRating.csv +31 -31
  790. teradataml/data/postagger_example.json +6 -6
  791. teradataml/data/posttagger_output.csv +44 -44
  792. teradataml/data/production_data.csv +16 -16
  793. teradataml/data/production_data2.csv +7 -7
  794. teradataml/data/randomsample_example.json +31 -31
  795. teradataml/data/randomwalksample_example.json +8 -8
  796. teradataml/data/rank_table.csv +6 -6
  797. teradataml/data/ref_mobile_data.csv +4 -4
  798. teradataml/data/ref_mobile_data_dense.csv +2 -2
  799. teradataml/data/ref_url.csv +17 -17
  800. teradataml/data/restaurant_reviews.csv +7 -7
  801. teradataml/data/river_data.csv +145 -145
  802. teradataml/data/roc_example.json +7 -7
  803. teradataml/data/roc_input.csv +101 -101
  804. teradataml/data/rule_inputs.csv +6 -6
  805. teradataml/data/rule_table.csv +2 -2
  806. teradataml/data/sales.csv +7 -7
  807. teradataml/data/sales_transaction.csv +501 -501
  808. teradataml/data/salesdata.csv +342 -342
  809. teradataml/data/sample_cities.csv +2 -2
  810. teradataml/data/sample_shapes.csv +10 -10
  811. teradataml/data/sample_streets.csv +2 -2
  812. teradataml/data/sampling_example.json +15 -15
  813. teradataml/data/sax_example.json +8 -8
  814. teradataml/data/scale_attributes.csv +3 -0
  815. teradataml/data/scale_example.json +74 -23
  816. teradataml/data/scale_housing.csv +11 -11
  817. teradataml/data/scale_housing_test.csv +6 -6
  818. teradataml/data/scale_input_part_sparse.csv +31 -0
  819. teradataml/data/scale_input_partitioned.csv +16 -0
  820. teradataml/data/scale_input_sparse.csv +11 -0
  821. teradataml/data/scale_parameters.csv +3 -0
  822. teradataml/data/scale_stat.csv +11 -11
  823. teradataml/data/scalebypartition_example.json +13 -13
  824. teradataml/data/scalemap_example.json +13 -13
  825. teradataml/data/scalesummary_example.json +12 -12
  826. teradataml/data/score_category.csv +101 -101
  827. teradataml/data/score_summary.csv +4 -4
  828. teradataml/data/script_example.json +9 -9
  829. teradataml/data/scripts/deploy_script.py +84 -0
  830. teradataml/data/scripts/mapper.R +20 -0
  831. teradataml/data/scripts/mapper.py +15 -15
  832. teradataml/data/scripts/mapper_replace.py +15 -15
  833. teradataml/data/scripts/sklearn/__init__.py +0 -0
  834. teradataml/data/scripts/sklearn/sklearn_fit.py +171 -0
  835. teradataml/data/scripts/sklearn/sklearn_fit_predict.py +127 -0
  836. teradataml/data/scripts/sklearn/sklearn_function.template +108 -0
  837. teradataml/data/scripts/sklearn/sklearn_model_selection_split.py +148 -0
  838. teradataml/data/scripts/sklearn/sklearn_neighbors.py +143 -0
  839. teradataml/data/scripts/sklearn/sklearn_score.py +119 -0
  840. teradataml/data/scripts/sklearn/sklearn_transform.py +171 -0
  841. teradataml/data/seeds.csv +10 -10
  842. teradataml/data/sentenceextractor_example.json +6 -6
  843. teradataml/data/sentiment_extract_input.csv +11 -11
  844. teradataml/data/sentiment_train.csv +16 -16
  845. teradataml/data/sentiment_word.csv +20 -20
  846. teradataml/data/sentiment_word_input.csv +19 -19
  847. teradataml/data/sentimentextractor_example.json +24 -24
  848. teradataml/data/sentimenttrainer_example.json +8 -8
  849. teradataml/data/sequence_table.csv +10 -10
  850. teradataml/data/seriessplitter_example.json +7 -7
  851. teradataml/data/sessionize_example.json +17 -17
  852. teradataml/data/sessionize_table.csv +116 -116
  853. teradataml/data/setop_test1.csv +24 -24
  854. teradataml/data/setop_test2.csv +22 -22
  855. teradataml/data/soc_nw_edges.csv +10 -10
  856. teradataml/data/soc_nw_vertices.csv +7 -7
  857. teradataml/data/souvenir_timeseries.csv +167 -167
  858. teradataml/data/sparse_iris_attribute.csv +5 -5
  859. teradataml/data/sparse_iris_test.csv +121 -121
  860. teradataml/data/sparse_iris_train.csv +601 -601
  861. teradataml/data/star1.csv +6 -6
  862. teradataml/data/state_transition.csv +5 -5
  863. teradataml/data/stock_data.csv +53 -53
  864. teradataml/data/stock_movement.csv +11 -11
  865. teradataml/data/stock_vol.csv +76 -76
  866. teradataml/data/stop_words.csv +8 -8
  867. teradataml/data/store_sales.csv +37 -37
  868. teradataml/data/stringsimilarity_example.json +7 -7
  869. teradataml/data/strsimilarity_input.csv +13 -13
  870. teradataml/data/students.csv +101 -101
  871. teradataml/data/svm_iris_input_test.csv +121 -121
  872. teradataml/data/svm_iris_input_train.csv +481 -481
  873. teradataml/data/svm_iris_model.csv +7 -7
  874. teradataml/data/svmdense_example.json +9 -9
  875. teradataml/data/svmdensepredict_example.json +18 -18
  876. teradataml/data/svmsparse_example.json +7 -7
  877. teradataml/data/svmsparsepredict_example.json +13 -13
  878. teradataml/data/svmsparsesummary_example.json +7 -7
  879. teradataml/data/target_mobile_data.csv +13 -13
  880. teradataml/data/target_mobile_data_dense.csv +5 -5
  881. teradataml/data/templatedata.csv +1201 -1201
  882. teradataml/data/templates/open_source_ml.json +9 -0
  883. teradataml/data/teradataml_example.json +150 -1
  884. teradataml/data/test_classification.csv +101 -0
  885. teradataml/data/test_loan_prediction.csv +53 -53
  886. teradataml/data/test_pacf_12.csv +37 -37
  887. teradataml/data/test_prediction.csv +101 -0
  888. teradataml/data/test_regression.csv +101 -0
  889. teradataml/data/test_river2.csv +109 -109
  890. teradataml/data/text_inputs.csv +6 -6
  891. teradataml/data/textchunker_example.json +7 -7
  892. teradataml/data/textclassifier_example.json +6 -6
  893. teradataml/data/textclassifier_input.csv +7 -7
  894. teradataml/data/textclassifiertrainer_example.json +6 -6
  895. teradataml/data/textmorph_example.json +5 -5
  896. teradataml/data/textparser_example.json +15 -15
  897. teradataml/data/texttagger_example.json +11 -11
  898. teradataml/data/texttokenizer_example.json +6 -6
  899. teradataml/data/texttrainer_input.csv +11 -11
  900. teradataml/data/tf_example.json +6 -6
  901. teradataml/data/tfidf_example.json +13 -13
  902. teradataml/data/tfidf_input1.csv +201 -201
  903. teradataml/data/tfidf_train.csv +6 -6
  904. teradataml/data/time_table1.csv +535 -535
  905. teradataml/data/time_table2.csv +14 -14
  906. teradataml/data/timeseriesdata.csv +1601 -1601
  907. teradataml/data/timeseriesdatasetsd4.csv +105 -105
  908. teradataml/data/titanic.csv +892 -892
  909. teradataml/data/token_table.csv +696 -696
  910. teradataml/data/train_multiclass.csv +101 -0
  911. teradataml/data/train_regression.csv +101 -0
  912. teradataml/data/train_regression_multiple_labels.csv +101 -0
  913. teradataml/data/train_tracking.csv +27 -27
  914. teradataml/data/transformation_table.csv +5 -5
  915. teradataml/data/transformation_table_new.csv +1 -1
  916. teradataml/data/tv_spots.csv +16 -16
  917. teradataml/data/twod_climate_data.csv +117 -117
  918. teradataml/data/uaf_example.json +475 -475
  919. teradataml/data/univariatestatistics_example.json +8 -8
  920. teradataml/data/unpack_example.json +9 -9
  921. teradataml/data/unpivot_example.json +9 -9
  922. teradataml/data/unpivot_input.csv +8 -8
  923. teradataml/data/us_air_pass.csv +36 -36
  924. teradataml/data/us_population.csv +624 -624
  925. teradataml/data/us_states_shapes.csv +52 -52
  926. teradataml/data/varmax_example.json +17 -17
  927. teradataml/data/vectordistance_example.json +25 -25
  928. teradataml/data/ville_climatedata.csv +121 -121
  929. teradataml/data/ville_tempdata.csv +12 -12
  930. teradataml/data/ville_tempdata1.csv +12 -12
  931. teradataml/data/ville_temperature.csv +11 -11
  932. teradataml/data/waveletTable.csv +1605 -1605
  933. teradataml/data/waveletTable2.csv +1605 -1605
  934. teradataml/data/weightedmovavg_example.json +8 -8
  935. teradataml/data/wft_testing.csv +5 -5
  936. teradataml/data/wine_data.csv +1600 -0
  937. teradataml/data/word_embed_input_table1.csv +5 -5
  938. teradataml/data/word_embed_input_table2.csv +4 -4
  939. teradataml/data/word_embed_model.csv +22 -22
  940. teradataml/data/words_input.csv +13 -13
  941. teradataml/data/xconvolve_complex_left.csv +6 -6
  942. teradataml/data/xconvolve_complex_leftmulti.csv +6 -6
  943. teradataml/data/xgboost_example.json +35 -35
  944. teradataml/data/xgboostpredict_example.json +31 -31
  945. teradataml/data/ztest_example.json +16 -0
  946. teradataml/dataframe/copy_to.py +1769 -1698
  947. teradataml/dataframe/data_transfer.py +2812 -2745
  948. teradataml/dataframe/dataframe.py +17630 -16946
  949. teradataml/dataframe/dataframe_utils.py +1875 -1740
  950. teradataml/dataframe/fastload.py +794 -603
  951. teradataml/dataframe/indexer.py +424 -424
  952. teradataml/dataframe/setop.py +1179 -1166
  953. teradataml/dataframe/sql.py +10174 -6432
  954. teradataml/dataframe/sql_function_parameters.py +439 -388
  955. teradataml/dataframe/sql_functions.py +652 -652
  956. teradataml/dataframe/sql_interfaces.py +220 -220
  957. teradataml/dataframe/vantage_function_types.py +674 -630
  958. teradataml/dataframe/window.py +693 -692
  959. teradataml/dbutils/__init__.py +3 -3
  960. teradataml/dbutils/dbutils.py +1167 -1150
  961. teradataml/dbutils/filemgr.py +267 -267
  962. teradataml/gen_ai/__init__.py +2 -2
  963. teradataml/gen_ai/convAI.py +472 -472
  964. teradataml/geospatial/__init__.py +3 -3
  965. teradataml/geospatial/geodataframe.py +1105 -1094
  966. teradataml/geospatial/geodataframecolumn.py +392 -387
  967. teradataml/geospatial/geometry_types.py +925 -925
  968. teradataml/hyperparameter_tuner/__init__.py +1 -1
  969. teradataml/hyperparameter_tuner/optimizer.py +3783 -2993
  970. teradataml/hyperparameter_tuner/utils.py +281 -187
  971. teradataml/lib/aed_0_1.dll +0 -0
  972. teradataml/lib/libaed_0_1.dylib +0 -0
  973. teradataml/lib/libaed_0_1.so +0 -0
  974. teradataml/libaed_0_1.dylib +0 -0
  975. teradataml/libaed_0_1.so +0 -0
  976. teradataml/opensource/__init__.py +1 -0
  977. teradataml/opensource/sklearn/__init__.py +1 -0
  978. teradataml/opensource/sklearn/_class.py +255 -0
  979. teradataml/opensource/sklearn/_sklearn_wrapper.py +1715 -0
  980. teradataml/opensource/sklearn/_wrapper_utils.py +268 -0
  981. teradataml/opensource/sklearn/constants.py +54 -0
  982. teradataml/options/__init__.py +130 -124
  983. teradataml/options/configure.py +358 -336
  984. teradataml/options/display.py +176 -176
  985. teradataml/plot/__init__.py +2 -2
  986. teradataml/plot/axis.py +1388 -1388
  987. teradataml/plot/constants.py +15 -15
  988. teradataml/plot/figure.py +398 -398
  989. teradataml/plot/plot.py +760 -760
  990. teradataml/plot/query_generator.py +83 -83
  991. teradataml/plot/subplot.py +216 -216
  992. teradataml/scriptmgmt/UserEnv.py +3791 -3761
  993. teradataml/scriptmgmt/__init__.py +3 -3
  994. teradataml/scriptmgmt/lls_utils.py +1719 -1604
  995. teradataml/series/series.py +532 -532
  996. teradataml/series/series_utils.py +71 -71
  997. teradataml/table_operators/Apply.py +949 -917
  998. teradataml/table_operators/Script.py +1718 -1982
  999. teradataml/table_operators/TableOperator.py +1255 -1616
  1000. teradataml/table_operators/__init__.py +2 -3
  1001. teradataml/table_operators/apply_query_generator.py +262 -262
  1002. teradataml/table_operators/query_generator.py +507 -507
  1003. teradataml/table_operators/table_operator_query_generator.py +460 -460
  1004. teradataml/table_operators/table_operator_util.py +631 -639
  1005. teradataml/table_operators/templates/dataframe_apply.template +184 -184
  1006. teradataml/table_operators/templates/dataframe_map.template +176 -176
  1007. teradataml/table_operators/templates/script_executor.template +170 -170
  1008. teradataml/utils/dtypes.py +684 -684
  1009. teradataml/utils/internal_buffer.py +84 -84
  1010. teradataml/utils/print_versions.py +205 -205
  1011. teradataml/utils/utils.py +410 -410
  1012. teradataml/utils/validators.py +2277 -2115
  1013. {teradataml-17.20.0.7.dist-info → teradataml-20.0.0.1.dist-info}/METADATA +346 -45
  1014. teradataml-20.0.0.1.dist-info/RECORD +1056 -0
  1015. {teradataml-17.20.0.7.dist-info → teradataml-20.0.0.1.dist-info}/WHEEL +1 -1
  1016. {teradataml-17.20.0.7.dist-info → teradataml-20.0.0.1.dist-info}/zip-safe +1 -1
  1017. teradataml/analytics/mle/AdaBoost.py +0 -651
  1018. teradataml/analytics/mle/AdaBoostPredict.py +0 -564
  1019. teradataml/analytics/mle/Antiselect.py +0 -342
  1020. teradataml/analytics/mle/Arima.py +0 -641
  1021. teradataml/analytics/mle/ArimaPredict.py +0 -477
  1022. teradataml/analytics/mle/Attribution.py +0 -1070
  1023. teradataml/analytics/mle/Betweenness.py +0 -658
  1024. teradataml/analytics/mle/Burst.py +0 -711
  1025. teradataml/analytics/mle/CCM.py +0 -600
  1026. teradataml/analytics/mle/CCMPrepare.py +0 -324
  1027. teradataml/analytics/mle/CFilter.py +0 -460
  1028. teradataml/analytics/mle/ChangePointDetection.py +0 -572
  1029. teradataml/analytics/mle/ChangePointDetectionRT.py +0 -477
  1030. teradataml/analytics/mle/Closeness.py +0 -737
  1031. teradataml/analytics/mle/ConfusionMatrix.py +0 -420
  1032. teradataml/analytics/mle/Correlation.py +0 -477
  1033. teradataml/analytics/mle/Correlation2.py +0 -573
  1034. teradataml/analytics/mle/CoxHazardRatio.py +0 -679
  1035. teradataml/analytics/mle/CoxPH.py +0 -556
  1036. teradataml/analytics/mle/CoxSurvival.py +0 -478
  1037. teradataml/analytics/mle/CumulativeMovAvg.py +0 -363
  1038. teradataml/analytics/mle/DTW.py +0 -623
  1039. teradataml/analytics/mle/DWT.py +0 -564
  1040. teradataml/analytics/mle/DWT2D.py +0 -599
  1041. teradataml/analytics/mle/DecisionForest.py +0 -716
  1042. teradataml/analytics/mle/DecisionForestEvaluator.py +0 -363
  1043. teradataml/analytics/mle/DecisionForestPredict.py +0 -561
  1044. teradataml/analytics/mle/DecisionTree.py +0 -830
  1045. teradataml/analytics/mle/DecisionTreePredict.py +0 -528
  1046. teradataml/analytics/mle/ExponentialMovAvg.py +0 -418
  1047. teradataml/analytics/mle/FMeasure.py +0 -402
  1048. teradataml/analytics/mle/FPGrowth.py +0 -734
  1049. teradataml/analytics/mle/FrequentPaths.py +0 -695
  1050. teradataml/analytics/mle/GLM.py +0 -558
  1051. teradataml/analytics/mle/GLML1L2.py +0 -547
  1052. teradataml/analytics/mle/GLML1L2Predict.py +0 -519
  1053. teradataml/analytics/mle/GLMPredict.py +0 -529
  1054. teradataml/analytics/mle/HMMDecoder.py +0 -945
  1055. teradataml/analytics/mle/HMMEvaluator.py +0 -901
  1056. teradataml/analytics/mle/HMMSupervised.py +0 -521
  1057. teradataml/analytics/mle/HMMUnsupervised.py +0 -572
  1058. teradataml/analytics/mle/Histogram.py +0 -561
  1059. teradataml/analytics/mle/IDWT.py +0 -476
  1060. teradataml/analytics/mle/IDWT2D.py +0 -493
  1061. teradataml/analytics/mle/IdentityMatch.py +0 -763
  1062. teradataml/analytics/mle/Interpolator.py +0 -918
  1063. teradataml/analytics/mle/KMeans.py +0 -485
  1064. teradataml/analytics/mle/KNN.py +0 -627
  1065. teradataml/analytics/mle/KNNRecommender.py +0 -488
  1066. teradataml/analytics/mle/KNNRecommenderPredict.py +0 -581
  1067. teradataml/analytics/mle/LAR.py +0 -439
  1068. teradataml/analytics/mle/LARPredict.py +0 -478
  1069. teradataml/analytics/mle/LDA.py +0 -548
  1070. teradataml/analytics/mle/LDAInference.py +0 -492
  1071. teradataml/analytics/mle/LDATopicSummary.py +0 -464
  1072. teradataml/analytics/mle/LevenshteinDistance.py +0 -450
  1073. teradataml/analytics/mle/LinReg.py +0 -433
  1074. teradataml/analytics/mle/LinRegPredict.py +0 -438
  1075. teradataml/analytics/mle/MinHash.py +0 -544
  1076. teradataml/analytics/mle/Modularity.py +0 -587
  1077. teradataml/analytics/mle/NEREvaluator.py +0 -410
  1078. teradataml/analytics/mle/NERExtractor.py +0 -595
  1079. teradataml/analytics/mle/NERTrainer.py +0 -458
  1080. teradataml/analytics/mle/NGrams.py +0 -570
  1081. teradataml/analytics/mle/NPath.py +0 -634
  1082. teradataml/analytics/mle/NTree.py +0 -549
  1083. teradataml/analytics/mle/NaiveBayes.py +0 -462
  1084. teradataml/analytics/mle/NaiveBayesPredict.py +0 -513
  1085. teradataml/analytics/mle/NaiveBayesTextClassifier.py +0 -607
  1086. teradataml/analytics/mle/NaiveBayesTextClassifier2.py +0 -531
  1087. teradataml/analytics/mle/NaiveBayesTextClassifierPredict.py +0 -799
  1088. teradataml/analytics/mle/NamedEntityFinder.py +0 -529
  1089. teradataml/analytics/mle/NamedEntityFinderEvaluator.py +0 -414
  1090. teradataml/analytics/mle/NamedEntityFinderTrainer.py +0 -396
  1091. teradataml/analytics/mle/POSTagger.py +0 -417
  1092. teradataml/analytics/mle/Pack.py +0 -411
  1093. teradataml/analytics/mle/PageRank.py +0 -535
  1094. teradataml/analytics/mle/PathAnalyzer.py +0 -426
  1095. teradataml/analytics/mle/PathGenerator.py +0 -367
  1096. teradataml/analytics/mle/PathStart.py +0 -464
  1097. teradataml/analytics/mle/PathSummarizer.py +0 -470
  1098. teradataml/analytics/mle/Pivot.py +0 -471
  1099. teradataml/analytics/mle/ROC.py +0 -425
  1100. teradataml/analytics/mle/RandomSample.py +0 -637
  1101. teradataml/analytics/mle/RandomWalkSample.py +0 -490
  1102. teradataml/analytics/mle/SAX.py +0 -779
  1103. teradataml/analytics/mle/SVMDense.py +0 -677
  1104. teradataml/analytics/mle/SVMDensePredict.py +0 -536
  1105. teradataml/analytics/mle/SVMDenseSummary.py +0 -437
  1106. teradataml/analytics/mle/SVMSparse.py +0 -557
  1107. teradataml/analytics/mle/SVMSparsePredict.py +0 -553
  1108. teradataml/analytics/mle/SVMSparseSummary.py +0 -435
  1109. teradataml/analytics/mle/Sampling.py +0 -549
  1110. teradataml/analytics/mle/Scale.py +0 -565
  1111. teradataml/analytics/mle/ScaleByPartition.py +0 -496
  1112. teradataml/analytics/mle/ScaleMap.py +0 -378
  1113. teradataml/analytics/mle/ScaleSummary.py +0 -320
  1114. teradataml/analytics/mle/SentenceExtractor.py +0 -363
  1115. teradataml/analytics/mle/SentimentEvaluator.py +0 -432
  1116. teradataml/analytics/mle/SentimentExtractor.py +0 -578
  1117. teradataml/analytics/mle/SentimentTrainer.py +0 -405
  1118. teradataml/analytics/mle/SeriesSplitter.py +0 -641
  1119. teradataml/analytics/mle/Sessionize.py +0 -475
  1120. teradataml/analytics/mle/SimpleMovAvg.py +0 -397
  1121. teradataml/analytics/mle/StringSimilarity.py +0 -425
  1122. teradataml/analytics/mle/TF.py +0 -389
  1123. teradataml/analytics/mle/TFIDF.py +0 -504
  1124. teradataml/analytics/mle/TextChunker.py +0 -414
  1125. teradataml/analytics/mle/TextClassifier.py +0 -399
  1126. teradataml/analytics/mle/TextClassifierEvaluator.py +0 -413
  1127. teradataml/analytics/mle/TextClassifierTrainer.py +0 -565
  1128. teradataml/analytics/mle/TextMorph.py +0 -494
  1129. teradataml/analytics/mle/TextParser.py +0 -623
  1130. teradataml/analytics/mle/TextTagger.py +0 -530
  1131. teradataml/analytics/mle/TextTokenizer.py +0 -502
  1132. teradataml/analytics/mle/UnivariateStatistics.py +0 -488
  1133. teradataml/analytics/mle/Unpack.py +0 -526
  1134. teradataml/analytics/mle/Unpivot.py +0 -438
  1135. teradataml/analytics/mle/VarMax.py +0 -776
  1136. teradataml/analytics/mle/VectorDistance.py +0 -762
  1137. teradataml/analytics/mle/WeightedMovAvg.py +0 -400
  1138. teradataml/analytics/mle/XGBoost.py +0 -842
  1139. teradataml/analytics/mle/XGBoostPredict.py +0 -627
  1140. teradataml/analytics/mle/__init__.py +0 -123
  1141. teradataml/analytics/mle/json/adaboost_mle.json +0 -135
  1142. teradataml/analytics/mle/json/adaboostpredict_mle.json +0 -85
  1143. teradataml/analytics/mle/json/antiselect_mle.json +0 -34
  1144. teradataml/analytics/mle/json/antiselect_mle_mle.json +0 -34
  1145. teradataml/analytics/mle/json/arima_mle.json +0 -172
  1146. teradataml/analytics/mle/json/arimapredict_mle.json +0 -52
  1147. teradataml/analytics/mle/json/attribution_mle_mle.json +0 -143
  1148. teradataml/analytics/mle/json/betweenness_mle.json +0 -97
  1149. teradataml/analytics/mle/json/burst_mle.json +0 -140
  1150. teradataml/analytics/mle/json/ccm_mle.json +0 -124
  1151. teradataml/analytics/mle/json/ccmprepare_mle.json +0 -14
  1152. teradataml/analytics/mle/json/cfilter_mle.json +0 -93
  1153. teradataml/analytics/mle/json/changepointdetection_mle.json +0 -92
  1154. teradataml/analytics/mle/json/changepointdetectionrt_mle.json +0 -78
  1155. teradataml/analytics/mle/json/closeness_mle.json +0 -104
  1156. teradataml/analytics/mle/json/confusionmatrix_mle.json +0 -79
  1157. teradataml/analytics/mle/json/correlation_mle.json +0 -86
  1158. teradataml/analytics/mle/json/correlationreduce_mle.json +0 -49
  1159. teradataml/analytics/mle/json/coxhazardratio_mle.json +0 -89
  1160. teradataml/analytics/mle/json/coxph_mle.json +0 -98
  1161. teradataml/analytics/mle/json/coxsurvival_mle.json +0 -79
  1162. teradataml/analytics/mle/json/cumulativemovavg_mle.json +0 -34
  1163. teradataml/analytics/mle/json/decisionforest_mle.json +0 -167
  1164. teradataml/analytics/mle/json/decisionforestevaluator_mle.json +0 -33
  1165. teradataml/analytics/mle/json/decisionforestpredict_mle_mle.json +0 -74
  1166. teradataml/analytics/mle/json/decisiontree_mle.json +0 -194
  1167. teradataml/analytics/mle/json/decisiontreepredict_mle_mle.json +0 -86
  1168. teradataml/analytics/mle/json/dtw_mle.json +0 -97
  1169. teradataml/analytics/mle/json/dwt2d_mle.json +0 -116
  1170. teradataml/analytics/mle/json/dwt_mle.json +0 -101
  1171. teradataml/analytics/mle/json/exponentialmovavg_mle.json +0 -55
  1172. teradataml/analytics/mle/json/fmeasure_mle.json +0 -58
  1173. teradataml/analytics/mle/json/fpgrowth_mle.json +0 -159
  1174. teradataml/analytics/mle/json/frequentpaths_mle.json +0 -129
  1175. teradataml/analytics/mle/json/glm_mle.json +0 -111
  1176. teradataml/analytics/mle/json/glml1l2_mle.json +0 -106
  1177. teradataml/analytics/mle/json/glml1l2predict_mle.json +0 -57
  1178. teradataml/analytics/mle/json/glmpredict_mle_mle.json +0 -74
  1179. teradataml/analytics/mle/json/histogram_mle.json +0 -100
  1180. teradataml/analytics/mle/json/hmmdecoder_mle.json +0 -192
  1181. teradataml/analytics/mle/json/hmmevaluator_mle.json +0 -206
  1182. teradataml/analytics/mle/json/hmmsupervised_mle.json +0 -91
  1183. teradataml/analytics/mle/json/hmmunsupervised_mle.json +0 -114
  1184. teradataml/analytics/mle/json/identitymatch_mle.json +0 -88
  1185. teradataml/analytics/mle/json/idwt2d_mle.json +0 -73
  1186. teradataml/analytics/mle/json/idwt_mle.json +0 -66
  1187. teradataml/analytics/mle/json/interpolator_mle.json +0 -151
  1188. teradataml/analytics/mle/json/kmeans_mle.json +0 -97
  1189. teradataml/analytics/mle/json/knn_mle.json +0 -141
  1190. teradataml/analytics/mle/json/knnrecommender_mle.json +0 -111
  1191. teradataml/analytics/mle/json/knnrecommenderpredict_mle.json +0 -75
  1192. teradataml/analytics/mle/json/lar_mle.json +0 -78
  1193. teradataml/analytics/mle/json/larpredict_mle.json +0 -69
  1194. teradataml/analytics/mle/json/lda_mle.json +0 -130
  1195. teradataml/analytics/mle/json/ldainference_mle.json +0 -78
  1196. teradataml/analytics/mle/json/ldatopicsummary_mle.json +0 -64
  1197. teradataml/analytics/mle/json/levenshteindistance_mle.json +0 -92
  1198. teradataml/analytics/mle/json/linreg_mle.json +0 -42
  1199. teradataml/analytics/mle/json/linregpredict_mle.json +0 -56
  1200. teradataml/analytics/mle/json/minhash_mle.json +0 -113
  1201. teradataml/analytics/mle/json/modularity_mle.json +0 -91
  1202. teradataml/analytics/mle/json/naivebayespredict_mle_mle.json +0 -85
  1203. teradataml/analytics/mle/json/naivebayesreduce_mle.json +0 -52
  1204. teradataml/analytics/mle/json/naivebayestextclassifierpredict_mle_mle.json +0 -147
  1205. teradataml/analytics/mle/json/naivebayestextclassifiertrainer2_mle.json +0 -108
  1206. teradataml/analytics/mle/json/naivebayestextclassifiertrainer_mle.json +0 -102
  1207. teradataml/analytics/mle/json/namedentityfinder_mle.json +0 -84
  1208. teradataml/analytics/mle/json/namedentityfinderevaluatorreduce_mle.json +0 -43
  1209. teradataml/analytics/mle/json/namedentityfindertrainer_mle.json +0 -64
  1210. teradataml/analytics/mle/json/nerevaluator_mle.json +0 -54
  1211. teradataml/analytics/mle/json/nerextractor_mle.json +0 -87
  1212. teradataml/analytics/mle/json/nertrainer_mle.json +0 -89
  1213. teradataml/analytics/mle/json/ngrams_mle.json +0 -137
  1214. teradataml/analytics/mle/json/ngramsplitter_mle_mle.json +0 -137
  1215. teradataml/analytics/mle/json/npath@coprocessor_mle.json +0 -73
  1216. teradataml/analytics/mle/json/ntree@coprocessor_mle.json +0 -123
  1217. teradataml/analytics/mle/json/pack_mle.json +0 -58
  1218. teradataml/analytics/mle/json/pack_mle_mle.json +0 -58
  1219. teradataml/analytics/mle/json/pagerank_mle.json +0 -81
  1220. teradataml/analytics/mle/json/pathanalyzer_mle.json +0 -63
  1221. teradataml/analytics/mle/json/pathgenerator_mle.json +0 -40
  1222. teradataml/analytics/mle/json/pathstart_mle.json +0 -62
  1223. teradataml/analytics/mle/json/pathsummarizer_mle.json +0 -72
  1224. teradataml/analytics/mle/json/pivoting_mle.json +0 -71
  1225. teradataml/analytics/mle/json/postagger_mle.json +0 -51
  1226. teradataml/analytics/mle/json/randomsample_mle.json +0 -131
  1227. teradataml/analytics/mle/json/randomwalksample_mle.json +0 -85
  1228. teradataml/analytics/mle/json/roc_mle.json +0 -73
  1229. teradataml/analytics/mle/json/sampling_mle.json +0 -75
  1230. teradataml/analytics/mle/json/sax_mle.json +0 -154
  1231. teradataml/analytics/mle/json/scale_mle.json +0 -93
  1232. teradataml/analytics/mle/json/scalebypartition_mle.json +0 -89
  1233. teradataml/analytics/mle/json/scalemap_mle.json +0 -44
  1234. teradataml/analytics/mle/json/scalesummary_mle.json +0 -14
  1235. teradataml/analytics/mle/json/sentenceextractor_mle.json +0 -41
  1236. teradataml/analytics/mle/json/sentimentevaluator_mle.json +0 -43
  1237. teradataml/analytics/mle/json/sentimentextractor_mle.json +0 -100
  1238. teradataml/analytics/mle/json/sentimenttrainer_mle.json +0 -68
  1239. teradataml/analytics/mle/json/seriessplitter_mle.json +0 -133
  1240. teradataml/analytics/mle/json/sessionize_mle_mle.json +0 -62
  1241. teradataml/analytics/mle/json/simplemovavg_mle.json +0 -48
  1242. teradataml/analytics/mle/json/stringsimilarity_mle.json +0 -50
  1243. teradataml/analytics/mle/json/stringsimilarity_mle_mle.json +0 -50
  1244. teradataml/analytics/mle/json/svmdense_mle.json +0 -165
  1245. teradataml/analytics/mle/json/svmdensepredict_mle.json +0 -95
  1246. teradataml/analytics/mle/json/svmdensesummary_mle.json +0 -58
  1247. teradataml/analytics/mle/json/svmsparse_mle.json +0 -148
  1248. teradataml/analytics/mle/json/svmsparsepredict_mle_mle.json +0 -103
  1249. teradataml/analytics/mle/json/svmsparsesummary_mle.json +0 -57
  1250. teradataml/analytics/mle/json/textchunker_mle.json +0 -40
  1251. teradataml/analytics/mle/json/textclassifier_mle.json +0 -51
  1252. teradataml/analytics/mle/json/textclassifierevaluator_mle.json +0 -43
  1253. teradataml/analytics/mle/json/textclassifiertrainer_mle.json +0 -103
  1254. teradataml/analytics/mle/json/textmorph_mle.json +0 -63
  1255. teradataml/analytics/mle/json/textparser_mle.json +0 -166
  1256. teradataml/analytics/mle/json/texttagger_mle.json +0 -81
  1257. teradataml/analytics/mle/json/texttokenizer_mle.json +0 -91
  1258. teradataml/analytics/mle/json/tf_mle.json +0 -33
  1259. teradataml/analytics/mle/json/tfidf_mle.json +0 -34
  1260. teradataml/analytics/mle/json/univariatestatistics_mle.json +0 -81
  1261. teradataml/analytics/mle/json/unpack_mle.json +0 -91
  1262. teradataml/analytics/mle/json/unpack_mle_mle.json +0 -91
  1263. teradataml/analytics/mle/json/unpivoting_mle.json +0 -63
  1264. teradataml/analytics/mle/json/varmax_mle.json +0 -176
  1265. teradataml/analytics/mle/json/vectordistance_mle.json +0 -179
  1266. teradataml/analytics/mle/json/weightedmovavg_mle.json +0 -48
  1267. teradataml/analytics/mle/json/xgboost_mle.json +0 -178
  1268. teradataml/analytics/mle/json/xgboostpredict_mle.json +0 -104
  1269. teradataml/analytics/sqle/Antiselect.py +0 -321
  1270. teradataml/analytics/sqle/Attribution.py +0 -603
  1271. teradataml/analytics/sqle/DecisionForestPredict.py +0 -408
  1272. teradataml/analytics/sqle/GLMPredict.py +0 -430
  1273. teradataml/analytics/sqle/MovingAverage.py +0 -543
  1274. teradataml/analytics/sqle/NGramSplitter.py +0 -548
  1275. teradataml/analytics/sqle/NPath.py +0 -632
  1276. teradataml/analytics/sqle/NaiveBayesTextClassifierPredict.py +0 -515
  1277. teradataml/analytics/sqle/Pack.py +0 -388
  1278. teradataml/analytics/sqle/SVMSparsePredict.py +0 -464
  1279. teradataml/analytics/sqle/Sessionize.py +0 -390
  1280. teradataml/analytics/sqle/StringSimilarity.py +0 -400
  1281. teradataml/analytics/sqle/Unpack.py +0 -503
  1282. teradataml/analytics/sqle/json/antiselect_sqle.json +0 -21
  1283. teradataml/analytics/sqle/json/attribution_sqle.json +0 -92
  1284. teradataml/analytics/sqle/json/decisionforestpredict_sqle.json +0 -48
  1285. teradataml/analytics/sqle/json/glmpredict_sqle.json +0 -48
  1286. teradataml/analytics/sqle/json/h2opredict_sqle.json +0 -63
  1287. teradataml/analytics/sqle/json/movingaverage_sqle.json +0 -58
  1288. teradataml/analytics/sqle/json/naivebayestextclassifierpredict_sqle.json +0 -76
  1289. teradataml/analytics/sqle/json/ngramsplitter_sqle.json +0 -126
  1290. teradataml/analytics/sqle/json/npath_sqle.json +0 -67
  1291. teradataml/analytics/sqle/json/pack_sqle.json +0 -47
  1292. teradataml/analytics/sqle/json/pmmlpredict_sqle.json +0 -55
  1293. teradataml/analytics/sqle/json/sessionize_sqle.json +0 -43
  1294. teradataml/analytics/sqle/json/stringsimilarity_sqle.json +0 -39
  1295. teradataml/analytics/sqle/json/svmsparsepredict_sqle.json +0 -74
  1296. teradataml/analytics/sqle/json/unpack_sqle.json +0 -80
  1297. teradataml/catalog/model_cataloging.py +0 -980
  1298. teradataml/config/mlengine_alias_definitions_v1.0 +0 -118
  1299. teradataml/config/mlengine_alias_definitions_v1.1 +0 -127
  1300. teradataml/config/mlengine_alias_definitions_v1.3 +0 -129
  1301. teradataml/table_operators/sandbox_container_util.py +0 -643
  1302. teradataml-17.20.0.7.dist-info/RECORD +0 -1280
  1303. {teradataml-17.20.0.7.dist-info → teradataml-20.0.0.1.dist-info}/top_level.txt +0 -0
@@ -1,2115 +1,2277 @@
1
- import numbers
2
- import os
3
- import pandas as pd
4
- from pathlib import Path
5
- import re
6
- from teradataml.common.constants import TeradataConstants, PTITableConstants, PythonTypes
7
- from teradataml.common.exceptions import TeradataMlException
8
- from teradataml.common.messages import MessageCodes, Messages
9
- from teradataml.utils.dtypes import _Dtypes, _DtypesMappers, _ListOf, _TupleOf
10
- from teradataml.options.configure import configure
11
- from teradataml.dataframe.sql_interfaces import ColumnExpression
12
-
13
- class _Validators:
14
- """
15
- A class containing set of utilities that can be used for validations of various kinds.
16
- Currently, this facilitates the validations done for:
17
- 1. Analytic function execution engine: (_validate_engine)
18
- 2. Validation for the vantage_version: (_validate_vantage_version)
19
- 3. Validate whether argument has passed with empty string or not: (_validate_input_columns_not_empty)
20
- 4. Validate for permitted values of the argument: (_validate_permitted_values)
21
- 5. Validate function arguments. (_validate_function_arguments) This specifically validates for
22
- 1. Argument types check.
23
- 2. Argument is empty or not.
24
- 3. Permitted values check.
25
- 6. Validate for missing required arguments.
26
- 7. Validate column exists in a DataFrame or not. (_validate_column_exists_in_dataframe)
27
- 8. Validate required arguments are missing or not. (_validate_missing_required_arguments)
28
- 9. Validate whether function install location is set.
29
- 10. Validate whether the table exist in the schema or not
30
- 11. Validate whether the given file is not empty, given absolute file path.
31
- 12. Validate whether "arg1" and "arg2" are mutually inclusive.
32
- """
33
- @staticmethod
34
- def __getTypeAsStr(type_list):
35
- """
36
- Function to convert type to string.
37
-
38
- PARAMETERS:
39
- type_list
40
- Required Argument.
41
- A tuple of types or a type to be converted to string.
42
-
43
- RAISES:
44
- None
45
-
46
- RETURNS:
47
- A list of strings representing types in type_list.
48
-
49
- EXAMPLES:
50
- _Validators.__getTypeAsStr(type_list)
51
- """
52
- type_as_str = []
53
- if isinstance(type_list, tuple):
54
- for typ in type_list:
55
- if isinstance(typ, tuple):
56
- for typ1 in typ:
57
- type_as_str.append(typ1.__name__)
58
- elif isinstance(typ, (_ListOf, _TupleOf)):
59
- type_as_str.append(str(typ))
60
- elif typ.__name__ == "DataFrame":
61
- type_as_str.append("teradataml DataFrame")
62
- else:
63
- type_as_str.append(typ.__name__)
64
-
65
- if isinstance(type_list, type):
66
- if type_list.__name__ == "DataFrame":
67
- type_as_str.append("teradataml DataFrame")
68
- else:
69
- type_as_str.append(type_list.__name__)
70
-
71
- if isinstance(type_list, (_ListOf, _TupleOf)):
72
- type_as_str.append(str(type_list))
73
-
74
- return type_as_str
75
-
76
- @staticmethod
77
- def _check_isinstance(obj, class_or_tuple):
78
- """
79
- Function checks whether an object is an instance of a class.
80
-
81
- PARAMETER
82
- obj:
83
- Required Argument.
84
- Specifies the object to check instance of.
85
-
86
- class_or_tuple:
87
- Required Argument.
88
- Specifies the type or tuple of types to check instance against.
89
-
90
- RAISES:
91
- None.
92
-
93
- RETURNS:
94
- True, if obj is instance of class_or_tuple
95
-
96
- EXAMPLES:
97
- _Validators._check_isinstance(obj, (int, list, str))
98
- """
99
- # If obj is of type bool and type to check against contains int, then we must
100
- # check/validate the instance as type(obj) == class_or_tuple.
101
- # bool is subclass of int, hence isinstance(True, int) will always return true.
102
- # And we would like to return false, as bool is not a int.
103
- if not isinstance(obj, bool):
104
- # If obj of any type other than bool, then we shall use "isinstance()"
105
- # to perform type checks.
106
- return isinstance(obj, class_or_tuple)
107
-
108
- else:
109
- # 'obj' is of type bool.
110
- if isinstance(class_or_tuple, tuple):
111
- if int not in class_or_tuple:
112
- # If class_or_tuple is instance of tuple and int is not in class_or_tuple
113
- # use "isinstance()" to validate type check for obj.
114
- return isinstance(obj, class_or_tuple)
115
- else:
116
- return type(obj) in class_or_tuple
117
-
118
- else: # isinstance(class_or_tuple, type):
119
- if int != class_or_tuple:
120
- # If class_or_tuple is instance of type and class_or_tuple is not an int
121
- # use "isinstance()" to validate type check for obj.
122
- return isinstance(obj, class_or_tuple)
123
- else:
124
- return type(obj) == class_or_tuple
125
-
126
- @staticmethod
127
- def _validate_columnexpression_dataframe_has_columns(columns,
128
- arg_name,
129
- column_expression):
130
- """
131
- DESCRIPTION:
132
- Function to check whether column name(s) available in dataframe
133
- or not from a given column. This function is used currently
134
- only for Window Aggregates.
135
-
136
- PARAMETERS:
137
- columns:
138
- Required Argument.
139
- Specifies the name or list of names of columns to be validated
140
- for existence.
141
- Types: str or List of strings
142
-
143
- arg_name:
144
- Required Argument.
145
- Specifies the name of the argument.
146
- Types: str
147
-
148
- column_expression:
149
- Required Argument.
150
- Specifies teradataml DataFrame Column to check against for
151
- column existence.
152
- Types: ColumnExpression
153
-
154
- RAISES:
155
- ValueError
156
-
157
- RETURNS:
158
- bool
159
-
160
- EXAMPLES:
161
- _Validators._validate_dataframe_has_argument_columns_from_column(self.data_sequence_column,
162
- "data_sequence_column",
163
- self.data.col)
164
- """
165
- if not columns:
166
- return True
167
-
168
- # Converting columns to a list if string is passed.
169
- if not isinstance(columns, list):
170
- columns = [columns]
171
-
172
- df_columns = [df_column.name for df_column in column_expression.table.columns]
173
-
174
- # Let's validate existence of each column one by one.
175
- for column_name in columns:
176
- # If column name does not exist in DataFrame of a column, raise the exception.
177
- if column_name not in df_columns:
178
- message = "{}. Check the argument '{}'".format(sorted(df_columns), arg_name)
179
- raise ValueError(Messages.get_message(MessageCodes.TDMLDF_DROP_INVALID_COL,
180
- column_name,
181
- message
182
- ))
183
- return True
184
-
185
- @staticmethod
186
- def _validate_dataframe_has_argument_columns(columns, column_arg, data, data_arg, is_partition_arg=False):
187
- """
188
- Function to check whether column names in columns are present in given dataframe or not.
189
- This function is used currently only for Analytics wrappers.
190
-
191
- PARAMETERS:
192
- columns:
193
- Required Argument.
194
- Specifies name or list of names of columns to be validated for existence.
195
- Types: str or List of strings
196
-
197
- column_arg:
198
- Required Argument.
199
- Specifies the name of the argument.
200
- Types: str
201
-
202
- data:
203
- Required Argument.
204
- Specifies teradataml DataFrame to check against for column existence.
205
- Types: teradataml DataFrame
206
-
207
- data_arg:
208
- Required Argument.
209
- Specifies the name of the dataframe argument.
210
- Types: str
211
-
212
- isPartitionArg:
213
- Optional Argument.
214
- Specifies a bool argument notifying, whether argument being validate is
215
- Partition argument or not.
216
- Types: bool
217
-
218
- RAISES:
219
- TeradataMlException - TDMLDF_COLUMN_IN_ARG_NOT_FOUND column(s) does not exist in a dataframe.
220
-
221
- EXAMPLES:
222
- _Validators._validate_dataframe_has_argument_columns(self.data_sequence_column, "data_sequence_column", self.data, "data")
223
- _Validators._validate_dataframe_has_argument_columns(self.data_partition_column, "data_sequence_column", self.data, "data", true)
224
- """
225
- if is_partition_arg and columns is None:
226
- return True
227
-
228
- if columns is None:
229
- return True
230
-
231
- _Validators._validate_dependent_argument(column_arg, columns, data_arg, data)
232
-
233
- # Converting columns to a list if string is passed.
234
- if not isinstance(columns, list) and columns is not None:
235
- columns = [columns]
236
-
237
- total_columns = []
238
-
239
- for column in columns:
240
- for separator in TeradataConstants.RANGE_SEPARATORS.value:
241
- if column is None:
242
- total_columns.append(column)
243
- elif column[0] == "-":
244
- # If column has exclude operator "-".
245
- # For example incase of "-[50]", let database handle validation.
246
- if re.match(r'-\[\d+\]', column) is not None:
247
- continue
248
- total_columns.append(column[1:])
249
- elif column.count(separator) == 1:
250
- # Following cases can occur:
251
- # '3:5' or 'colA:colE'
252
- # ':4' or ':columnD' specifies all columns up to and including the column with index 4(or columnD).
253
- # '4:' or 'columnD:' specifies the column with index 4(or columnD) and all columns after it.
254
- # ':' specifies all columns in the table.
255
-
256
- try:
257
- # Check if its a sinlge column with one separator. For e.g. column:A.
258
- # If yes, just continue.
259
- _Validators._validate_column_exists_in_dataframe(column, data._metaexpr)
260
- continue
261
- except:
262
- # User has provided range value.
263
- column_names = column.split(separator)
264
- if (len(column_names) == 2 and
265
- any([column_names[0].isdigit(), column_names[1].isdigit()]) and
266
- not all([column_names[0].isdigit(), column_names[1].isdigit()]) and
267
- not "" in column_names):
268
- # Raises Exception if column range has mixed types. For e.g. "4:XYZ".
269
- err_msg = Messages.get_message(MessageCodes.MIXED_TYPES_IN_COLUMN_RANGE)
270
- raise ValueError(err_msg.format(column_arg))
271
-
272
- for col in column_names:
273
- if not col.isdigit() and col != "":
274
- total_columns.append(col)
275
-
276
- elif column.count(separator) > 1:
277
- continue
278
- else:
279
- total_columns.append(column)
280
-
281
- return _Validators._validate_column_exists_in_dataframe(total_columns, data._metaexpr, column_arg=column_arg,
282
- data_arg=data_arg)
283
-
284
- @staticmethod
285
- def _validate_column_exists_in_dataframe(columns, metaexpr, case_insensitive=False, column_arg=None,
286
- data_arg=None, for_table=False):
287
- """
288
- Method to check whether column or list of columns exists in a teradataml DataFrame or not.
289
-
290
- PARAMETERS:
291
- columns:
292
- Required Argument.
293
- Specifies name or list of names of columns to be validated for existence.
294
- Types: str or List of strings
295
-
296
- metaexpr:
297
- Required Argument.
298
- Specifies a teradataml DataFrame metaexpr to be validated against.
299
- Types: MetaExpression
300
-
301
- case_insensitive:
302
- Optional Argument.
303
- Specifies a flag, that determines whether to check for column existence in
304
- case_insensitive manner or not.
305
- Default Value: False (Case-Sensitive lookup)
306
- Types: bool
307
-
308
- column_arg:
309
- Optional Argument.
310
- Specifies the name of the argument.
311
- Types: str
312
-
313
- data_arg:
314
- Optional Argument.
315
- Specifies the name of the dataframe argument or name of the table.
316
- Types: str
317
-
318
- for_table:
319
- Optional Argument.
320
- Specifies whether error should be raised against table or DataFrame, i.e.,
321
- when columns are not available and "for_table" is set to False, then
322
- exception message mentions column(s) not available in DataFrame. When
323
- columns are not available and "for_table" is set to true, then exception
324
- message mentions column(s) not available in Table.
325
- Types: str
326
-
327
- RAISES:
328
- ValueError
329
- TDMLDF_DROP_INVALID_COL - If columns not found in metaexpr.
330
-
331
- RETURNS:
332
- None
333
-
334
- EXAMPLES:
335
- _Validators._validate_column_exists_in_dataframe(["col1", "col2"], self.metaexpr)
336
-
337
- """
338
- if columns is None:
339
- return True
340
-
341
- # If just a column name is passed, convert it to a list.
342
- if isinstance(columns, str):
343
- columns = [columns]
344
-
345
- # Constructing New unquotted column names for selected columns ONLY using Parent _metaexpr
346
- if case_insensitive:
347
- # If lookup has to be a case insensitive then convert the
348
- # metaexpr columns name to lower case.
349
- unquoted_df_columns = [c.name.replace('"', "").lower() for c in metaexpr.c]
350
- else:
351
- unquoted_df_columns = [c.name.replace('"', "") for c in metaexpr.c]
352
-
353
- # Let's validate existence of each column one by one.
354
- for column_name in columns:
355
- if column_name is None:
356
- column_name = str(column_name)
357
-
358
- if case_insensitive:
359
- # If lookup has to be a case insensitive then convert the
360
- # column name to lower case.
361
- column_name = column_name.lower()
362
-
363
- # If column name does not exist in metaexpr, raise the exception
364
- if not column_name.replace('"', "") in unquoted_df_columns:
365
- if column_arg and data_arg:
366
- raise ValueError(Messages.get_message(MessageCodes.TDMLDF_COLUMN_IN_ARG_NOT_FOUND,
367
- column_name,
368
- column_arg,
369
- data_arg,
370
- "Table" if for_table else "DataFrame"))
371
- else:
372
- raise ValueError(Messages.get_message(MessageCodes.TDMLDF_DROP_INVALID_COL,
373
- column_name, sorted(unquoted_df_columns)))
374
-
375
- return True
376
-
377
- @staticmethod
378
- def _validate_engine(engine):
379
- """
380
- Function to validate whether the argument engine is supported or not.
381
-
382
- PARAMETERS:
383
- engine:
384
- Required Argument.
385
- Specifies the type of the engine.
386
-
387
- RETURNS:
388
- True, if engine is supported.
389
-
390
- RAISES:
391
- TeradataMLException
392
-
393
- EXAMPLES:
394
- _Validators._validate_engine("ENGINE_SQL")
395
- """
396
- supported_engines = TeradataConstants.SUPPORTED_ENGINES.value
397
- if engine not in supported_engines.keys():
398
- raise TeradataMlException(Messages.get_message(
399
- MessageCodes.CONFIG_ALIAS_ENGINE_NOT_SUPPORTED).format(engine,
400
- ", ".join(supported_engines.keys())),
401
- MessageCodes.CONFIG_ALIAS_ENGINE_NOT_SUPPORTED)
402
-
403
- return True
404
-
405
- @staticmethod
406
- def _validate_function_arguments(arg_list, skip_empty_check = None):
407
- """
408
- Method to verify that the input arguments are of valid data type except for
409
- argument of DataFrameType.
410
-
411
- PARAMETERS:
412
- arg_list:
413
- Required Argument.
414
- Specifies a list of arguments, expected types are mentioned as type or tuple.
415
- argInfoMatrix = []
416
- argInfoMatrix.append(["data", data, False, (DataFrame)])
417
- argInfoMatrix.append(["centers", centers, True, (int, list)])
418
- argInfoMatrix.append(["threshold", threshold, True, (float)])
419
- Types: List of Lists
420
- skip_empty_check:
421
- Optional Argument.
422
- Specifies column name and values for which to skip check.
423
- Types: Dictionary specifying column name to values mapping.
424
-
425
- RAISES:
426
- Error if arguments are not of valid datatype
427
-
428
- EXAMPLES:
429
- _Validators._validate_function_arguments(arg_list)
430
- """
431
- invalid_arg_names = []
432
- invalid_arg_types = []
433
-
434
- typeCheckFailed = False
435
-
436
- for args in arg_list:
437
- num_args = len(args)
438
- if not isinstance(args[0], str):
439
- raise TypeError("First element in argument information matrix should be str.")
440
-
441
- if not isinstance(args[2], bool):
442
- raise TypeError("Third element in argument information matrix should be bool.")
443
-
444
- if not (isinstance(args[3], tuple) or isinstance(args[3], type) or
445
- isinstance(args[3], (_ListOf, _TupleOf))):
446
- err_msg = "Fourth element in argument information matrix should be a 'tuple of types' or 'type' type."
447
- raise TypeError(err_msg)
448
-
449
- if num_args >= 5:
450
- if not isinstance(args[4], bool):
451
- raise TypeError("Fifth element in argument information matrix should be bool.")
452
-
453
- #
454
- # Let's validate argument types.
455
- #
456
- # Verify datatypes for arguments which are required or the optional arguments are not None
457
- if ((args[2] == True and args[1] is not None) or (args[2] == False)):
458
- # Validate the types of argument, if expected types are instance of tuple or type
459
- dtype_list = _Validators.__getTypeAsStr(args[3])
460
-
461
- if isinstance(args[3], tuple) and list in args[3]:
462
- # If list of data types contain 'list', which means argument can accept list of values.
463
- dtype_list.remove('list')
464
- valid_types_str = ", ".join(dtype_list) + " or list of values of type(s): " + ", ".join(
465
- dtype_list)
466
-
467
- if isinstance(args[1], list):
468
- # If argument contains list of values, check each value.
469
- for value in args[1]:
470
- # If not valid datatype add invalid_arg to dictionary and break
471
- if not _Validators._check_isinstance(value, args[3]):
472
- invalid_arg_names.append(args[0])
473
- invalid_arg_types.append(valid_types_str)
474
- typeCheckFailed = True
475
- break
476
- elif not _Validators._check_isinstance(args[1], args[3]):
477
- # Argument is not of type list.
478
- invalid_arg_names.append(args[0])
479
- invalid_arg_types.append(valid_types_str)
480
- typeCheckFailed = True
481
-
482
- elif isinstance(args[3], tuple):
483
- # Argument can accept values of multiple types, but not list.
484
- valid_types_str = " or ".join(dtype_list)
485
- if not _Validators._check_isinstance(args[1], args[3]):
486
- invalid_arg_names.append(args[0])
487
- invalid_arg_types.append(valid_types_str)
488
- typeCheckFailed = True
489
- else:
490
- # Argument can accept values of single type.
491
- valid_types_str = " or ".join(dtype_list)
492
- if not _Validators._check_isinstance(args[1], args[3]):
493
- invalid_arg_names.append(args[0])
494
- invalid_arg_types.append(valid_types_str)
495
- typeCheckFailed = True
496
-
497
- #
498
- # Validate the arguments for empty value
499
- #
500
- if not typeCheckFailed and len(args) >= 5:
501
- if args[4]:
502
- _Validators._validate_input_columns_not_empty(args[1], args[0], skip_empty_check)
503
-
504
- #
505
- # Validate the arguments for permitted values
506
- #
507
- if not typeCheckFailed and len(args) >= 6:
508
- if args[5] is not None:
509
- _Validators._validate_permitted_values(args[1], args[5], args[0], supported_types=args[3])
510
-
511
- if typeCheckFailed:
512
- if len(invalid_arg_names) != 0:
513
- raise TypeError(Messages.get_message(MessageCodes.UNSUPPORTED_DATATYPE,
514
- invalid_arg_names, invalid_arg_types))
515
-
516
- return True
517
-
518
- @staticmethod
519
- def _validate_input_columns_not_empty(arg, arg_name, skip_empty_check = None):
520
- """
521
- Function to check whether argument is empty string or not.
522
-
523
- PARAMETERS:
524
- arg:
525
- Required Argument.
526
- Argument value (string) to be checked whether it is empty or not.
527
- skip_empty_check:
528
- Optional Argument.
529
- Specifies column name and values for which to skip check.
530
- Types: Dictionary specifying column name to values mapping.
531
- Example: When '\n', '\t' are valid values for argument 'arg_name', this check should be skipped.
532
-
533
- RAISES:
534
- Error if argument contains empty string
535
-
536
- EXAMPLES:
537
- _Validators._validate_input_columns_not_empty(arg)
538
- """
539
- if isinstance(arg, str):
540
- if not (skip_empty_check and arg_name in skip_empty_check.keys() and arg in skip_empty_check[arg_name]):
541
- if ((len(arg.strip()) == 0)):
542
- raise ValueError(Messages.get_message(MessageCodes.ARG_EMPTY, arg_name))
543
-
544
- if isinstance(arg, list):
545
- if len(arg) == 0:
546
- raise ValueError(Messages.get_message(MessageCodes.ARG_EMPTY, arg_name).replace("empty string", "an empty list"))
547
-
548
- for col in arg:
549
- if not (skip_empty_check and arg_name in skip_empty_check.keys() and col in skip_empty_check[arg_name]):
550
- if isinstance(col, str):
551
- if (not (col is None) and ((len(col.strip()) == 0))):
552
- raise ValueError(Messages.get_message(MessageCodes.ARG_EMPTY, arg_name))
553
- return True
554
-
555
- @staticmethod
556
- def _validate_missing_required_arguments(arg_list):
557
- """
558
- Method to check whether the required arguments passed to the function are missing
559
- or not. Only wrapper's use this function.
560
-
561
- PARAMETERS:
562
- arg_list - A list
563
- The argument is expected to be a list of arguments
564
-
565
- RAISES:
566
- If any arguments are missing exception raised with missing arguments which are
567
- required.
568
-
569
- EXAMPLES:
570
- An example input matrix will be:
571
- arg_info_matrix = []
572
- arg_info_matrix.append(["data", data, False, DataFrame])
573
- arg_info_matrix.append(["centers", centers, True, int])
574
- arg_info_matrix.append(["threshold", threshold, True, "float"])
575
- awu = AnalyticsWrapperUtils()
576
- awu._validate_missing_required_arguments(arg_info_matrix)
577
- """
578
- miss_args = []
579
- for args in arg_list:
580
- '''
581
- Check for missing arguments which are required. If args[2] is false
582
- the argument is required.
583
- The following conditions are true :
584
- 1. The argument should not be None and an empty string.
585
- then argument is required which is missing and Raises exception.
586
- '''
587
- if args[2] == False and args[1] is None:
588
- miss_args.append(args[0])
589
-
590
- if (len(miss_args)>0):
591
- raise TeradataMlException(Messages.get_message(MessageCodes.MISSING_ARGS,miss_args),
592
- MessageCodes.MISSING_ARGS)
593
- return True
594
-
595
- @staticmethod
596
- def _validate_permitted_values(arg, permitted_values, arg_name, case_insensitive=True, includeNone=True, supported_types=None):
597
- """
598
- Function to check the permitted values for the argument.
599
-
600
- PARAMETERS:
601
- arg:
602
- Required Argument.
603
- Argument value to be checked against permitted values from the list.
604
- Types: string
605
-
606
- permitted_values:
607
- Required Argument.
608
- A list of strings/ints/floats containing permitted values for the argument.
609
- Types: string
610
-
611
- arg_name:
612
- Required Argument.
613
- Name of the argument to be printed in the error message.
614
- Types: string
615
-
616
- case_insensitive:
617
- Optional Argument.
618
- Specifies whether values in permitted_values could be case sensitive.
619
- Types: bool
620
-
621
- includeNone:
622
- Optional Argument.
623
- Specifies whether 'None' can be included as valid value.
624
- Types: bool
625
-
626
- supported_types:
627
- Optional Argument.
628
- Specifies the supported datatypes for the argument.
629
- Types: str
630
-
631
- RAISES:
632
- Error if argument is not present in the list
633
-
634
- EXAMPLES:
635
- permitted_values = ["LOGISTIC", "BINOMIAL", "POISSON", "GAUSSIAN", "GAMMA", "INVERSE_GAUSSIAN", "NEGATIVE_BINOMIAL"]
636
- arg = "LOGISTIC"
637
- _Validators._validate_permitted_values(arg, permitted_values, argument_name)
638
- """
639
- # validating permitted_values type which has to be a list.
640
- _Validators._validate_function_arguments([["permitted_values", permitted_values, False, (list)]])
641
-
642
- if case_insensitive:
643
- permitted_values = [item.upper() if isinstance(item, str) else item for item in permitted_values]
644
-
645
- # Validate whether argument has value from permitted values list or not.
646
- if not isinstance(arg, list) and arg is not None:
647
- arg = [arg]
648
-
649
- if arg is not None:
650
- # Getting arguments in uppercase to compare with 'permitted_values'
651
- arg_upper = []
652
- for element in arg:
653
- if element is None:
654
- # If element is None, then we shall add a string "None"
655
- if includeNone:
656
- continue
657
- arg_upper.append(str(element))
658
- elif isinstance(element, str):
659
- # If element is of type str, then we will convert it to upper case.
660
- if case_insensitive:
661
- arg_upper.append(element.upper())
662
- else:
663
- arg_upper.append(element)
664
- else:
665
- # For any other type of element, we will keep it as is.
666
- arg_upper.append(element)
667
-
668
- # Form the list of datatypes not present in the datatypes of permitted_values.
669
- add_types = ()
670
- if supported_types is not None:
671
- # Convert type and tuple to list.
672
- supported_types = [supported_types] if isinstance(supported_types, type) else supported_types
673
- # Form a list for types which are not there in type of permitted_values.
674
- add_types = tuple(set(list(supported_types)) - set(list(map(type, permitted_values))) - set([list]))
675
- # Remove the arguments from arg_upper which are an instance of the add_types.
676
- if len(add_types) > 0:
677
- [arg_upper.remove(arg) for arg in arg_upper if isinstance(arg, add_types)]
678
-
679
- # If any of the arguments in 'arg_upper' not in 'permitted_values',
680
- # then, raise exception
681
- upper_invalid_values = list(set(arg_upper).difference(set(permitted_values)))
682
-
683
- if len(upper_invalid_values) > 0:
684
- # Getting actual invalid arguments (non-upper)
685
- invalid_values = []
686
- for element in arg:
687
- if element is None:
688
- if includeNone:
689
- continue
690
- invalid_values.append(str(element))
691
- elif isinstance(element, str) and element.upper() in upper_invalid_values:
692
- invalid_values.append(element)
693
- elif element in upper_invalid_values:
694
- invalid_values.append(element)
695
- invalid_values.sort()
696
-
697
- # Concatenate the message for datatypes not present in datatypes of permitted_values.
698
- if len(add_types) > 0 :
699
- add_types = _Validators.__getTypeAsStr(add_types)
700
- add_types = " or ".join(add_types)
701
- permitted_values = "{} {}".format(permitted_values, "or any values of type {}".format(add_types))
702
-
703
- raise ValueError(
704
- Messages.get_message(MessageCodes.INVALID_ARG_VALUE,
705
- ', '.join([str(item) if not isinstance(item, str) else item for item in invalid_values]),
706
- arg_name, permitted_values))
707
- # If any of the arguments doesn't want to include None as valid value
708
- # then, raise exception.
709
- else:
710
- if not includeNone:
711
- raise ValueError(
712
- Messages.get_message(MessageCodes.INVALID_ARG_VALUE, None,
713
- arg_name, permitted_values), MessageCodes.INVALID_ARG_VALUE)
714
- # Returns True when arg is None or there is no Exception
715
- return True
716
-
717
- @staticmethod
718
- def _validate_positive_int(arg, arg_name, lbound=0, ubound=None, lbound_inclusive=False):
719
- """
720
- Validation to check arg values is a positive int.
721
-
722
- PARAMETERS:
723
- arg:
724
- Required Argument.
725
- Specifies the number to be validated for positive INT.
726
- Types: int
727
-
728
- arg_name:
729
- Required Argument.
730
- Specifies the name of the argument to be printed in error message.
731
- Types: str
732
-
733
- lbound:
734
- Optional Argument.
735
- Specifies the lower bound value for arg.
736
- Note: Value provided to this argument is exclusive, i.e., if value provided
737
- to this argument 10, then error will be raised for any value of arg <= 10.
738
- It can be made inclusive, if lbound_inclusive is set to 'True'.
739
- Types: int
740
-
741
- ubound:
742
- Optional Argument.
743
- Specifies the upper bound value for arg.
744
- Note: Value provided to this argument is inclusive, i.e., if value provided
745
- to this argument 10, then error will be raised for any value of arg > 10.
746
- Types: int
747
-
748
- lbound_inclusive:
749
- Optional Argument.
750
- Specifies a boolean flag telling API whether to lbound value is inclusive or not.
751
- Types: bool
752
-
753
- RAISES:
754
- ValueError - If arg is not a positive int.
755
-
756
- RETURNS:
757
- True - If success
758
-
759
- EXAMPLES:
760
- # Validate n for value > 0
761
- _Validators._validate_positive_int(n, "n")
762
- # Validate n for value > 0 and value <= 32767
763
- _Validators._validate_positive_int(n, "n", ubound="32767")
764
- """
765
- if arg is None:
766
- return True
767
-
768
- if ubound is None:
769
- if lbound_inclusive:
770
- if not isinstance(arg, numbers.Integral) or arg < lbound:
771
- raise ValueError(Messages.get_message(MessageCodes.TDMLDF_POSITIVE_INT).format(arg_name, "greater than or equal to"))
772
- else:
773
- if not isinstance(arg, numbers.Integral) or arg <= lbound:
774
- raise ValueError(Messages.get_message(MessageCodes.TDMLDF_POSITIVE_INT).format(arg_name, "greater than"))
775
- else:
776
- if not isinstance(arg, numbers.Integral) or arg <= lbound or arg > ubound:
777
- raise ValueError(Messages.get_message(MessageCodes.TDMLDF_LBOUND_UBOUND).format(
778
- arg_name, "greater than {}".format(lbound),
779
- " and less than or equal to {}".format(ubound)))
780
-
781
- return True
782
-
783
- @staticmethod
784
- def _validate_argument_range(arg,
785
- arg_name,
786
- lbound=None,
787
- ubound=None,
788
- lbound_inclusive=False,
789
- ubound_inclusive=False):
790
- """
791
- DESCRIPTION:
792
- Validation to check arg is in specified range.
793
-
794
- PARAMETERS:
795
- arg:
796
- Required Argument.
797
- Specifies the number to be validated for range check.
798
- Types: int
799
-
800
- arg_name:
801
- Required Argument.
802
- Specifies the name of the argument to be printed in error message.
803
- Types: str
804
-
805
- lbound:
806
- Optional Argument.
807
- Specifies the lower bound value for arg.
808
- Note:
809
- Value provided to this argument is exclusive, i.e., if
810
- value provided to this argument 10, then error will be
811
- raised for any value of arg < 10. It can be made inclusive,
812
- if lbound_inclusive is set to 'True'.
813
- Types: int OR float
814
-
815
- ubound:
816
- Optional Argument.
817
- Specifies the upper bound value for arg.
818
- Note:
819
- Value provided to this argument is exclusive, i.e., if
820
- value provided to this argument 10, then error will be
821
- raised for any value of arg > 10. It can be made inclusive,
822
- if ubound_inclusive is set to 'True'.
823
- Types: int OR float
824
-
825
- lbound_inclusive:
826
- Optional Argument.
827
- Specifies whether lbound value is inclusive or not. When set to True,
828
- value is inclusive, otherwise exclusive.
829
- Default Value: False
830
- Types: bool
831
-
832
- ubound_inclusive:
833
- Optional Argument.
834
- Specifies whether ubound value is inclusive or not. When set to True,
835
- value is inclusive, otherwise exclusive.
836
- Default Value: False
837
- Types: bool
838
-
839
- RAISES:
840
- ValueError - If arg is not in the specified range.
841
-
842
- RETURNS:
843
- True - If success
844
-
845
- EXAMPLES:
846
- # Validate n for value in between of 10 and 20.
847
- _Validators._validate_argument_range(n, 10, 20)
848
- """
849
- if lbound is None and ubound is None:
850
- return True
851
-
852
- # Raise error if lower bound is greater than upper bound.
853
- if lbound is not None and ubound is not None and (lbound > ubound):
854
- raise ValueError("Lowerbound value '{}' must be less than upperbound value '{}'.".format(lbound, ubound))
855
-
856
- # If argument is None, do not validate the argument.
857
- if arg is None:
858
- return True
859
-
860
- is_arg_in_lower_bound, is_arg_in_upper_bound = True, True
861
- lbound_msg, ubound_msg = "", ""
862
-
863
- # Check for lower bound.
864
- if lbound is not None:
865
- if lbound_inclusive:
866
- is_arg_in_lower_bound = arg >= lbound
867
- lbound_msg = "greater than or equal to {}".format(lbound)
868
- else:
869
- is_arg_in_lower_bound = arg > lbound
870
- lbound_msg = "greater than {}".format(lbound)
871
-
872
- # Check for upper bound.
873
- if ubound is not None:
874
- if ubound_inclusive:
875
- is_arg_in_upper_bound = arg <= ubound
876
- ubound_msg = "less than or equal to {}".format(ubound)
877
- else:
878
- is_arg_in_upper_bound = arg < ubound
879
- ubound_msg = "less than {}".format(ubound)
880
-
881
- if not (is_arg_in_lower_bound and is_arg_in_upper_bound):
882
- # If both lower bound and upper bound error messages available, append 'and' to
883
- # upper bound message.
884
- if lbound_msg and ubound_msg:
885
- ubound_msg = " and {}".format(ubound_msg)
886
- raise ValueError(
887
- Messages.get_message(MessageCodes.TDMLDF_LBOUND_UBOUND).format(arg_name, lbound_msg, ubound_msg))
888
-
889
- return True
890
-
891
- @staticmethod
892
- def _validate_vantage_version(vantage_version):
893
- """
894
- Function to verify whether the given vantage_version is
895
- supported or not.
896
-
897
- PARAMETERS:
898
- vantage_version:
899
- Required Argument.
900
- Specifies the vantage version.
901
-
902
- RETURNS:
903
- True, if the current vantage version is supported or not.
904
-
905
- RAISES:
906
- TeradataMLException
907
-
908
- EXAMPLES:
909
- _Validators._validate_vantage_version("vantage1.0")
910
- """
911
- supported_vantage_versions = TeradataConstants.SUPPORTED_VANTAGE_VERSIONS.value
912
-
913
- # Raise exception if the vantage version is not supported.
914
- if vantage_version not in supported_vantage_versions.keys():
915
- err_ = Messages.get_message(MessageCodes.CONFIG_ALIAS_VANTAGE_VERSION_NOT_SUPPORTED). \
916
- format(vantage_version, ", ".join(supported_vantage_versions.keys()))
917
- raise TeradataMlException(err_,
918
- MessageCodes.CONFIG_ALIAS_VANTAGE_VERSION_NOT_SUPPORTED)
919
-
920
- return True
921
-
922
- @staticmethod
923
- def _validate_timebucket_duration(timebucket_duration, timebucket_duration_arg_name='timebucket_duration'):
924
- """
925
- Internal function to validate timeduration_bucket specified when creating a
926
- Primary Time Index (PTI) table.
927
-
928
- PARAMETERS:
929
- timebucket_duration:
930
- Specifies the timebucket_duration passed to a function().
931
- Types: str
932
-
933
- timebucket_duration_arg_name:
934
- Specifies the name of the argument to be displayed in the error message.
935
- Types: str
936
-
937
- RETURNS:
938
- True if the value is valid.
939
-
940
- RAISES:
941
- ValueError or TeradataMlException when the value is invalid.
942
-
943
- EXAMPLES:
944
- _Validators._validate_timebucket_duration('HOURS(2)')
945
- _Validators._validate_timebucket_duration('2hours')
946
- _Validators._validate_timebucket_duration('ayear') # Invalid
947
- """
948
- # Return True is it is not specified or is None since it is optional
949
- if timebucket_duration is None:
950
- return True
951
-
952
- # Check if notation if formal or shorthand (beginning with a digit)
953
- if timebucket_duration[0].isdigit():
954
- valid_timebucket_durations = PTITableConstants.VALID_TIMEBUCKET_DURATIONS_SHORTHAND.value
955
- pattern_to_use = PTITableConstants.PATTERN_TIMEBUCKET_DURATION_SHORT.value
956
- normalized_timebucket_duration = timebucket_duration.lower()
957
- else:
958
- valid_timebucket_durations = PTITableConstants.VALID_TIMEBUCKET_DURATIONS_FORMAL.value
959
- pattern_to_use = PTITableConstants.PATTERN_TIMEBUCKET_DURATION_FORMAL.value
960
- normalized_timebucket_duration = timebucket_duration.upper()
961
-
962
- for timebucket_duration_notation in valid_timebucket_durations:
963
- pattern = re.compile(pattern_to_use.format(timebucket_duration_notation))
964
- match = pattern.match(normalized_timebucket_duration)
965
- if match is not None:
966
- n = int(match.group(1))
967
- _Validators._validate_positive_int(n, "n", ubound=32767)
968
-
969
- # Looks like the value is valid
970
- return True
971
-
972
- # Match not found
973
- raise ValueError(Messages.get_message(
974
- MessageCodes.INVALID_ARG_VALUE).format(timebucket_duration, timebucket_duration_arg_name,
975
- 'a valid time unit of format time_unit(n) or it\'s short hand '
976
- 'equivalent notation'))
977
-
978
- @staticmethod
979
- def _validate_column_type(df, col, col_arg, expected_types, raiseError = True):
980
- """
981
- Internal function to validate the type of an input DataFrame column against
982
- a list of expected types.
983
-
984
- PARAMETERS
985
- df:
986
- Required Argument.
987
- Specifies the input teradataml DataFrame which has the column to be tested
988
- for type.
989
- Types: teradataml DataFrame
990
-
991
- col:
992
- Required Argument.
993
- Specifies the column in the input DataFrame to be tested for type.
994
- Types: str
995
-
996
- col_arg:
997
- Required Argument.
998
- Specifies the name of the argument used to pass the column name.
999
- Types: str
1000
-
1001
- expected_types:
1002
- Required Argument.
1003
- Specifies a list of teradatasqlachemy datatypes that the column is
1004
- expected to be of type.
1005
- Types: list of SQLAlchemy types
1006
-
1007
- raiseError:
1008
- Optional Argument.
1009
- Specifies a boolean flag that decides whether to raise error or just return True or False.
1010
- Default Values: True, raise exception if column is not of desired type.
1011
- Types: bool
1012
-
1013
- RETURNS:
1014
- True, when the columns is of an expected type.
1015
-
1016
- RAISES:
1017
- TeradataMlException, when the columns is not one of the expected types.
1018
-
1019
- EXAMPLES:
1020
- _Validators._validate_column_type(df, timecode_column, 'timecode_column', PTITableConstants.VALID_TIMECODE_DATATYPES)
1021
- """
1022
- if not any(isinstance(df[col].type, t) for t in expected_types):
1023
- if raiseError:
1024
- raise TeradataMlException(Messages.get_message(MessageCodes.INVALID_COLUMN_TYPE).
1025
- format(col_arg, df[col].type, ' or '.join(expected_type.__visit_name__
1026
- for expected_type in expected_types)),
1027
- MessageCodes.INVALID_COLUMN_TYPE)
1028
- else:
1029
- return False
1030
-
1031
- return True
1032
-
1033
- @staticmethod
1034
- def _validate_aggr_operation_unsupported_datatype(operation, columns, td_column_names_and_types):
1035
- """
1036
- Internal function to validate the for unsupported data types of an input DataFrame column for
1037
- an aggreagate function.
1038
-
1039
- PARAMETERS
1040
- operation:
1041
- Required Argument.
1042
- Specifies the name of the aggregate operation.
1043
- Types: str
1044
-
1045
- columns:
1046
- Required Argument.
1047
- Specifies the column names to be validated for datatype check.
1048
- Types: str
1049
-
1050
- td_column_names_and_types:
1051
- Required Argument.
1052
- Specifies the input teradataml DataFrames column name to SQLAlchemy type mapper.
1053
- Types: str
1054
-
1055
- RETURNS:
1056
- None
1057
-
1058
- RAISES:
1059
- TeradataMlException, when the columns is not one of the expected types.
1060
-
1061
- EXAMPLES:
1062
- _Validators._validate_aggr_operation_unsupported_datatype(operation, columns, td_column_names_and_types):
1063
- """
1064
- # Check if the user provided columns has unsupported datatype for aggregate operation or not.
1065
- # Get the list of unsupported types for aggregate function.
1066
- unsupported_types = _Dtypes._get_unsupported_data_types_for_aggregate_operations(operation)
1067
- invalid_columns = []
1068
-
1069
- for column in columns:
1070
- if isinstance(td_column_names_and_types[column.lower()], tuple(unsupported_types)):
1071
- invalid_columns.append(
1072
- "({0} - {1})".format(column, td_column_names_and_types[column.lower()]))
1073
-
1074
- if len(invalid_columns) > 0:
1075
- invalid_columns.sort() # helps in catching the columns in
1076
- # lexicographic order
1077
- error = MessageCodes.TDMLDF_AGGREGATE_UNSUPPORTED.value.format(
1078
- ", ".join(invalid_columns), operation)
1079
- msg = Messages.get_message(MessageCodes.TDMLDF_AGGREGATE_COMBINED_ERR). \
1080
- format(error)
1081
- raise TeradataMlException(msg, MessageCodes.TDMLDF_AGGREGATE_COMBINED_ERR)
1082
-
1083
- @staticmethod
1084
- def _validate_str_arg_length(arg_name, arg_value, op, length):
1085
- """
1086
- Internal function to validate the length of a string passed as an argument.
1087
-
1088
- PARAMETERS
1089
- arg_name:
1090
- Required Argument.
1091
- Specifies the name of the argument for which we need to validate the value length.
1092
- Types: str
1093
-
1094
- arg_value:
1095
- Required Argument.
1096
- Specifies the value passed to the argument.
1097
- Types: str
1098
-
1099
- op:
1100
- Required Argument.
1101
- Specifies the type of check, and can be one of:
1102
- * LT - Less than
1103
- * LE - less than or equal to
1104
- * GT - greater than
1105
- * GE - greater than or equal to
1106
- * EQ - equal to
1107
- * NE - not equal to
1108
- Types: str
1109
- Permitted Values: ['LT', 'LE', 'GT', 'GE', 'EQ', 'NE']
1110
-
1111
- length:
1112
- Required Argument.
1113
- Specifies the length against which the 'op' check for the argument value length will be made.
1114
- Types: int
1115
-
1116
- RETURNS:
1117
- None
1118
-
1119
- RAISES:
1120
- ValueError.
1121
-
1122
- EXAMPLES:
1123
- _Validators._validate_str_arg_length("name", "The value", 10):
1124
- """
1125
- return _Validators._validate_arg_length(arg_name=arg_name, arg_value=arg_value, op=op, length=length)
1126
-
1127
- @staticmethod
1128
- def _validate_arg_length(arg_name, arg_value, op, length):
1129
- """
1130
- Internal function to validate the length of an argument.
1131
-
1132
- PARAMETERS
1133
- arg_name:
1134
- Required Argument.
1135
- Specifies the name of the argument for which we need to validate the value length.
1136
- Types: str
1137
-
1138
- arg_value:
1139
- Required Argument.
1140
- Specifies the value passed to the argument.
1141
- Types: str or list or tuple or set or dict
1142
-
1143
- op:
1144
- Required Argument.
1145
- Specifies the type of check, and can be one of:
1146
- * LT - Less than
1147
- * LE - less than or equal to
1148
- * GT - greater than
1149
- * GE - greater than or equal to
1150
- * EQ - equal to
1151
- * NE - not equal to
1152
- Types: str
1153
- Permitted Values: ['LT', 'LE', 'GT', 'GE', 'EQ', 'NE']
1154
-
1155
- length:
1156
- Required Argument.
1157
- Specifies the length against which the 'op' check for the argument value length will be made.
1158
- Types: int
1159
-
1160
- RETURNS:
1161
- None
1162
-
1163
- RAISES:
1164
- ValueError.
1165
-
1166
- EXAMPLES:
1167
- _Validators._validate_arg_length("name", [1, 2, 3], 3):
1168
- """
1169
- # Check if the length of the string value for the argument is acceptable.
1170
- # First, check if op is an acceptable operation.
1171
- acceptable_op = {'LT': int.__lt__,
1172
- 'LE': int.__le__,
1173
- 'GT': int.__gt__,
1174
- 'GE': int.__ge__,
1175
- 'EQ': int.__eq__,
1176
- 'NE': int.__ne__
1177
- }
1178
- if op not in acceptable_op:
1179
- raise ValueError(Messages.get_message(MessageCodes.INVALID_ARG_VALUE,
1180
- op, "op", acceptable_op))
1181
-
1182
- # Format the error message with the substring based on the op type.
1183
- errors = {'LT': "less than {}",
1184
- 'LE': "less than or equal to {}",
1185
- 'GT': "greater than {}",
1186
- 'GE': "greater than or equal to {}",
1187
- 'EQ': "equal to {}",
1188
- 'NE': "not equal to {}"
1189
- }
1190
- if not acceptable_op[op](len(arg_value), length):
1191
- if isinstance(arg_value, str):
1192
- raise ValueError(Messages.get_message(MessageCodes.INVALID_LENGTH_STRING_ARG,
1193
- arg_name, errors[op].format(length)))
1194
- raise ValueError(Messages.get_message(MessageCodes.INVALID_LENGTH_ARG, type(arg_value).__name__,
1195
- arg_name, errors[op].format(length)))
1196
- return True
1197
-
1198
- @staticmethod
1199
- def _validate_file_exists(file_path):
1200
- """
1201
- DESCRIPTION:
1202
- Function to validate whether the path specified is a file and if it exists.
1203
-
1204
- PARAMETERS:
1205
- file_path:
1206
- Required Argument.
1207
- Specifies the path of the file.
1208
- Types: str
1209
-
1210
- RETURNS:
1211
- True, if the path is a file and it exists.
1212
-
1213
- RAISES:
1214
- TeradataMLException
1215
-
1216
- EXAMPLES:
1217
- _Validators._validate_file_exists("/data/mapper.py")
1218
- """
1219
- if not Path(file_path).exists() or not os.path.isfile(file_path):
1220
- raise TeradataMlException(
1221
- Messages.get_message(MessageCodes.INPUT_FILE_NOT_FOUND).format(file_path),
1222
- MessageCodes.INPUT_FILE_NOT_FOUND)
1223
-
1224
- return True
1225
-
1226
- @staticmethod
1227
- def _validate_mutually_exclusive_arguments(arg1, err_disp_arg1_name, arg2,
1228
- err_disp_arg2_name, skip_all_none_check=False):
1229
- """
1230
- DESCRIPTION:
1231
- Function to validate whether "arg1" and "arg2" are mutually exclusive.
1232
-
1233
- PARAMETERS:
1234
- arg1:
1235
- Required Argument.
1236
- Specifies the value of argument1.
1237
- Types: Any
1238
-
1239
- err_disp_arg1_name:
1240
- Required Argument.
1241
- Specifies the name of argument1.
1242
- Types: str
1243
-
1244
- arg2:
1245
- Required Argument.
1246
- Specifies the value of argument2.
1247
- Types: Any
1248
-
1249
- err_disp_arg2_name:
1250
- Required Argument.
1251
- Specifies the name of argument2.
1252
- Types: str
1253
-
1254
- skip_all_none_check:
1255
- Optional Argument.
1256
- Specifies whether to skip check when arg1 and arg2 both are None.
1257
- Default Value: False
1258
- Types: bool
1259
-
1260
- RETURNS:
1261
- True, if either arg1 or arg2 is None or both are None.
1262
-
1263
- RAISES:
1264
- TeradataMLException
1265
-
1266
- EXAMPLES:
1267
- _Validators._validate_mutually_exclusive_arguments(arg1, "arg1", arg2, "arg2")
1268
- """
1269
- both_args_none = arg1 is None and arg2 is None
1270
- if skip_all_none_check:
1271
- both_args_none = False
1272
-
1273
- # Either both the arguments are specified or both are None.
1274
- if all([arg1, arg2]) or both_args_none:
1275
- raise TeradataMlException(Messages.get_message(
1276
- MessageCodes.EITHER_THIS_OR_THAT_ARGUMENT, err_disp_arg1_name,
1277
- err_disp_arg2_name), MessageCodes.EITHER_THIS_OR_THAT_ARGUMENT)
1278
- return True
1279
-
1280
- @staticmethod
1281
- def _validate_unexpected_column_type(df, col, col_arg, unexpected_types, check_exist=True, raise_error=True):
1282
- """
1283
- Internal function to validate the column existence and type of an input DataFrame column against
1284
- a list of unexpected types.
1285
-
1286
- PARAMETERS
1287
- df:
1288
- Required Argument.
1289
- Specifies the input teradataml DataFrame which has the column(s) to be tested
1290
- for type.
1291
- Types: teradataml DataFrame
1292
-
1293
- col:
1294
- Required Argument.
1295
- Specifies the column(s) in the input DataFrame to be tested for type.
1296
- Types: str (or) ColumnExpression (or) List of strings(str)
1297
- or ColumnExpressions
1298
-
1299
- col_arg:
1300
- Required Argument.
1301
- Specifies the name of the argument used to pass the column(s) name.
1302
- Types: str
1303
-
1304
- unexpected_types:
1305
- Required Argument.
1306
- Specifies unsupported teradatasqlalcehmy datatypes for the column is
1307
- unexpected to be of type.
1308
- Types: list of SQLAlchemy types
1309
-
1310
- check_exist:
1311
- Optional Argument.
1312
- Specifies a boolean flag that decides whether to check for column is
1313
- existed in DataFrame or not.
1314
- Default Values: True, raise exception if column is not of desired type.
1315
- Types: bool
1316
-
1317
- raise_error:
1318
- Optional Argument.
1319
- Specifies a boolean flag that decides whether to raise error or just return True or False.
1320
- Default Values: True, raise exception if column is not of desired type.
1321
- Types: bool
1322
-
1323
- RETURNS:
1324
- True, when the columns is of an expected type.
1325
-
1326
- RAISES:
1327
- TeradataMlException, when the columns is not one of the expected types.
1328
-
1329
- EXAMPLES:
1330
- _Validators._validate_unexpected_column_type(
1331
- df, timecode_column, 'timecode_column', PTITableConstants.VALID_TIMECODE_DATATYPES)
1332
- """
1333
-
1334
- columns = [col] if not isinstance(col, list) else col
1335
-
1336
- # Converting "unexpected_types" to tuple as isinstance can accept Tuple
1337
- # of types too.
1338
- unexpected_types = tuple(unexpected_types)
1339
-
1340
- for col in columns:
1341
- # Get the name of the column if "col" is ColumnExpression.
1342
- if not isinstance(col, str):
1343
- col = col.name
1344
-
1345
- # Check for column existence.
1346
- if check_exist:
1347
- _Validators._validate_column_exists_in_dataframe(col, df._metaexpr)
1348
-
1349
- if isinstance(df[col].type, unexpected_types):
1350
- if raise_error:
1351
- invalid_column_types = (col_type.__name__ for col_type in
1352
- unexpected_types)
1353
- error_message = Messages.get_message(MessageCodes.INVALID_COLUMN_DATATYPE,
1354
- col,
1355
- col_arg,
1356
- "Unsupported",
1357
- ", ".join(invalid_column_types))
1358
- raise TeradataMlException(error_message, MessageCodes.INVALID_COLUMN_DATATYPE)
1359
-
1360
- else:
1361
- return False
1362
-
1363
- return True
1364
-
1365
- @staticmethod
1366
- def _validate_dependent_argument(dependent_arg, dependent_arg_value, independent_arg, independent_arg_value,
1367
- msg_arg_value=None):
1368
- """
1369
- DESCRIPTION:
1370
- Function validates if an independent argument is specified or not when
1371
- dependent argument is specified. Raises error, if independent argument
1372
- is not specified and dependent argument is specified, otherwise returns True.
1373
-
1374
- PARAMETERS:
1375
- dependent_arg:
1376
- Required Argument.
1377
- Specifies the name of dependent argument.
1378
- Types: String
1379
-
1380
- dependent_arg_value:
1381
- Required Argument.
1382
- Specifies the value of dependent argument.
1383
- Types: Any
1384
-
1385
- independent_arg:
1386
- Required Argument.
1387
- Specifies the name of independent argument.
1388
- Types: String
1389
-
1390
- independent_arg_value:
1391
- Required Argument.
1392
- Specifies the value of independent argument.
1393
- Types: Any
1394
-
1395
- msg_arg_value:
1396
- Optional Argument.
1397
- Specifies the independent argument value to be printed in message
1398
- instead of "(not None)".
1399
- Types: String
1400
-
1401
- RETURNS:
1402
- True, when the independent argument is present for the dependent
1403
- argument.
1404
-
1405
- RAISES:
1406
- TeradataMlException, when independent argument is not specified and
1407
- dependent argument is specified.
1408
-
1409
- EXAMPLES:
1410
- _Validators._validate_dependent_argument("dependent_arg_name", admissions_train,
1411
- "independent_arg_name", None)
1412
- _Validators._validate_dependent_argument("dependent_arg_name", None,
1413
- "independent_arg_name", admissions_train)
1414
- _Validators._validate_dependent_argument("dependent_arg_name", admissions_train,
1415
- "independent_arg_name", admissions_train)
1416
- _Validators._validate_dependent_argument("dependent_arg_name", admissions_train,
1417
- "independent_arg_name", admissions_train,
1418
- "arg_val")
1419
- """
1420
- if dependent_arg_value is not None and independent_arg_value is None:
1421
- error_code = MessageCodes.DEPENDENT_ARGUMENT
1422
- error_msg = Messages.get_message(error_code, dependent_arg, independent_arg)
1423
- if msg_arg_value is None:
1424
- raise TeradataMlException(error_msg, error_code)
1425
- else:
1426
- raise TeradataMlException(error_msg.replace("(not None)", "as '{}'".format(msg_arg_value)),
1427
- MessageCodes.DEPENDENT_ARGUMENT)
1428
- return True
1429
-
1430
- @staticmethod
1431
- def _validate_py_type_for_td_type_conversion(py_type, py_type_arg_name):
1432
- """
1433
- DESCRIPTION:
1434
- Function to validate python type, which needs to be converted to TD Type.
1435
- This function checks whether the python type can be converted to a TD
1436
- type or not. If PY type is not able to convert TD Type, it then raises
1437
- an error.
1438
-
1439
- PARAMETERS:
1440
- py_type:
1441
- Required Argument.
1442
- Specifies the python type.
1443
- Types: Any
1444
-
1445
- py_type_arg_name:
1446
- Required Argument.
1447
- Specifies the name of argument which holds python variable.
1448
- Types: str
1449
-
1450
- RETURNS:
1451
- None
1452
-
1453
- RAISES:
1454
- TeradataMLException
1455
-
1456
- EXAMPLES:
1457
- _Validators._validate_py_type_for_td_type_conversion(int, "arg1")
1458
- """
1459
- if py_type not in _DtypesMappers.PY_TD_MAPPER:
1460
- error_code = MessageCodes.UNSUPPORTED_DATATYPE
1461
- error_msg = Messages.get_message(
1462
- error_code, py_type_arg_name, '[{}]'.format(", ".join((t.__name__ for t in _DtypesMappers.PY_TD_MAPPER))))
1463
- raise TeradataMlException(error_msg, error_code)
1464
-
1465
- @staticmethod
1466
- def _validate_function_install_location_is_set(option, function_type, option_name):
1467
- """
1468
- DESCRIPTION:
1469
- Function to validate whether install location for functions is set.
1470
-
1471
- PARAMETERS:
1472
- option:
1473
- Required Argument.
1474
- Specifies the configuration option value to validate.
1475
- Types: str
1476
-
1477
- function_type:
1478
- Required Argument.
1479
- Specifies the type of function to check installed location for.
1480
- Types: str
1481
-
1482
- option_name:
1483
- Required Argument.
1484
- Specifies the configuration option name.
1485
- Types: str
1486
-
1487
- RETURNS:
1488
- None
1489
-
1490
- RAISES:
1491
- TeradataMLException
1492
-
1493
- EXAMPLES:
1494
- _Validators._validate_function_install_location_is_set(
1495
- configure.byom_install_location,
1496
- "Bring Your Own Model",
1497
- "configure.byom_install_location")
1498
- """
1499
- # Check whether an empty string is passed to "option".
1500
- _Validators._validate_input_columns_not_empty(option, option_name)
1501
-
1502
- if option is None:
1503
- message = Messages.get_message(MessageCodes.UNKNOWN_INSTALL_LOCATION,
1504
- "{} functions".format(function_type),
1505
- "option '{}'".format(option_name))
1506
- raise TeradataMlException(message, MessageCodes.MISSING_ARGS)
1507
-
1508
- @staticmethod
1509
- def _check_table_exists(conn, table_name,
1510
- schema_name,
1511
- raise_error_if_does_not_exists=True,
1512
- additional_error=''):
1513
- """
1514
- DESCRIPTION:
1515
- Check whether table specified exists or not.
1516
-
1517
- PARAMETERS:
1518
- raise_error_if_does_not_exists:
1519
- Optional Argument.
1520
- Specifies the flag to decide whether to raise error when table name specified does not exist.
1521
- Default Value: True (Raise exception)
1522
- Types: bool
1523
-
1524
- additional_error:
1525
- Optional Argument.
1526
- Specifies the additional error message to display along with standard message.
1527
- Default Value: ''
1528
- Types: String
1529
-
1530
- RAISES:
1531
- TeradataMlException.
1532
-
1533
- RETURNS:
1534
- True, if table exists, else False.
1535
-
1536
- EXAMPLES:
1537
- >>> _check_table_exists('model_table_name','model_schema_name')
1538
- """
1539
-
1540
- # Check whether table exists on the system or not.
1541
- table_exists = conn.dialect.has_table(conn, table_name=table_name,
1542
- schema=schema_name)
1543
-
1544
- # If tables exists, return True.
1545
- if table_exists:
1546
- return True
1547
-
1548
- # We are here means the specified table does not exist.
1549
- # Let's raise error if 'raise_error_if_does_not_exists' set to True.
1550
- if raise_error_if_does_not_exists:
1551
- # Raise error, as the specified table_name does not exist.
1552
- # TABLE_DOES_NOT_EXIST
1553
- raise TeradataMlException(Messages.get_message(MessageCodes.TABLE_DOES_NOT_EXIST,
1554
- schema_name, table_name, additional_error),
1555
- MessageCodes.TABLE_DOES_NOT_EXIST)
1556
- return False
1557
-
1558
- @staticmethod
1559
- def _check_empty_file(file_path):
1560
- """
1561
- Description:
1562
- Function to validate whether the given file is not empty,
1563
- given absolute file path.
1564
-
1565
- PARAMETERS:
1566
- file_path:
1567
- Required Argument.
1568
- Specifies absolute file path of the file.
1569
- Types: str
1570
-
1571
- RETURNS:
1572
- Boolean
1573
-
1574
- RAISES:
1575
- TeradataMlException
1576
-
1577
- EXAMPLES:
1578
- _check_empty_file("/abc/xyz.txt")
1579
- """
1580
-
1581
- if os.stat(file_path).st_size == 0:
1582
- raise TeradataMlException(
1583
- Messages.get_message(MessageCodes.EMPTY_FILE,
1584
- "{}".format(file_path)),
1585
- MessageCodes.EMPTY_FILE)
1586
- return True
1587
-
1588
- @staticmethod
1589
- def _validate_mutually_inclusive_arguments(arg1, err_disp_arg1_name, arg2,
1590
- err_disp_arg2_name):
1591
- """
1592
- DESCRIPTION:
1593
- Function to validate whether "arg1" and "arg2" are mutually inclusive.
1594
-
1595
- PARAMETERS:
1596
- arg1:
1597
- Required Argument.
1598
- Specifies the value of argument1.
1599
- Types: Any
1600
-
1601
- err_disp_arg1_name:
1602
- Required Argument.
1603
- Specifies the name of argument1.
1604
- Types: str
1605
-
1606
- arg2:
1607
- Required Argument.
1608
- Specifies the value of argument2.
1609
- Types: Any
1610
-
1611
- err_disp_arg2_name:
1612
- Required Argument.
1613
- Specifies the name of argument2.
1614
- Types: str
1615
-
1616
- RETURNS:
1617
- True, if both arg1 and arg2 are present or both are None.
1618
-
1619
- RAISES:
1620
- TeradataMLException
1621
-
1622
- EXAMPLES:
1623
- _Validators._validate_mutually_inclusive_arguments(arg1, "arg1", arg2, "arg2")
1624
- """
1625
- both_args_none = arg1 is None and arg2 is None
1626
- # If below handles 0 value.
1627
- # 0 turns to False using bool(0) but 0 is a valid value and should return True.
1628
- arg1 = True if arg1 == 0 else bool(arg1)
1629
- arg2 = True if arg2 == 0 else bool(arg2)
1630
-
1631
- # Either both the arguments are specified or both are None.
1632
- if not(all([arg1, arg2]) or both_args_none):
1633
- arg_order = [err_disp_arg1_name, err_disp_arg2_name] if arg1 \
1634
- else [err_disp_arg2_name, err_disp_arg1_name]
1635
- raise TeradataMlException(Messages.get_message(
1636
- MessageCodes.DEPENDENT_ARGUMENT, arg_order[0],
1637
- arg_order[1]), MessageCodes.DEPENDENT_ARGUMENT)
1638
- return True
1639
-
1640
- @staticmethod
1641
- def _validate_file_extension(file_path, extension):
1642
- """
1643
- DESCRIPTION:
1644
- Function to validate whether the file has a specified extension.
1645
-
1646
- PARAMETERS:
1647
- file_path:
1648
- Required Argument.
1649
- Specifies the file path or file name.
1650
- Types: str
1651
-
1652
- extension:
1653
- Required Argument.
1654
- Specifies the extension of the file.
1655
- Types: str OR list of Strings (str)
1656
-
1657
- RETURNS:
1658
- True, if the file has specified extension.
1659
-
1660
- RAISES:
1661
- TeradataMLException
1662
-
1663
- EXAMPLES:
1664
-
1665
- _Validators._validate_file_extension("/data/mapper.py",".py")
1666
- _Validators._validate_file_extension("ml__demoenv_requirements_1605727131624097.txt",".txt")
1667
- """
1668
- extension = extension if isinstance(extension, list) else[extension]
1669
- file_extension = file_path.lower().split('.')[-1]
1670
- if file_extension not in extension:
1671
- raise TeradataMlException(
1672
- Messages.get_message(MessageCodes.UNSUPPORTED_FILE_EXTENSION).format("{}".format(extension)),
1673
- MessageCodes.UNSUPPORTED_FILE_EXTENSION)
1674
-
1675
- return True
1676
-
1677
- @staticmethod
1678
- def _validate_argument_is_not_None(arg, arg_name, additional_error="", reverse=False):
1679
- """
1680
- DESCRIPTION:
1681
- Check whether the argument provided is not None.
1682
- If parameter reverse is set to True, the validation is reversed to
1683
- check whether argument provided is None.
1684
-
1685
- PARAMETERS:
1686
- arg:
1687
- Required Argument.
1688
- Specifies the argument to be validated.
1689
- Types: str
1690
-
1691
- arg_name:
1692
- Required Argument.
1693
- Specifies the name of the argument to be printed in error message.
1694
- Types: str
1695
-
1696
- additional_error:
1697
- Optional Argument.
1698
- Specifies the additional error message to display along with standard message.
1699
- Default value=""
1700
- Types: str
1701
-
1702
- reverse:
1703
- Optional Argument.
1704
- Specifies whether to reverse the validation.
1705
- Returns True if arg is None, False if arg is not None.
1706
- Default value=False
1707
- Types: bool
1708
-
1709
-
1710
- RAISES:
1711
- ValueError.
1712
-
1713
- RETURNS:
1714
- True, if the argument is not None, else False.
1715
-
1716
- EXAMPLES:
1717
- >>> _validate_argument_is_not_None(table_name, "table_name", additional_error)
1718
- """
1719
- if not reverse:
1720
- # Raise an error if the argument is None.
1721
- if arg is None:
1722
- raise ValueError(Messages.get_message(MessageCodes.ARG_NONE, arg_name, "None", additional_error))
1723
- return True
1724
- else:
1725
- # Raise an error if the argument is not None.
1726
- if arg is not None:
1727
- raise ValueError(Messages.get_message(MessageCodes.ARG_NONE, arg_name,
1728
- "provided {}".format(additional_error), ""))
1729
- return True
1730
-
1731
-
1732
- @staticmethod
1733
- def _validate_dataframe(df, raise_error=True):
1734
- """
1735
- This is an internal function checks whether the dataframe is none
1736
- or not. If not none then checks the dataframe type and length of columns.
1737
-
1738
- PARAMETERS:
1739
- df:
1740
- Required Argument.
1741
- Specifies the dataframe.
1742
- Types: pandas.DataFrame or teradataml.dataframe.dataframe.DataFrame
1743
-
1744
- raise_error:
1745
- Optional Argument.
1746
- Specifies whether to raise an exception or not.
1747
- Default Values: True
1748
- Types: bool
1749
-
1750
- RETURNS:
1751
- None
1752
-
1753
- RAISES:
1754
- TeradataMlException
1755
-
1756
- EXAMPLES:
1757
- _validate_dataframe(df)
1758
-
1759
- """
1760
- from teradataml.dataframe import dataframe as tdmldf
1761
-
1762
- valid = False
1763
- if df is not None:
1764
- if isinstance(df, pd.DataFrame) and len(df.columns) > 0:
1765
- valid = True
1766
- elif isinstance(df, tdmldf.DataFrame) and len(df._metaexpr.c) > 0:
1767
- valid = True
1768
- else:
1769
- valid = False
1770
-
1771
- if raise_error and not valid:
1772
- raise TeradataMlException(Messages.get_message(MessageCodes.IS_NOT_VALID_DF),
1773
- MessageCodes.IS_NOT_VALID_DF)
1774
-
1775
-
1776
- @staticmethod
1777
- def _validate_column_value_length(argument_name, argument_value, allowed_length,
1778
- operation='perform the operation'):
1779
- """
1780
- DESCRIPTION:
1781
- Function to validate length of string against permitted value.
1782
-
1783
- PARAMETERS:
1784
- argument_name:
1785
- Required Argument.
1786
- Specifies the name of the argument whose value
1787
- will be checked against permitted length.
1788
- This is used while raising an error.
1789
- Types: str.
1790
-
1791
- argument_value:
1792
- Required Argument.
1793
- Specifies the string whose length will be checked against permitted length.
1794
- Types: str.
1795
-
1796
- allowed_length:
1797
- Required Argument.
1798
- Specifies the allowed length for argument value.
1799
- Types: int.
1800
-
1801
- operation:
1802
- Optional Argument.
1803
- Specifies the name of operation which will fail, if this check fails.
1804
- Default value: 'perform the operation'.
1805
- Types: str.
1806
-
1807
- RETURNS:
1808
- None.
1809
-
1810
- RAISES:
1811
- TeradataMlException - EXECUTION_FAILED, ValueError
1812
-
1813
- EXAMPLES:
1814
- >>> _validate_column_value_length("Description", "KMeans model", 150, "save the model")
1815
- """
1816
- try:
1817
- _Validators._validate_str_arg_length(argument_name, argument_value, 'LE', allowed_length)
1818
- except ValueError:
1819
- error_code = MessageCodes.EXECUTION_FAILED
1820
- error_msg = Messages.get_message(
1821
- error_code, operation,
1822
- 'Length of argument {0} ({1}) is more than the allowed length ({2}).'
1823
- .format(argument_name, len(argument_value), allowed_length))
1824
- raise TeradataMlException(error_msg, error_code)
1825
- return True
1826
-
1827
-
1828
- @staticmethod
1829
- def _validate_list_lengths_equal(list1, arg_name1, list2, arg_name2):
1830
- """
1831
- DESCRIPTION:
1832
- Check if length of the lists is same or not.
1833
-
1834
- PARAMETERS:
1835
- list1:
1836
- Required Argument.
1837
- Specifies the first list to check the length against "list2".
1838
- Types: list
1839
-
1840
- arg_name1:
1841
- Required Argument.
1842
- Specifies the name of the argument that accepts "list1" as input.
1843
- This is used while raising an error.
1844
- Types: str
1845
-
1846
- list2:
1847
- Required Argument.
1848
- Specifies the second list to check the length against "list1".
1849
- Types: list
1850
-
1851
- arg_name2:
1852
- Required Argument.
1853
- Specifies the name of the argument that accepts "list2" as input.
1854
- This is used while raising an error.
1855
- Types: str
1856
-
1857
- RETURNS:
1858
- None.
1859
-
1860
- RAISES:
1861
- ValueError
1862
-
1863
- EXAMPLES:
1864
- _Validators._validate_list_lengths_equal(self.coordinates, "coordinates",
1865
- self.timestamps, "timestamps")
1866
- """
1867
- if len(list1) != len(list2):
1868
- # Raise error, if length of both lists is not same.
1869
- err_ = Messages.get_message(MessageCodes.INVALID_LENGTH_ARGS,
1870
- "'{}' and '{}'".format(arg_name1, arg_name2))
1871
- raise ValueError(err_)
1872
- return True
1873
-
1874
- @staticmethod
1875
- def _validate_dict_argument_key_value(arg_name, arg_dict, key_types=None, value_types=None,
1876
- key_permitted_values=None, value_permitted_values=None,
1877
- value_empty_string=True):
1878
- """
1879
- DESCRIPTION:
1880
- Internal function to validate type and permitted values
1881
- for keys and values in a dictionary argument.
1882
-
1883
- PARAMETERS:
1884
- arg_name:
1885
- Required Argument.
1886
- Specifies the name of the dictionary argument.
1887
- Types: str
1888
-
1889
- arg_dict:
1890
- Required Argument.
1891
- Specifies the dictonary value of "arg_name".
1892
- Types: dict
1893
-
1894
- key_types:
1895
- Optional Argument.
1896
- Specifies the types, 'keys' of the "arg_dict" can take.
1897
- Types: Any type or tuple of types
1898
-
1899
- value_types:
1900
- Optional Argument.
1901
- Specifies the types, 'values' assigned to 'keys' of
1902
- "arg_dict" can take.
1903
- Types: Any type or tuple of types
1904
-
1905
- key_permitted_values:
1906
- Optional Argument.
1907
- Specifies the permitted values for the 'keys' of "arg_dict".
1908
- Types: list
1909
-
1910
- value_permitted_values:
1911
- Optional Argument.
1912
- Specifies the permitted values for the 'values' assgined to 'keys'
1913
- of "arg_dict".
1914
- Types: list
1915
-
1916
- value_empty_string:
1917
- Optional Argument.
1918
- Specifies the whether 'values' assigned to 'keys' of "arg_dict"
1919
- can accept empty string.
1920
- Set to True, dictionary value with empty string is accepted.
1921
- Set to False, dictionary value with empty string is not accepted.
1922
- Default Value: True
1923
- Types: bool
1924
-
1925
- RETURNS:
1926
- bool
1927
-
1928
- RAISES:
1929
- TypeError, ValueError
1930
-
1931
- EXAMPLES:
1932
- _Validators._validate_dict_argument_key_value("name", {"a":3, "b":4}, (str), (int))
1933
- _Validators._validate_dict_argument_key_value(arg_name="columns", arg_dict=columns,
1934
- key_types=(ColumnExpression, _TupleOf(ColumnExpression)),
1935
- value_types=(str, int, float, NoneType))
1936
-
1937
- """
1938
- info_matrix = []
1939
- dict_keys_list = set()
1940
- from teradataml.common.utils import UtilFuncs
1941
-
1942
- try:
1943
- for key, value in arg_dict.items():
1944
- # Validate duplicate keys exists or not.
1945
- # If keys are not of type tuple, convert it to tuple.
1946
- keys_list = (key,) if not isinstance(key, tuple) else key
1947
-
1948
- # If duplicate key exists raise exception. E.g.
1949
- # di = {("key1", "key2"): "my_keys1",
1950
- # ("key1", "key3"): "my_keys2",
1951
- # "key2" : "my_keys3"}
1952
- for k in keys_list:
1953
- # If ColumnExpression, get the column name.
1954
- if isinstance(k, ColumnExpression):
1955
- k_name, name = k.name, "ColumnExpression(s)"
1956
- else:
1957
- k_name, name = k, "Key names"
1958
-
1959
- # If duplicate key exists raise exception.
1960
- if k_name in dict_keys_list:
1961
- raise TeradataMlException(Messages.get_message(
1962
- MessageCodes.DUPLICATE_DICT_KEYS_NAMES,
1963
- name, arg_name),
1964
- MessageCodes.DUPLICATE_PARAMETER)
1965
- else:
1966
- dict_keys_list.add(k_name)
1967
-
1968
- # Append "keys" and "values" into arg info matrix for type validation.
1969
- if key_types is not None:
1970
- info_matrix.append(["<dict_key>", key, True, key_types, True])
1971
-
1972
- if value_types is not None:
1973
- info_matrix.append(
1974
- ["<dict_value>", value, True, value_types, not value_empty_string])
1975
-
1976
- # Validate permitted values for both "key" and "value" if permitted values
1977
- # are provided.
1978
- if key_permitted_values is not None:
1979
- _Validators._validate_permitted_values(arg=key,
1980
- permitted_values=key_permitted_values,
1981
- arg_name="<dict_key>",
1982
- case_insensitive=False,
1983
- includeNone=True)
1984
-
1985
- if value_permitted_values is not None:
1986
- _Validators._validate_permitted_values(arg=value,
1987
- permitted_values=value_permitted_values,
1988
- arg_name="<dict_value>",
1989
- case_insensitive=False,
1990
- includeNone=True)
1991
-
1992
- if key_types is not None or value_types is not None:
1993
- # Validate types using already existing validator.
1994
- _Validators._validate_function_arguments(info_matrix)
1995
-
1996
- except ValueError as ve:
1997
- # Catch ValueError raised by '_validate_permitted_values' to
1998
- # raise proper error message for dictionary argument.
1999
- if "TDML_2007" in str(ve):
2000
- permitted_values = value_permitted_values
2001
- err_str = "value"
2002
- err_val = value
2003
- if "<dict_key>" in str(ve):
2004
- permitted_values = key_permitted_values
2005
- err_str = "key"
2006
- err_val = key
2007
- raise ValueError(
2008
- Messages.get_message(MessageCodes.INVALID_DICT_ARG_VALUE, err_val,
2009
- err_str, arg_name, permitted_values))
2010
-
2011
- # Catch ValueError raised by '_validate_function_arguments'
2012
- # for empty string value.
2013
- elif "TDML_2004" in str(ve):
2014
- err_str = "Key" if "<dict_key>" in str(ve) else "Value"
2015
- raise ValueError(
2016
- Messages.get_message(MessageCodes.DICT_ARG_KEY_VALUE_EMPTY,
2017
- err_str, arg_name))
2018
-
2019
- except TypeError as te:
2020
- # Catch TypeError raised by '_validate_function_arguments' to
2021
- # raise proper error message for dictionary argument.
2022
- permitted_types = value_types
2023
- err_str = "value"
2024
- if "<dict_key>" in str(te):
2025
- permitted_types = key_types
2026
- err_str = "key"
2027
-
2028
- permitted_types = [''.join(_Validators.__getTypeAsStr(kv_type))
2029
- if isinstance(kv_type, (_TupleOf, _ListOf)) else
2030
- kv_type.__name__ for kv_type in permitted_types]
2031
-
2032
- raise TypeError(
2033
- Messages.get_message(MessageCodes.UNSUPPORTED_DICT_KEY_VALUE_DTYPE, err_str,
2034
- arg_name, permitted_types))
2035
-
2036
- return True
2037
-
2038
- @staticmethod
2039
- def _validate_http_response(http_response, valid_status_code, error_msg):
2040
- """
2041
- DESCRIPTION:
2042
- Internal function to validate the HTTP response.
2043
-
2044
- PARAMETERS:
2045
- http_response:
2046
- Required Argument.
2047
- Specifies the response object recieved from HTTP request.
2048
- Types: requests.models.Response OR httpx.Response
2049
-
2050
- valid_status_code:
2051
- Required Argument.
2052
- Specifies the HTTP response code of a request.
2053
- Types: int
2054
-
2055
- error_msg:
2056
- Required Argument.
2057
- Specifies the error message to be displayed when response code is
2058
- not equal to "valid_status_code".
2059
- Types: str
2060
-
2061
- RETURNS:
2062
- bool
2063
-
2064
- RAISES:
2065
- TeradatamlException
2066
-
2067
- EXAMPLES:
2068
- _Validators._validate_http_response(resp, 200, "test1")
2069
- """
2070
- if http_response.status_code != valid_status_code:
2071
- err_ = Messages.get_message(MessageCodes.EXECUTION_FAILED,
2072
- error_msg,
2073
- "Error-details: ({}){}".format(http_response.status_code, http_response.text))
2074
- raise TeradataMlException(err_, MessageCodes.EXECUTION_FAILED)
2075
-
2076
- return True
2077
-
2078
- @staticmethod
2079
- def _validate_module_presence(module_name, function_name):
2080
- """
2081
- DESCRIPTION:
2082
- Check if module being imported is present.
2083
-
2084
- PARAMETERS:
2085
- module_name:
2086
- Required Argument.
2087
- Specifies the name of the module to import.
2088
- Types: str
2089
-
2090
- function_name:
2091
- Required Argument.
2092
- Specifies the name of the function from where module is imported.
2093
- Types: str
2094
-
2095
- RETURNS:
2096
- None.
2097
-
2098
- RAISES:
2099
- TeradataMlException
2100
-
2101
- EXAMPLES:
2102
- _Validators._validate_module_presence("docker", "setup_sandbox_env")
2103
- """
2104
- import importlib
2105
-
2106
- try:
2107
- importlib.import_module(module_name, package=None)
2108
- except Exception as err:
2109
- message = \
2110
- Messages.get_message(
2111
- MessageCodes.IMPORT_PYTHON_PACKAGE,
2112
- module_name, module_name, function_name)
2113
- raise TeradataMlException(message,
2114
- MessageCodes.IMPORT_PYTHON_PACKAGE)
2115
- return True
1
+ import numbers
2
+ import os
3
+ import pandas as pd
4
+ from pathlib import Path
5
+ import re
6
+ from teradataml.common.constants import TeradataConstants, PTITableConstants, PythonTypes
7
+ from teradataml.common.exceptions import TeradataMlException
8
+ from teradataml.common.messages import MessageCodes, Messages
9
+ from teradataml.utils.dtypes import _Dtypes, _DtypesMappers, _ListOf, _TupleOf
10
+ from teradataml.options.configure import configure
11
+ from teradataml.dataframe.sql_interfaces import ColumnExpression
12
+ from functools import wraps, reduce
13
+
14
+
15
+ def skip_validation():
16
+ """
17
+ DESCRIPTION:
18
+ Define for skipping the validation.
19
+
20
+ PARAMETERS:
21
+ None
22
+
23
+ EXAMPLES:
24
+ @skip_validation(skip_all=True)
25
+ def validation_func(): ...
26
+
27
+ """
28
+ def decorator(func):
29
+ def wrapper(*args, **kwargs):
30
+ # If "skip_all" flag is set to False,
31
+ # skip all validation execution.
32
+ if not _Validators.skip_all:
33
+ return func(*args, **kwargs)
34
+ return wraps(func)(wrapper)
35
+ return decorator
36
+
37
+
38
+ class _Validators:
39
+ """
40
+ A class containing set of utilities that can be used for validations of various kinds.
41
+ Currently, this facilitates the validations done for:
42
+ 1. Analytic function execution engine: (_validate_engine)
43
+ 2. Validation for the vantage_version: (_validate_vantage_version)
44
+ 3. Validate whether argument has passed with empty string or not: (_validate_input_columns_not_empty)
45
+ 4. Validate for permitted values of the argument: (_validate_permitted_values)
46
+ 5. Validate function arguments. (_validate_function_arguments) This specifically validates for
47
+ 1. Argument types check.
48
+ 2. Argument is empty or not.
49
+ 3. Permitted values check.
50
+ 6. Validate for missing required arguments.
51
+ 7. Validate column exists in a DataFrame or not. (_validate_column_exists_in_dataframe)
52
+ 8. Validate required arguments are missing or not. (_validate_missing_required_arguments)
53
+ 9. Validate whether function install location is set.
54
+ 10. Validate whether the table exist in the schema or not
55
+ 11. Validate whether the given file is not empty, given absolute file path.
56
+ 12. Validate whether "arg1" and "arg2" are mutually inclusive.
57
+ """
58
+
59
+ # "skip_all" specifies to skip all the executions.
60
+ skip_all = False
61
+
62
+ @staticmethod
63
+ @skip_validation()
64
+ def __getTypeAsStr(type_list):
65
+ """
66
+ Function to convert type to string.
67
+
68
+ PARAMETERS:
69
+ type_list
70
+ Required Argument.
71
+ A tuple of types or a type to be converted to string.
72
+
73
+ RAISES:
74
+ None
75
+
76
+ RETURNS:
77
+ A list of strings representing types in type_list.
78
+
79
+ EXAMPLES:
80
+ _Validators.__getTypeAsStr(type_list)
81
+ """
82
+ type_as_str = []
83
+ if isinstance(type_list, tuple):
84
+ for typ in type_list:
85
+ if isinstance(typ, tuple):
86
+ for typ1 in typ:
87
+ type_as_str.append(typ1.__name__)
88
+ elif isinstance(typ, (_ListOf, _TupleOf)):
89
+ type_as_str.append(str(typ))
90
+ elif typ.__name__ == "DataFrame":
91
+ type_as_str.append("teradataml DataFrame")
92
+ else:
93
+ type_as_str.append(typ.__name__)
94
+
95
+ if isinstance(type_list, type):
96
+ if type_list.__name__ == "DataFrame":
97
+ type_as_str.append("teradataml DataFrame")
98
+ else:
99
+ type_as_str.append(type_list.__name__)
100
+
101
+ if isinstance(type_list, (_ListOf, _TupleOf)):
102
+ type_as_str.append(str(type_list))
103
+
104
+ return type_as_str
105
+
106
+ @staticmethod
107
+ @skip_validation()
108
+ def _check_isinstance(obj, class_or_tuple):
109
+ """
110
+ Function checks whether an object is an instance of a class.
111
+
112
+ PARAMETER
113
+ obj:
114
+ Required Argument.
115
+ Specifies the object to check instance of.
116
+
117
+ class_or_tuple:
118
+ Required Argument.
119
+ Specifies the type or tuple of types to check instance against.
120
+
121
+ RAISES:
122
+ None.
123
+
124
+ RETURNS:
125
+ True, if obj is instance of class_or_tuple
126
+
127
+ EXAMPLES:
128
+ _Validators._check_isinstance(obj, (int, list, str))
129
+ """
130
+ # If obj is of type bool and type to check against contains int, then we must
131
+ # check/validate the instance as type(obj) == class_or_tuple.
132
+ # bool is subclass of int, hence isinstance(True, int) will always return true.
133
+ # And we would like to return false, as bool is not a int.
134
+ if not isinstance(obj, bool):
135
+ # If obj of any type other than bool, then we shall use "isinstance()"
136
+ # to perform type checks.
137
+ return isinstance(obj, class_or_tuple)
138
+
139
+ else:
140
+ # 'obj' is of type bool.
141
+ if isinstance(class_or_tuple, tuple):
142
+ if int not in class_or_tuple:
143
+ # If class_or_tuple is instance of tuple and int is not in class_or_tuple
144
+ # use "isinstance()" to validate type check for obj.
145
+ return isinstance(obj, class_or_tuple)
146
+ else:
147
+ return type(obj) in class_or_tuple
148
+
149
+ else: # isinstance(class_or_tuple, type):
150
+ if int != class_or_tuple:
151
+ # If class_or_tuple is instance of type and class_or_tuple is not an int
152
+ # use "isinstance()" to validate type check for obj.
153
+ return isinstance(obj, class_or_tuple)
154
+ else:
155
+ return type(obj) == class_or_tuple
156
+
157
+ @staticmethod
158
+ @skip_validation()
159
+ def _validate_columnexpression_dataframe_has_columns(columns,
160
+ arg_name,
161
+ column_expression):
162
+ """
163
+ DESCRIPTION:
164
+ Function to check whether column name(s) available in dataframe
165
+ or not from a given column. This function is used currently
166
+ only for Window Aggregates.
167
+
168
+ PARAMETERS:
169
+ columns:
170
+ Required Argument.
171
+ Specifies the name or list of names of columns to be validated
172
+ for existence.
173
+ Types: str or List of strings or ColumnExpression or list of ColumnExpression
174
+
175
+ arg_name:
176
+ Required Argument.
177
+ Specifies the name of the argument.
178
+ Types: str
179
+
180
+ column_expression:
181
+ Required Argument.
182
+ Specifies teradataml DataFrame Column to check against for
183
+ column existence.
184
+ Types: ColumnExpression
185
+
186
+ RAISES:
187
+ ValueError
188
+
189
+ RETURNS:
190
+ bool
191
+
192
+ EXAMPLES:
193
+ _Validators._validate_dataframe_has_argument_columns_from_column(self.data_sequence_column,
194
+ "data_sequence_column",
195
+ self.data.col)
196
+ """
197
+ if not columns:
198
+ return True
199
+ from teradataml.common.utils import UtilFuncs
200
+ # Converting columns to a list if string is passed.
201
+ if not isinstance(columns, list):
202
+ columns = [columns]
203
+
204
+ df_columns = UtilFuncs._all_df_columns(column_expression)
205
+
206
+ # Let's validate existence of each column one by one.
207
+ columns_ = []
208
+ for column in columns:
209
+ if isinstance(column, str):
210
+ columns_.append(column)
211
+ else:
212
+ columns_ = columns_ + UtilFuncs._all_df_columns(column)
213
+
214
+ # Let's validate existence of each column one by one.
215
+ for column_name in columns_:
216
+ # If column name does not exist in DataFrame of a column, raise the exception.
217
+ if column_name not in df_columns:
218
+ message = "{}. Check the argument '{}'".format(sorted(df_columns), arg_name)
219
+ raise ValueError(Messages.get_message(MessageCodes.TDMLDF_DROP_INVALID_COL,
220
+ column_name,
221
+ message
222
+ ))
223
+ return True
224
+
225
+ @staticmethod
226
+ @skip_validation()
227
+ def _validate_invalid_column_types(all_columns, column_arg, columns_to_check, invalid_types):
228
+ """
229
+ DESCRIPTION:
230
+ Function to validate the invalid types for "columns_to_check" from "all_columns".
231
+
232
+ PARAMETERS:
233
+ all_columns:
234
+ Required Argument.
235
+ Specifies the ColumnExpressions.
236
+ Types: List of ColumnExpression
237
+
238
+ column_arg:
239
+ Required Argument.
240
+ Specifies the name of the argument.
241
+ Types: str
242
+
243
+ columns_to_check:
244
+ Required Argument.
245
+ Specifies columns to check for invalid types.
246
+ Types: str OR list of str OR ColumnExpression OR list of ColumnExpression
247
+
248
+ invalid_types:
249
+ Required Argument.
250
+ Specifies list of invalid teradata types to check against "columns".
251
+ Types: list
252
+
253
+ RAISES:
254
+ ValueError
255
+
256
+ RETURNS:
257
+ bool
258
+
259
+ EXAMPLES:
260
+ _Validators._validate_invalid_column_types(columns, column_arg, invalid_types)
261
+ """
262
+ columns_and_types = {c.name.lower(): type(c.type) for c in all_columns}
263
+ get_col_type = lambda column: columns_and_types[column.lower()].__name__ if isinstance(
264
+ column, str) else column.type.__class__.__name__
265
+
266
+ invalid_types = ["{}({})".format(column if isinstance(column, str) else column.name, get_col_type(column))
267
+ for column in columns_to_check if get_col_type(column)
268
+ in [t.__name__ for t in _Dtypes._get_sort_unsupported_data_types()]
269
+ ]
270
+
271
+ if invalid_types:
272
+ invalid_column_types = (col_type.__name__ for col_type in
273
+ _Dtypes._get_sort_unsupported_data_types())
274
+ error_message = Messages.get_message(MessageCodes.INVALID_COLUMN_DATATYPE,
275
+ ", ".join(invalid_types),
276
+ column_arg,
277
+ "Unsupported",
278
+ ", ".join(invalid_column_types))
279
+
280
+ raise ValueError(error_message)
281
+
282
+ return True
283
+
284
+ @staticmethod
285
+ @skip_validation()
286
+ def _validate_dataframe_has_argument_columns(columns, column_arg, data, data_arg, is_partition_arg=False):
287
+ """
288
+ Function to check whether column names in columns are present in given dataframe or not.
289
+ This function is used currently only for Analytics wrappers.
290
+
291
+ PARAMETERS:
292
+ columns:
293
+ Required Argument.
294
+ Specifies name or list of names of columns to be validated for existence.
295
+ Types: str or List of strings
296
+
297
+ column_arg:
298
+ Required Argument.
299
+ Specifies the name of the argument.
300
+ Types: str
301
+
302
+ data:
303
+ Required Argument.
304
+ Specifies teradataml DataFrame to check against for column existence.
305
+ Types: teradataml DataFrame
306
+
307
+ data_arg:
308
+ Required Argument.
309
+ Specifies the name of the dataframe argument.
310
+ Types: str
311
+
312
+ isPartitionArg:
313
+ Optional Argument.
314
+ Specifies a bool argument notifying, whether argument being validate is
315
+ Partition argument or not.
316
+ Types: bool
317
+
318
+ RAISES:
319
+ TeradataMlException - TDMLDF_COLUMN_IN_ARG_NOT_FOUND column(s) does not exist in a dataframe.
320
+
321
+ EXAMPLES:
322
+ _Validators._validate_dataframe_has_argument_columns(self.data_sequence_column, "data_sequence_column", self.data, "data")
323
+ _Validators._validate_dataframe_has_argument_columns(self.data_partition_column, "data_sequence_column", self.data, "data", true)
324
+ """
325
+ if is_partition_arg and columns is None:
326
+ return True
327
+
328
+ if columns is None:
329
+ return True
330
+
331
+ _Validators._validate_dependent_argument(column_arg, columns, data_arg, data)
332
+
333
+ # Converting columns to a list if string is passed.
334
+ if not isinstance(columns, list) and columns is not None:
335
+ columns = [columns]
336
+
337
+ total_columns = []
338
+
339
+ for column in columns:
340
+ for separator in TeradataConstants.RANGE_SEPARATORS.value:
341
+ if column is None:
342
+ total_columns.append(column)
343
+ elif column[0] == "-":
344
+ # If column has exclude operator "-".
345
+ # For example incase of "-[50]", let database handle validation.
346
+ if re.match(r'-\[\d+\]', column) is not None:
347
+ continue
348
+ total_columns.append(column[1:])
349
+ elif column.count(separator) == 1:
350
+ # Following cases can occur:
351
+ # '3:5' or 'colA:colE'
352
+ # ':4' or ':columnD' specifies all columns up to and including the column with index 4(or columnD).
353
+ # '4:' or 'columnD:' specifies the column with index 4(or columnD) and all columns after it.
354
+ # ':' specifies all columns in the table.
355
+
356
+ try:
357
+ # Check if its a sinlge column with one separator. For e.g. column:A.
358
+ # If yes, just continue.
359
+ _Validators._validate_column_exists_in_dataframe(column, data._metaexpr)
360
+ continue
361
+ except:
362
+ # User has provided range value.
363
+ column_names = column.split(separator)
364
+ if (len(column_names) == 2 and
365
+ any([column_names[0].isdigit(), column_names[1].isdigit()]) and
366
+ not all([column_names[0].isdigit(), column_names[1].isdigit()]) and
367
+ not "" in column_names):
368
+ # Raises Exception if column range has mixed types. For e.g. "4:XYZ".
369
+ err_msg = Messages.get_message(MessageCodes.MIXED_TYPES_IN_COLUMN_RANGE)
370
+ raise ValueError(err_msg.format(column_arg))
371
+
372
+ for col in column_names:
373
+ if not col.isdigit() and col != "":
374
+ total_columns.append(col)
375
+
376
+ elif column.count(separator) > 1:
377
+ continue
378
+ else:
379
+ total_columns.append(column)
380
+
381
+ return _Validators._validate_column_exists_in_dataframe(total_columns, data._metaexpr, column_arg=column_arg,
382
+ data_arg=data_arg)
383
+
384
+ @staticmethod
385
+ @skip_validation()
386
+ def _validate_column_exists_in_dataframe(columns, metaexpr, case_insensitive=False, column_arg=None,
387
+ data_arg=None, for_table=False):
388
+ """
389
+ Method to check whether column or list of columns exists in a teradataml DataFrame or not.
390
+
391
+ PARAMETERS:
392
+ columns:
393
+ Required Argument.
394
+ Specifies name or list of names of columns to be validated for existence.
395
+ Types: str or List of strings
396
+
397
+ metaexpr:
398
+ Required Argument.
399
+ Specifies a teradataml DataFrame metaexpr to be validated against.
400
+ Types: MetaExpression
401
+
402
+ case_insensitive:
403
+ Optional Argument.
404
+ Specifies a flag, that determines whether to check for column existence in
405
+ case_insensitive manner or not.
406
+ Default Value: False (Case-Sensitive lookup)
407
+ Types: bool
408
+
409
+ column_arg:
410
+ Optional Argument.
411
+ Specifies the name of the argument.
412
+ Types: str
413
+
414
+ data_arg:
415
+ Optional Argument.
416
+ Specifies the name of the dataframe argument or name of the table.
417
+ Types: str
418
+
419
+ for_table:
420
+ Optional Argument.
421
+ Specifies whether error should be raised against table or DataFrame, i.e.,
422
+ when columns are not available and "for_table" is set to False, then
423
+ exception message mentions column(s) not available in DataFrame. When
424
+ columns are not available and "for_table" is set to true, then exception
425
+ message mentions column(s) not available in Table.
426
+ Types: str
427
+
428
+ RAISES:
429
+ ValueError
430
+ TDMLDF_DROP_INVALID_COL - If columns not found in metaexpr.
431
+
432
+ RETURNS:
433
+ None
434
+
435
+ EXAMPLES:
436
+ _Validators._validate_column_exists_in_dataframe(["col1", "col2"], self.metaexpr)
437
+
438
+ """
439
+ if columns is None:
440
+ return True
441
+
442
+ # If just a column name is passed, convert it to a list.
443
+ if isinstance(columns, str):
444
+ columns = [columns]
445
+
446
+ # Constructing New unquotted column names for selected columns ONLY using Parent _metaexpr
447
+ if case_insensitive:
448
+ # If lookup has to be a case insensitive then convert the
449
+ # metaexpr columns name to lower case.
450
+ unquoted_df_columns = [c.name.replace('"', "").lower() for c in metaexpr.c]
451
+ else:
452
+ unquoted_df_columns = [c.name.replace('"', "") for c in metaexpr.c]
453
+
454
+ # Let's validate existence of each column one by one.
455
+ for column_name in columns:
456
+ if column_name is None:
457
+ column_name = str(column_name)
458
+
459
+ if case_insensitive:
460
+ # If lookup has to be a case insensitive then convert the
461
+ # column name to lower case.
462
+ column_name = column_name.lower()
463
+
464
+ # If column name does not exist in metaexpr, raise the exception
465
+ if not column_name.replace('"', "") in unquoted_df_columns:
466
+ if column_arg and data_arg:
467
+ raise ValueError(Messages.get_message(MessageCodes.TDMLDF_COLUMN_IN_ARG_NOT_FOUND,
468
+ column_name,
469
+ column_arg,
470
+ data_arg,
471
+ "Table" if for_table else "DataFrame"))
472
+ else:
473
+ raise ValueError(Messages.get_message(MessageCodes.TDMLDF_DROP_INVALID_COL,
474
+ column_name, sorted(unquoted_df_columns)))
475
+
476
+ return True
477
+
478
+ @staticmethod
479
+ @skip_validation()
480
+ def _validate_engine(engine):
481
+ """
482
+ Function to validate whether the argument engine is supported or not.
483
+
484
+ PARAMETERS:
485
+ engine:
486
+ Required Argument.
487
+ Specifies the type of the engine.
488
+
489
+ RETURNS:
490
+ True, if engine is supported.
491
+
492
+ RAISES:
493
+ TeradataMLException
494
+
495
+ EXAMPLES:
496
+ _Validators._validate_engine("ENGINE_SQL")
497
+ """
498
+ supported_engines = TeradataConstants.SUPPORTED_ENGINES.value
499
+ if engine not in supported_engines.keys():
500
+ raise TeradataMlException(Messages.get_message(
501
+ MessageCodes.CONFIG_ALIAS_ENGINE_NOT_SUPPORTED).format(engine,
502
+ ", ".join(supported_engines.keys())),
503
+ MessageCodes.CONFIG_ALIAS_ENGINE_NOT_SUPPORTED)
504
+
505
+ return True
506
+
507
+ @staticmethod
508
+ @skip_validation()
509
+ def _validate_function_arguments(arg_list, skip_empty_check = None):
510
+ """
511
+ Method to verify that the input arguments are of valid data type except for
512
+ argument of DataFrameType.
513
+
514
+ PARAMETERS:
515
+ arg_list:
516
+ Required Argument.
517
+ Specifies a list of arguments, expected types are mentioned as type or tuple.
518
+ argInfoMatrix = []
519
+ argInfoMatrix.append(["data", data, False, (DataFrame)])
520
+ argInfoMatrix.append(["centers", centers, True, (int, list)])
521
+ argInfoMatrix.append(["threshold", threshold, True, (float)])
522
+ Types: List of Lists
523
+ skip_empty_check:
524
+ Optional Argument.
525
+ Specifies column name and values for which to skip check.
526
+ Types: Dictionary specifying column name to values mapping.
527
+
528
+ RAISES:
529
+ Error if arguments are not of valid datatype
530
+
531
+ EXAMPLES:
532
+ _Validators._validate_function_arguments(arg_list)
533
+ """
534
+ invalid_arg_names = []
535
+ invalid_arg_types = []
536
+
537
+ typeCheckFailed = False
538
+
539
+ for args in arg_list:
540
+ num_args = len(args)
541
+ if not isinstance(args[0], str):
542
+ raise TypeError("First element in argument information matrix should be str.")
543
+
544
+ if not isinstance(args[2], bool):
545
+ raise TypeError("Third element in argument information matrix should be bool.")
546
+
547
+ if not (isinstance(args[3], tuple) or isinstance(args[3], type) or
548
+ isinstance(args[3], (_ListOf, _TupleOf))):
549
+ err_msg = "Fourth element in argument information matrix should be a 'tuple of types' or 'type' type."
550
+ raise TypeError(err_msg)
551
+
552
+ if num_args >= 5:
553
+ if not isinstance(args[4], bool):
554
+ raise TypeError("Fifth element in argument information matrix should be bool.")
555
+
556
+ #
557
+ # Let's validate argument types.
558
+ #
559
+ # Verify datatypes for arguments which are required or the optional arguments are not None
560
+ if ((args[2] == True and args[1] is not None) or (args[2] == False)):
561
+ # Validate the types of argument, if expected types are instance of tuple or type
562
+ dtype_list = _Validators.__getTypeAsStr(args[3])
563
+
564
+ if isinstance(args[3], tuple) and list in args[3]:
565
+ # If list of data types contain 'list', which means argument can accept list of values.
566
+ dtype_list.remove('list')
567
+ valid_types_str = ", ".join(dtype_list) + " or list of values of type(s): " + ", ".join(
568
+ dtype_list)
569
+
570
+ if isinstance(args[1], list):
571
+ # If argument contains list of values, check each value.
572
+ for value in args[1]:
573
+ # If not valid datatype add invalid_arg to dictionary and break
574
+ if not _Validators._check_isinstance(value, args[3]):
575
+ invalid_arg_names.append(args[0])
576
+ invalid_arg_types.append(valid_types_str)
577
+ typeCheckFailed = True
578
+ break
579
+ elif not _Validators._check_isinstance(args[1], args[3]):
580
+ # Argument is not of type list.
581
+ invalid_arg_names.append(args[0])
582
+ invalid_arg_types.append(valid_types_str)
583
+ typeCheckFailed = True
584
+
585
+ elif isinstance(args[3], tuple):
586
+ # Argument can accept values of multiple types, but not list.
587
+ valid_types_str = " or ".join(dtype_list)
588
+ if not _Validators._check_isinstance(args[1], args[3]):
589
+ invalid_arg_names.append(args[0])
590
+ invalid_arg_types.append(valid_types_str)
591
+ typeCheckFailed = True
592
+ else:
593
+ # Argument can accept values of single type.
594
+ valid_types_str = " or ".join(dtype_list)
595
+ if not _Validators._check_isinstance(args[1], args[3]):
596
+ invalid_arg_names.append(args[0])
597
+ invalid_arg_types.append(valid_types_str)
598
+ typeCheckFailed = True
599
+
600
+ #
601
+ # Validate the arguments for empty value
602
+ #
603
+ if not typeCheckFailed and len(args) >= 5:
604
+ if args[4]:
605
+ _Validators._validate_input_columns_not_empty(args[1], args[0], skip_empty_check)
606
+
607
+ #
608
+ # Validate the arguments for permitted values
609
+ #
610
+ if not typeCheckFailed and len(args) >= 6:
611
+ if args[5] is not None:
612
+ _Validators._validate_permitted_values(args[1], args[5], args[0], supported_types=args[3])
613
+
614
+ if typeCheckFailed:
615
+ if len(invalid_arg_names) != 0:
616
+ raise TypeError(Messages.get_message(MessageCodes.UNSUPPORTED_DATATYPE,
617
+ invalid_arg_names, invalid_arg_types))
618
+
619
+ return True
620
+
621
+ @staticmethod
622
+ @skip_validation()
623
+ def _validate_input_columns_not_empty(arg, arg_name, skip_empty_check = None):
624
+ """
625
+ Function to check whether argument is empty string or not.
626
+
627
+ PARAMETERS:
628
+ arg:
629
+ Required Argument.
630
+ Argument value (string) to be checked whether it is empty or not.
631
+ skip_empty_check:
632
+ Optional Argument.
633
+ Specifies column name and values for which to skip check.
634
+ Types: Dictionary specifying column name to values mapping.
635
+ Example: When '\n', '\t' are valid values for argument 'arg_name', this check should be skipped.
636
+
637
+ RAISES:
638
+ Error if argument contains empty string
639
+
640
+ EXAMPLES:
641
+ _Validators._validate_input_columns_not_empty(arg)
642
+ """
643
+ if isinstance(arg, str):
644
+ if not (skip_empty_check and arg_name in skip_empty_check.keys() and arg in skip_empty_check[arg_name]):
645
+ if ((len(arg.strip()) == 0)):
646
+ raise ValueError(Messages.get_message(MessageCodes.ARG_EMPTY, arg_name))
647
+
648
+ if isinstance(arg, list):
649
+ if len(arg) == 0:
650
+ raise ValueError(Messages.get_message(MessageCodes.ARG_EMPTY, arg_name).replace("empty string", "an empty list"))
651
+
652
+ for col in arg:
653
+ if not (skip_empty_check and arg_name in skip_empty_check.keys() and col in skip_empty_check[arg_name]):
654
+ if isinstance(col, str):
655
+ if (not (col is None) and ((len(col.strip()) == 0))):
656
+ raise ValueError(Messages.get_message(MessageCodes.ARG_EMPTY, arg_name))
657
+ return True
658
+
659
+ @staticmethod
660
+ @skip_validation()
661
+ def _validate_missing_required_arguments(arg_list):
662
+ """
663
+ Method to check whether the required arguments passed to the function are missing
664
+ or not. Only wrapper's use this function.
665
+
666
+ PARAMETERS:
667
+ arg_list - A list
668
+ The argument is expected to be a list of arguments
669
+
670
+ RAISES:
671
+ If any arguments are missing exception raised with missing arguments which are
672
+ required.
673
+
674
+ EXAMPLES:
675
+ An example input matrix will be:
676
+ arg_info_matrix = []
677
+ arg_info_matrix.append(["data", data, False, DataFrame])
678
+ arg_info_matrix.append(["centers", centers, True, int])
679
+ arg_info_matrix.append(["threshold", threshold, True, "float"])
680
+ awu = AnalyticsWrapperUtils()
681
+ awu._validate_missing_required_arguments(arg_info_matrix)
682
+ """
683
+ miss_args = []
684
+ for args in arg_list:
685
+ '''
686
+ Check for missing arguments which are required. If args[2] is false
687
+ the argument is required.
688
+ The following conditions are true :
689
+ 1. The argument should not be None and an empty string.
690
+ then argument is required which is missing and Raises exception.
691
+ '''
692
+ if args[2] == False and args[1] is None:
693
+ miss_args.append(args[0])
694
+
695
+ if (len(miss_args)>0):
696
+ raise TeradataMlException(Messages.get_message(MessageCodes.MISSING_ARGS,miss_args),
697
+ MessageCodes.MISSING_ARGS)
698
+ return True
699
+
700
+ @staticmethod
701
+ @skip_validation()
702
+ def _validate_permitted_values(arg, permitted_values, arg_name, case_insensitive=True, includeNone=True, supported_types=None):
703
+ """
704
+ Function to check the permitted values for the argument.
705
+
706
+ PARAMETERS:
707
+ arg:
708
+ Required Argument.
709
+ Argument value to be checked against permitted values from the list.
710
+ Types: string
711
+
712
+ permitted_values:
713
+ Required Argument.
714
+ A list of strings/ints/floats containing permitted values for the argument.
715
+ Types: string
716
+
717
+ arg_name:
718
+ Required Argument.
719
+ Name of the argument to be printed in the error message.
720
+ Types: string
721
+
722
+ case_insensitive:
723
+ Optional Argument.
724
+ Specifies whether values in permitted_values could be case sensitive.
725
+ Types: bool
726
+
727
+ includeNone:
728
+ Optional Argument.
729
+ Specifies whether 'None' can be included as valid value.
730
+ Types: bool
731
+
732
+ supported_types:
733
+ Optional Argument.
734
+ Specifies the supported datatypes for the argument.
735
+ Types: str
736
+
737
+ RAISES:
738
+ Error if argument is not present in the list
739
+
740
+ EXAMPLES:
741
+ permitted_values = ["LOGISTIC", "BINOMIAL", "POISSON", "GAUSSIAN", "GAMMA", "INVERSE_GAUSSIAN", "NEGATIVE_BINOMIAL"]
742
+ arg = "LOGISTIC"
743
+ _Validators._validate_permitted_values(arg, permitted_values, argument_name)
744
+ """
745
+ # validating permitted_values type which has to be a list.
746
+ _Validators._validate_function_arguments([["permitted_values", permitted_values, False, (list)]])
747
+
748
+ if case_insensitive:
749
+ permitted_values = [item.upper() if isinstance(item, str) else item for item in permitted_values]
750
+
751
+ # Validate whether argument has value from permitted values list or not.
752
+ if not isinstance(arg, list) and arg is not None:
753
+ arg = [arg]
754
+
755
+ if arg is not None:
756
+ # Getting arguments in uppercase to compare with 'permitted_values'
757
+ arg_upper = []
758
+ for element in arg:
759
+ if element is None:
760
+ # If element is None, then we shall add a string "None"
761
+ if includeNone:
762
+ continue
763
+ arg_upper.append(str(element))
764
+ elif isinstance(element, str):
765
+ # If element is of type str, then we will convert it to upper case.
766
+ if case_insensitive:
767
+ arg_upper.append(element.upper())
768
+ else:
769
+ arg_upper.append(element)
770
+ else:
771
+ # For any other type of element, we will keep it as is.
772
+ arg_upper.append(element)
773
+
774
+ # Form the list of datatypes not present in the datatypes of permitted_values.
775
+ add_types = ()
776
+ if supported_types is not None:
777
+ # Convert type and tuple to list.
778
+ supported_types = [supported_types] if isinstance(supported_types, type) else supported_types
779
+ # Form a list for types which are not there in type of permitted_values.
780
+ add_types = tuple(set(list(supported_types)) - set(list(map(type, permitted_values))) - set([list]))
781
+ # Remove the arguments from arg_upper which are an instance of the add_types.
782
+ if len(add_types) > 0:
783
+ [arg_upper.remove(arg) for arg in arg_upper if isinstance(arg, add_types)]
784
+
785
+ # If any of the arguments in 'arg_upper' not in 'permitted_values',
786
+ # then, raise exception
787
+ upper_invalid_values = list(set(arg_upper).difference(set(permitted_values)))
788
+
789
+ if len(upper_invalid_values) > 0:
790
+ # Getting actual invalid arguments (non-upper)
791
+ invalid_values = []
792
+ for element in arg:
793
+ if element is None:
794
+ if includeNone:
795
+ continue
796
+ invalid_values.append(str(element))
797
+ elif isinstance(element, str) and element.upper() in upper_invalid_values:
798
+ invalid_values.append(element)
799
+ elif element in upper_invalid_values:
800
+ invalid_values.append(element)
801
+ invalid_values.sort()
802
+
803
+ # Concatenate the message for datatypes not present in datatypes of permitted_values.
804
+ if len(add_types) > 0 :
805
+ add_types = _Validators.__getTypeAsStr(add_types)
806
+ add_types = " or ".join(add_types)
807
+ permitted_values = "{} {}".format(permitted_values, "or any values of type {}".format(add_types))
808
+
809
+ raise ValueError(
810
+ Messages.get_message(MessageCodes.INVALID_ARG_VALUE,
811
+ ', '.join([str(item) if not isinstance(item, str) else item for item in invalid_values]),
812
+ arg_name, permitted_values))
813
+ # If any of the arguments doesn't want to include None as valid value
814
+ # then, raise exception.
815
+ else:
816
+ if not includeNone:
817
+ raise ValueError(
818
+ Messages.get_message(MessageCodes.INVALID_ARG_VALUE, None,
819
+ arg_name, permitted_values), MessageCodes.INVALID_ARG_VALUE)
820
+ # Returns True when arg is None or there is no Exception
821
+ return True
822
+
823
+ @staticmethod
824
+ @skip_validation()
825
+ def _validate_positive_int(arg, arg_name, lbound=0, ubound=None, lbound_inclusive=False):
826
+ """
827
+ Validation to check arg values is a positive int.
828
+
829
+ PARAMETERS:
830
+ arg:
831
+ Required Argument.
832
+ Specifies the number to be validated for positive INT.
833
+ Types: int
834
+
835
+ arg_name:
836
+ Required Argument.
837
+ Specifies the name of the argument to be printed in error message.
838
+ Types: str
839
+
840
+ lbound:
841
+ Optional Argument.
842
+ Specifies the lower bound value for arg.
843
+ Note: Value provided to this argument is exclusive, i.e., if value provided
844
+ to this argument 10, then error will be raised for any value of arg <= 10.
845
+ It can be made inclusive, if lbound_inclusive is set to 'True'.
846
+ Types: int
847
+
848
+ ubound:
849
+ Optional Argument.
850
+ Specifies the upper bound value for arg.
851
+ Note: Value provided to this argument is inclusive, i.e., if value provided
852
+ to this argument 10, then error will be raised for any value of arg > 10.
853
+ Types: int
854
+
855
+ lbound_inclusive:
856
+ Optional Argument.
857
+ Specifies a boolean flag telling API whether to lbound value is inclusive or not.
858
+ Types: bool
859
+
860
+ RAISES:
861
+ ValueError - If arg is not a positive int.
862
+
863
+ RETURNS:
864
+ True - If success
865
+
866
+ EXAMPLES:
867
+ # Validate n for value > 0
868
+ _Validators._validate_positive_int(n, "n")
869
+ # Validate n for value > 0 and value <= 32767
870
+ _Validators._validate_positive_int(n, "n", ubound="32767")
871
+ """
872
+ if arg is None:
873
+ return True
874
+
875
+ if ubound is None:
876
+ if lbound_inclusive:
877
+ if not isinstance(arg, numbers.Integral) or arg < lbound:
878
+ raise ValueError(Messages.get_message(MessageCodes.TDMLDF_POSITIVE_INT).format(arg_name, "greater than or equal to"))
879
+ else:
880
+ if not isinstance(arg, numbers.Integral) or arg <= lbound:
881
+ raise ValueError(Messages.get_message(MessageCodes.TDMLDF_POSITIVE_INT).format(arg_name, "greater than"))
882
+ else:
883
+ if not isinstance(arg, numbers.Integral) or arg <= lbound or arg > ubound:
884
+ raise ValueError(Messages.get_message(MessageCodes.TDMLDF_LBOUND_UBOUND).format(
885
+ arg_name, "greater than {}".format(lbound),
886
+ " and less than or equal to {}".format(ubound)))
887
+
888
+ return True
889
+
890
+ @staticmethod
891
+ @skip_validation()
892
+ def _validate_argument_range(arg,
893
+ arg_name,
894
+ lbound=None,
895
+ ubound=None,
896
+ lbound_inclusive=False,
897
+ ubound_inclusive=False):
898
+ """
899
+ DESCRIPTION:
900
+ Validation to check arg is in specified range.
901
+
902
+ PARAMETERS:
903
+ arg:
904
+ Required Argument.
905
+ Specifies the number to be validated for range check.
906
+ Types: int
907
+
908
+ arg_name:
909
+ Required Argument.
910
+ Specifies the name of the argument to be printed in error message.
911
+ Types: str
912
+
913
+ lbound:
914
+ Optional Argument.
915
+ Specifies the lower bound value for arg.
916
+ Note:
917
+ Value provided to this argument is exclusive, i.e., if
918
+ value provided to this argument 10, then error will be
919
+ raised for any value of arg < 10. It can be made inclusive,
920
+ if lbound_inclusive is set to 'True'.
921
+ Types: int OR float
922
+
923
+ ubound:
924
+ Optional Argument.
925
+ Specifies the upper bound value for arg.
926
+ Note:
927
+ Value provided to this argument is exclusive, i.e., if
928
+ value provided to this argument 10, then error will be
929
+ raised for any value of arg > 10. It can be made inclusive,
930
+ if ubound_inclusive is set to 'True'.
931
+ Types: int OR float
932
+
933
+ lbound_inclusive:
934
+ Optional Argument.
935
+ Specifies whether lbound value is inclusive or not. When set to True,
936
+ value is inclusive, otherwise exclusive.
937
+ Default Value: False
938
+ Types: bool
939
+
940
+ ubound_inclusive:
941
+ Optional Argument.
942
+ Specifies whether ubound value is inclusive or not. When set to True,
943
+ value is inclusive, otherwise exclusive.
944
+ Default Value: False
945
+ Types: bool
946
+
947
+ RAISES:
948
+ ValueError - If arg is not in the specified range.
949
+
950
+ RETURNS:
951
+ True - If success
952
+
953
+ EXAMPLES:
954
+ # Validate n for value in between of 10 and 20.
955
+ _Validators._validate_argument_range(n, 10, 20)
956
+ """
957
+ if lbound is None and ubound is None:
958
+ return True
959
+
960
+ # Raise error if lower bound is greater than upper bound.
961
+ if lbound is not None and ubound is not None and (lbound > ubound):
962
+ raise ValueError("Lowerbound value '{}' must be less than upperbound value '{}'.".format(lbound, ubound))
963
+
964
+ # If argument is None, do not validate the argument.
965
+ if arg is None:
966
+ return True
967
+
968
+ is_arg_in_lower_bound, is_arg_in_upper_bound = True, True
969
+ lbound_msg, ubound_msg = "", ""
970
+
971
+ # Check for lower bound.
972
+ if lbound is not None:
973
+ if lbound_inclusive:
974
+ is_arg_in_lower_bound = arg >= lbound
975
+ lbound_msg = "greater than or equal to {}".format(lbound)
976
+ else:
977
+ is_arg_in_lower_bound = arg > lbound
978
+ lbound_msg = "greater than {}".format(lbound)
979
+
980
+ # Check for upper bound.
981
+ if ubound is not None:
982
+ if ubound_inclusive:
983
+ is_arg_in_upper_bound = arg <= ubound
984
+ ubound_msg = "less than or equal to {}".format(ubound)
985
+ else:
986
+ is_arg_in_upper_bound = arg < ubound
987
+ ubound_msg = "less than {}".format(ubound)
988
+
989
+ if not (is_arg_in_lower_bound and is_arg_in_upper_bound):
990
+ # If both lower bound and upper bound error messages available, append 'and' to
991
+ # upper bound message.
992
+ if lbound_msg and ubound_msg:
993
+ ubound_msg = " and {}".format(ubound_msg)
994
+ raise ValueError(
995
+ Messages.get_message(MessageCodes.TDMLDF_LBOUND_UBOUND).format(arg_name, lbound_msg, ubound_msg))
996
+
997
+ return True
998
+
999
+ @staticmethod
1000
+ @skip_validation()
1001
+ def _validate_vantage_version(vantage_version):
1002
+ """
1003
+ Function to verify whether the given vantage_version is
1004
+ supported or not.
1005
+
1006
+ PARAMETERS:
1007
+ vantage_version:
1008
+ Required Argument.
1009
+ Specifies the vantage version.
1010
+
1011
+ RETURNS:
1012
+ True, if the current vantage version is supported or not.
1013
+
1014
+ RAISES:
1015
+ TeradataMLException
1016
+
1017
+ EXAMPLES:
1018
+ _Validators._validate_vantage_version("vantage1.0")
1019
+ """
1020
+ supported_vantage_versions = TeradataConstants.SUPPORTED_VANTAGE_VERSIONS.value
1021
+
1022
+ # Raise exception if the vantage version is not supported.
1023
+ if vantage_version not in supported_vantage_versions.keys():
1024
+ err_ = Messages.get_message(MessageCodes.CONFIG_ALIAS_VANTAGE_VERSION_NOT_SUPPORTED). \
1025
+ format(vantage_version, ", ".join(supported_vantage_versions.keys()))
1026
+ raise TeradataMlException(err_,
1027
+ MessageCodes.CONFIG_ALIAS_VANTAGE_VERSION_NOT_SUPPORTED)
1028
+
1029
+ return True
1030
+
1031
+ @staticmethod
1032
+ @skip_validation()
1033
+ def _validate_timebucket_duration(timebucket_duration, timebucket_duration_arg_name='timebucket_duration'):
1034
+ """
1035
+ Internal function to validate timeduration_bucket specified when creating a
1036
+ Primary Time Index (PTI) table.
1037
+
1038
+ PARAMETERS:
1039
+ timebucket_duration:
1040
+ Specifies the timebucket_duration passed to a function().
1041
+ Types: str
1042
+
1043
+ timebucket_duration_arg_name:
1044
+ Specifies the name of the argument to be displayed in the error message.
1045
+ Types: str
1046
+
1047
+ RETURNS:
1048
+ True if the value is valid.
1049
+
1050
+ RAISES:
1051
+ ValueError or TeradataMlException when the value is invalid.
1052
+
1053
+ EXAMPLES:
1054
+ _Validators._validate_timebucket_duration('HOURS(2)')
1055
+ _Validators._validate_timebucket_duration('2hours')
1056
+ _Validators._validate_timebucket_duration('ayear') # Invalid
1057
+ """
1058
+ # Return True is it is not specified or is None since it is optional
1059
+ if timebucket_duration is None:
1060
+ return True
1061
+
1062
+ # Check if notation if formal or shorthand (beginning with a digit)
1063
+ if timebucket_duration[0].isdigit():
1064
+ valid_timebucket_durations = PTITableConstants.VALID_TIMEBUCKET_DURATIONS_SHORTHAND.value
1065
+ pattern_to_use = PTITableConstants.PATTERN_TIMEBUCKET_DURATION_SHORT.value
1066
+ normalized_timebucket_duration = timebucket_duration.lower()
1067
+ else:
1068
+ valid_timebucket_durations = PTITableConstants.VALID_TIMEBUCKET_DURATIONS_FORMAL.value
1069
+ pattern_to_use = PTITableConstants.PATTERN_TIMEBUCKET_DURATION_FORMAL.value
1070
+ normalized_timebucket_duration = timebucket_duration.upper()
1071
+
1072
+ for timebucket_duration_notation in valid_timebucket_durations:
1073
+ pattern = re.compile(pattern_to_use.format(timebucket_duration_notation))
1074
+ match = pattern.match(normalized_timebucket_duration)
1075
+ if match is not None:
1076
+ n = int(match.group(1))
1077
+ _Validators._validate_positive_int(n, "n", ubound=32767)
1078
+
1079
+ # Looks like the value is valid
1080
+ return True
1081
+
1082
+ # Match not found
1083
+ raise ValueError(Messages.get_message(
1084
+ MessageCodes.INVALID_ARG_VALUE).format(timebucket_duration, timebucket_duration_arg_name,
1085
+ 'a valid time unit of format time_unit(n) or it\'s short hand '
1086
+ 'equivalent notation'))
1087
+
1088
+ @staticmethod
1089
+ @skip_validation()
1090
+ def _validate_column_type(df, col, col_arg, expected_types, raiseError = True):
1091
+ """
1092
+ Internal function to validate the type of an input DataFrame column against
1093
+ a list of expected types.
1094
+
1095
+ PARAMETERS
1096
+ df:
1097
+ Required Argument.
1098
+ Specifies the input teradataml DataFrame which has the column to be tested
1099
+ for type.
1100
+ Types: teradataml DataFrame
1101
+
1102
+ col:
1103
+ Required Argument.
1104
+ Specifies the column in the input DataFrame to be tested for type.
1105
+ Types: str
1106
+
1107
+ col_arg:
1108
+ Required Argument.
1109
+ Specifies the name of the argument used to pass the column name.
1110
+ Types: str
1111
+
1112
+ expected_types:
1113
+ Required Argument.
1114
+ Specifies a list of teradatasqlachemy datatypes that the column is
1115
+ expected to be of type.
1116
+ Types: list of teradatasqlalchemy types
1117
+
1118
+ raiseError:
1119
+ Optional Argument.
1120
+ Specifies a boolean flag that decides whether to raise error or just return True or False.
1121
+ Default Values: True, raise exception if column is not of desired type.
1122
+ Types: bool
1123
+
1124
+ RETURNS:
1125
+ True, when the columns is of an expected type.
1126
+
1127
+ RAISES:
1128
+ TeradataMlException, when the columns is not one of the expected types.
1129
+
1130
+ EXAMPLES:
1131
+ _Validators._validate_column_type(df, timecode_column, 'timecode_column', PTITableConstants.VALID_TIMECODE_DATATYPES)
1132
+ """
1133
+ if not any(isinstance(df[col].type, t) for t in expected_types):
1134
+ if raiseError:
1135
+ raise TeradataMlException(Messages.get_message(MessageCodes.INVALID_COLUMN_TYPE).
1136
+ format(col_arg, df[col].type, ' or '.join(expected_type.__visit_name__
1137
+ for expected_type in expected_types)),
1138
+ MessageCodes.INVALID_COLUMN_TYPE)
1139
+ else:
1140
+ return False
1141
+
1142
+ return True
1143
+
1144
+ @staticmethod
1145
+ @skip_validation()
1146
+ def _validate_aggr_operation_unsupported_datatype(operation, columns, td_column_names_and_types):
1147
+ """
1148
+ Internal function to validate the for unsupported data types of an input DataFrame column for
1149
+ an aggreagate function.
1150
+
1151
+ PARAMETERS
1152
+ operation:
1153
+ Required Argument.
1154
+ Specifies the name of the aggregate operation.
1155
+ Types: str
1156
+
1157
+ columns:
1158
+ Required Argument.
1159
+ Specifies the column names to be validated for datatype check.
1160
+ Types: str
1161
+
1162
+ td_column_names_and_types:
1163
+ Required Argument.
1164
+ Specifies the input teradataml DataFrames column name to SQLAlchemy type mapper.
1165
+ Types: str
1166
+
1167
+ RETURNS:
1168
+ None
1169
+
1170
+ RAISES:
1171
+ TeradataMlException, when the columns is not one of the expected types.
1172
+
1173
+ EXAMPLES:
1174
+ _Validators._validate_aggr_operation_unsupported_datatype(operation, columns, td_column_names_and_types):
1175
+ """
1176
+ # Check if the user provided columns has unsupported datatype for aggregate operation or not.
1177
+ # Get the list of unsupported types for aggregate function.
1178
+ unsupported_types = _Dtypes._get_unsupported_data_types_for_aggregate_operations(operation)
1179
+ invalid_columns = []
1180
+
1181
+ for column in columns:
1182
+ if isinstance(td_column_names_and_types[column.lower()], tuple(unsupported_types)):
1183
+ invalid_columns.append(
1184
+ "({0} - {1})".format(column, td_column_names_and_types[column.lower()]))
1185
+
1186
+ if len(invalid_columns) > 0:
1187
+ invalid_columns.sort() # helps in catching the columns in
1188
+ # lexicographic order
1189
+ error = MessageCodes.TDMLDF_AGGREGATE_UNSUPPORTED.value.format(
1190
+ ", ".join(invalid_columns), operation)
1191
+ msg = Messages.get_message(MessageCodes.TDMLDF_AGGREGATE_COMBINED_ERR). \
1192
+ format(error)
1193
+ raise TeradataMlException(msg, MessageCodes.TDMLDF_AGGREGATE_COMBINED_ERR)
1194
+
1195
+ @staticmethod
1196
+ @skip_validation()
1197
+ def _validate_str_arg_length(arg_name, arg_value, op, length):
1198
+ """
1199
+ Internal function to validate the length of a string passed as an argument.
1200
+
1201
+ PARAMETERS
1202
+ arg_name:
1203
+ Required Argument.
1204
+ Specifies the name of the argument for which we need to validate the value length.
1205
+ Types: str
1206
+
1207
+ arg_value:
1208
+ Required Argument.
1209
+ Specifies the value passed to the argument.
1210
+ Types: str
1211
+
1212
+ op:
1213
+ Required Argument.
1214
+ Specifies the type of check, and can be one of:
1215
+ * LT - Less than
1216
+ * LE - less than or equal to
1217
+ * GT - greater than
1218
+ * GE - greater than or equal to
1219
+ * EQ - equal to
1220
+ * NE - not equal to
1221
+ Types: str
1222
+ Permitted Values: ['LT', 'LE', 'GT', 'GE', 'EQ', 'NE']
1223
+
1224
+ length:
1225
+ Required Argument.
1226
+ Specifies the length against which the 'op' check for the argument value length will be made.
1227
+ Types: int
1228
+
1229
+ RETURNS:
1230
+ None
1231
+
1232
+ RAISES:
1233
+ ValueError.
1234
+
1235
+ EXAMPLES:
1236
+ _Validators._validate_str_arg_length("name", "The value", 10):
1237
+ """
1238
+ return _Validators._validate_arg_length(arg_name=arg_name, arg_value=arg_value, op=op, length=length)
1239
+
1240
+ @staticmethod
1241
+ @skip_validation()
1242
+ def _validate_arg_length(arg_name, arg_value, op, length):
1243
+ """
1244
+ Internal function to validate the length of an argument.
1245
+
1246
+ PARAMETERS
1247
+ arg_name:
1248
+ Required Argument.
1249
+ Specifies the name of the argument for which we need to validate the value length.
1250
+ Types: str
1251
+
1252
+ arg_value:
1253
+ Required Argument.
1254
+ Specifies the value passed to the argument.
1255
+ Types: str or list or tuple or set or dict
1256
+
1257
+ op:
1258
+ Required Argument.
1259
+ Specifies the type of check, and can be one of:
1260
+ * LT - Less than
1261
+ * LE - less than or equal to
1262
+ * GT - greater than
1263
+ * GE - greater than or equal to
1264
+ * EQ - equal to
1265
+ * NE - not equal to
1266
+ Types: str
1267
+ Permitted Values: ['LT', 'LE', 'GT', 'GE', 'EQ', 'NE']
1268
+
1269
+ length:
1270
+ Required Argument.
1271
+ Specifies the length against which the 'op' check for the argument value length will be made.
1272
+ Types: int
1273
+
1274
+ RETURNS:
1275
+ None
1276
+
1277
+ RAISES:
1278
+ ValueError.
1279
+
1280
+ EXAMPLES:
1281
+ _Validators._validate_arg_length("name", [1, 2, 3], 3):
1282
+ """
1283
+ # Check if the length of the string value for the argument is acceptable.
1284
+ # First, check if op is an acceptable operation.
1285
+ acceptable_op = {'LT': int.__lt__,
1286
+ 'LE': int.__le__,
1287
+ 'GT': int.__gt__,
1288
+ 'GE': int.__ge__,
1289
+ 'EQ': int.__eq__,
1290
+ 'NE': int.__ne__
1291
+ }
1292
+ if op not in acceptable_op:
1293
+ raise ValueError(Messages.get_message(MessageCodes.INVALID_ARG_VALUE,
1294
+ op, "op", acceptable_op))
1295
+
1296
+ # Format the error message with the substring based on the op type.
1297
+ errors = {'LT': "less than {}",
1298
+ 'LE': "less than or equal to {}",
1299
+ 'GT': "greater than {}",
1300
+ 'GE': "greater than or equal to {}",
1301
+ 'EQ': "equal to {}",
1302
+ 'NE': "not equal to {}"
1303
+ }
1304
+ if not acceptable_op[op](len(arg_value), length):
1305
+ if isinstance(arg_value, str):
1306
+ raise ValueError(Messages.get_message(MessageCodes.INVALID_LENGTH_STRING_ARG,
1307
+ arg_name, errors[op].format(length)))
1308
+ raise ValueError(Messages.get_message(MessageCodes.INVALID_LENGTH_ARG, type(arg_value).__name__,
1309
+ arg_name, errors[op].format(length)))
1310
+ return True
1311
+
1312
+ @staticmethod
1313
+ @skip_validation()
1314
+ def _validate_file_exists(file_path):
1315
+ """
1316
+ DESCRIPTION:
1317
+ Function to validate whether the path specified is a file and if it exists.
1318
+
1319
+ PARAMETERS:
1320
+ file_path:
1321
+ Required Argument.
1322
+ Specifies the path of the file.
1323
+ Types: str
1324
+
1325
+ RETURNS:
1326
+ True, if the path is a file and it exists.
1327
+
1328
+ RAISES:
1329
+ TeradataMLException
1330
+
1331
+ EXAMPLES:
1332
+ _Validators._validate_file_exists("/data/mapper.py")
1333
+ """
1334
+ if not Path(file_path).exists() or not os.path.isfile(file_path):
1335
+ raise TeradataMlException(
1336
+ Messages.get_message(MessageCodes.INPUT_FILE_NOT_FOUND).format(file_path),
1337
+ MessageCodes.INPUT_FILE_NOT_FOUND)
1338
+
1339
+ return True
1340
+
1341
+ @staticmethod
1342
+ @skip_validation()
1343
+ def _validate_mutually_exclusive_arguments(arg1, err_disp_arg1_name, arg2,
1344
+ err_disp_arg2_name, skip_all_none_check=False):
1345
+ """
1346
+ DESCRIPTION:
1347
+ Function to validate whether "arg1" and "arg2" are mutually exclusive.
1348
+
1349
+ PARAMETERS:
1350
+ arg1:
1351
+ Required Argument.
1352
+ Specifies the value of argument1.
1353
+ Types: Any
1354
+
1355
+ err_disp_arg1_name:
1356
+ Required Argument.
1357
+ Specifies the name of argument1.
1358
+ Types: str
1359
+
1360
+ arg2:
1361
+ Required Argument.
1362
+ Specifies the value of argument2.
1363
+ Types: Any
1364
+
1365
+ err_disp_arg2_name:
1366
+ Required Argument.
1367
+ Specifies the name of argument2.
1368
+ Types: str
1369
+
1370
+ skip_all_none_check:
1371
+ Optional Argument.
1372
+ Specifies whether to skip check when arg1 and arg2 both are None.
1373
+ Default Value: False
1374
+ Types: bool
1375
+
1376
+ RETURNS:
1377
+ True, if either arg1 or arg2 is None or both are None.
1378
+
1379
+ RAISES:
1380
+ TeradataMLException
1381
+
1382
+ EXAMPLES:
1383
+ _Validators._validate_mutually_exclusive_arguments(arg1, "arg1", arg2, "arg2")
1384
+ """
1385
+ both_args_none = arg1 is None and arg2 is None
1386
+ if skip_all_none_check:
1387
+ both_args_none = False
1388
+
1389
+ # Either both the arguments are specified or both are None.
1390
+ if all([arg1, arg2]) or both_args_none:
1391
+ raise TeradataMlException(Messages.get_message(
1392
+ MessageCodes.EITHER_THIS_OR_THAT_ARGUMENT, err_disp_arg1_name,
1393
+ err_disp_arg2_name), MessageCodes.EITHER_THIS_OR_THAT_ARGUMENT)
1394
+ return True
1395
+
1396
+ @staticmethod
1397
+ @skip_validation()
1398
+ def _validate_unexpected_column_type(df, col, col_arg, unexpected_types, check_exist=True, raise_error=True):
1399
+ """
1400
+ Internal function to validate the column existence and type of an input DataFrame column against
1401
+ a list of unexpected types.
1402
+
1403
+ PARAMETERS
1404
+ df:
1405
+ Required Argument.
1406
+ Specifies the input teradataml DataFrame which has the column(s) to be tested
1407
+ for type.
1408
+ Types: teradataml DataFrame
1409
+
1410
+ col:
1411
+ Required Argument.
1412
+ Specifies the column(s) in the input DataFrame to be tested for type.
1413
+ Types: str (or) ColumnExpression (or) List of strings(str)
1414
+ or ColumnExpressions
1415
+
1416
+ col_arg:
1417
+ Required Argument.
1418
+ Specifies the name of the argument used to pass the column(s) name.
1419
+ Types: str
1420
+
1421
+ unexpected_types:
1422
+ Required Argument.
1423
+ Specifies unsupported teradatasqlalcehmy datatypes for the column is
1424
+ unexpected to be of type.
1425
+ Types: list of SQLAlchemy types
1426
+
1427
+ check_exist:
1428
+ Optional Argument.
1429
+ Specifies a boolean flag that decides whether to check for column is
1430
+ existed in DataFrame or not.
1431
+ Default Values: True, raise exception if column is not of desired type.
1432
+ Types: bool
1433
+
1434
+ raise_error:
1435
+ Optional Argument.
1436
+ Specifies a boolean flag that decides whether to raise error or just return True or False.
1437
+ Default Values: True, raise exception if column is not of desired type.
1438
+ Types: bool
1439
+
1440
+ RETURNS:
1441
+ True, when the columns is of an expected type.
1442
+
1443
+ RAISES:
1444
+ TeradataMlException, when the columns is not one of the expected types.
1445
+
1446
+ EXAMPLES:
1447
+ _Validators._validate_unexpected_column_type(
1448
+ df, timecode_column, 'timecode_column', PTITableConstants.VALID_TIMECODE_DATATYPES)
1449
+ """
1450
+
1451
+ columns = [col] if not isinstance(col, list) else col
1452
+
1453
+ # Converting "unexpected_types" to tuple as isinstance can accept Tuple
1454
+ # of types too.
1455
+ unexpected_types = tuple(unexpected_types)
1456
+
1457
+ for col in columns:
1458
+ # Get the name of the column if "col" is ColumnExpression.
1459
+ if not isinstance(col, str):
1460
+ col = col.name
1461
+
1462
+ # Check for column existence.
1463
+ if check_exist:
1464
+ _Validators._validate_column_exists_in_dataframe(col, df._metaexpr)
1465
+
1466
+ if isinstance(df[col].type, unexpected_types):
1467
+ if raise_error:
1468
+ invalid_column_types = (col_type.__name__ for col_type in
1469
+ unexpected_types)
1470
+ error_message = Messages.get_message(MessageCodes.INVALID_COLUMN_DATATYPE,
1471
+ col,
1472
+ col_arg,
1473
+ "Unsupported",
1474
+ ", ".join(invalid_column_types))
1475
+ raise TeradataMlException(error_message, MessageCodes.INVALID_COLUMN_DATATYPE)
1476
+
1477
+ else:
1478
+ return False
1479
+
1480
+ return True
1481
+
1482
+ @staticmethod
1483
+ @skip_validation()
1484
+ def _validate_dependent_argument(dependent_arg, dependent_arg_value, independent_arg, independent_arg_value,
1485
+ msg_arg_value=None):
1486
+ """
1487
+ DESCRIPTION:
1488
+ Function validates if an independent argument is specified or not when
1489
+ dependent argument is specified. Raises error, if independent argument
1490
+ is not specified and dependent argument is specified, otherwise returns True.
1491
+
1492
+ PARAMETERS:
1493
+ dependent_arg:
1494
+ Required Argument.
1495
+ Specifies the name of dependent argument.
1496
+ Types: String
1497
+
1498
+ dependent_arg_value:
1499
+ Required Argument.
1500
+ Specifies the value of dependent argument.
1501
+ Types: Any
1502
+
1503
+ independent_arg:
1504
+ Required Argument.
1505
+ Specifies the name of independent argument.
1506
+ Types: String
1507
+
1508
+ independent_arg_value:
1509
+ Required Argument.
1510
+ Specifies the value of independent argument.
1511
+ Types: Any
1512
+
1513
+ msg_arg_value:
1514
+ Optional Argument.
1515
+ Specifies the independent argument value to be printed in message
1516
+ instead of "(not None)".
1517
+ Types: String
1518
+
1519
+ RETURNS:
1520
+ True, when the independent argument is present for the dependent
1521
+ argument.
1522
+
1523
+ RAISES:
1524
+ TeradataMlException, when independent argument is not specified and
1525
+ dependent argument is specified.
1526
+
1527
+ EXAMPLES:
1528
+ _Validators._validate_dependent_argument("dependent_arg_name", admissions_train,
1529
+ "independent_arg_name", None)
1530
+ _Validators._validate_dependent_argument("dependent_arg_name", None,
1531
+ "independent_arg_name", admissions_train)
1532
+ _Validators._validate_dependent_argument("dependent_arg_name", admissions_train,
1533
+ "independent_arg_name", admissions_train)
1534
+ _Validators._validate_dependent_argument("dependent_arg_name", admissions_train,
1535
+ "independent_arg_name", admissions_train,
1536
+ "arg_val")
1537
+ """
1538
+ if dependent_arg_value is not None and independent_arg_value is None:
1539
+ error_code = MessageCodes.DEPENDENT_ARGUMENT
1540
+ error_msg = Messages.get_message(error_code, dependent_arg, independent_arg)
1541
+ if msg_arg_value is None:
1542
+ raise TeradataMlException(error_msg, error_code)
1543
+ else:
1544
+ raise TeradataMlException(error_msg.replace("(not None)", "as '{}'".format(msg_arg_value)),
1545
+ MessageCodes.DEPENDENT_ARGUMENT)
1546
+ return True
1547
+
1548
+ @staticmethod
1549
+ @skip_validation()
1550
+ def _validate_py_type_for_td_type_conversion(py_type, py_type_arg_name):
1551
+ """
1552
+ DESCRIPTION:
1553
+ Function to validate python type, which needs to be converted to TD Type.
1554
+ This function checks whether the python type can be converted to a TD
1555
+ type or not. If PY type is not able to convert TD Type, it then raises
1556
+ an error.
1557
+
1558
+ PARAMETERS:
1559
+ py_type:
1560
+ Required Argument.
1561
+ Specifies the python type.
1562
+ Types: Any
1563
+
1564
+ py_type_arg_name:
1565
+ Required Argument.
1566
+ Specifies the name of argument which holds python variable.
1567
+ Types: str
1568
+
1569
+ RETURNS:
1570
+ None
1571
+
1572
+ RAISES:
1573
+ TeradataMLException
1574
+
1575
+ EXAMPLES:
1576
+ _Validators._validate_py_type_for_td_type_conversion(int, "arg1")
1577
+ """
1578
+ if py_type not in _DtypesMappers.PY_TD_MAPPER:
1579
+ error_code = MessageCodes.UNSUPPORTED_DATATYPE
1580
+ error_msg = Messages.get_message(
1581
+ error_code, py_type_arg_name, '[{}]'.format(", ".join((t.__name__ for t in _DtypesMappers.PY_TD_MAPPER))))
1582
+ raise TeradataMlException(error_msg, error_code)
1583
+
1584
+ @staticmethod
1585
+ @skip_validation()
1586
+ def _validate_function_install_location_is_set(option, function_type, option_name):
1587
+ """
1588
+ DESCRIPTION:
1589
+ Function to validate whether install location for functions is set.
1590
+
1591
+ PARAMETERS:
1592
+ option:
1593
+ Required Argument.
1594
+ Specifies the configuration option value to validate.
1595
+ Types: str
1596
+
1597
+ function_type:
1598
+ Required Argument.
1599
+ Specifies the type of function to check installed location for.
1600
+ Types: str
1601
+
1602
+ option_name:
1603
+ Required Argument.
1604
+ Specifies the configuration option name.
1605
+ Types: str
1606
+
1607
+ RETURNS:
1608
+ None
1609
+
1610
+ RAISES:
1611
+ TeradataMLException
1612
+
1613
+ EXAMPLES:
1614
+ _Validators._validate_function_install_location_is_set(
1615
+ configure.byom_install_location,
1616
+ "Bring Your Own Model",
1617
+ "configure.byom_install_location")
1618
+ """
1619
+ # Check whether an empty string is passed to "option".
1620
+ _Validators._validate_input_columns_not_empty(option, option_name)
1621
+
1622
+ if option is None:
1623
+ message = Messages.get_message(MessageCodes.UNKNOWN_INSTALL_LOCATION,
1624
+ "{} functions".format(function_type),
1625
+ "option '{}'".format(option_name))
1626
+ raise TeradataMlException(message, MessageCodes.MISSING_ARGS)
1627
+
1628
+ @staticmethod
1629
+ @skip_validation()
1630
+ def _check_table_exists(conn, table_name,
1631
+ schema_name,
1632
+ raise_error_if_does_not_exists=True,
1633
+ additional_error=''):
1634
+ """
1635
+ DESCRIPTION:
1636
+ Check whether table specified exists or not.
1637
+
1638
+ PARAMETERS:
1639
+ raise_error_if_does_not_exists:
1640
+ Optional Argument.
1641
+ Specifies the flag to decide whether to raise error when table name specified does not exist.
1642
+ Default Value: True (Raise exception)
1643
+ Types: bool
1644
+
1645
+ additional_error:
1646
+ Optional Argument.
1647
+ Specifies the additional error message to display along with standard message.
1648
+ Default Value: ''
1649
+ Types: String
1650
+
1651
+ RAISES:
1652
+ TeradataMlException.
1653
+
1654
+ RETURNS:
1655
+ True, if table exists, else False.
1656
+
1657
+ EXAMPLES:
1658
+ >>> _check_table_exists('model_table_name','model_schema_name')
1659
+ """
1660
+
1661
+ # Check whether table exists on the system or not.
1662
+ table_exists = conn.dialect.has_table(conn, table_name=table_name,
1663
+ schema=schema_name)
1664
+
1665
+ # If tables exists, return True.
1666
+ if table_exists:
1667
+ return True
1668
+
1669
+ # We are here means the specified table does not exist.
1670
+ # Let's raise error if 'raise_error_if_does_not_exists' set to True.
1671
+ if raise_error_if_does_not_exists:
1672
+ # Raise error, as the specified table_name does not exist.
1673
+ # TABLE_DOES_NOT_EXIST
1674
+ raise TeradataMlException(Messages.get_message(MessageCodes.TABLE_DOES_NOT_EXIST,
1675
+ schema_name, table_name, additional_error),
1676
+ MessageCodes.TABLE_DOES_NOT_EXIST)
1677
+ return False
1678
+
1679
+ @staticmethod
1680
+ @skip_validation()
1681
+ def _check_empty_file(file_path):
1682
+ """
1683
+ Description:
1684
+ Function to validate whether the given file is not empty,
1685
+ given absolute file path.
1686
+
1687
+ PARAMETERS:
1688
+ file_path:
1689
+ Required Argument.
1690
+ Specifies absolute file path of the file.
1691
+ Types: str
1692
+
1693
+ RETURNS:
1694
+ Boolean
1695
+
1696
+ RAISES:
1697
+ TeradataMlException
1698
+
1699
+ EXAMPLES:
1700
+ _check_empty_file("/abc/xyz.txt")
1701
+ """
1702
+
1703
+ if os.stat(file_path).st_size == 0:
1704
+ raise TeradataMlException(
1705
+ Messages.get_message(MessageCodes.EMPTY_FILE,
1706
+ "{}".format(file_path)),
1707
+ MessageCodes.EMPTY_FILE)
1708
+ return True
1709
+
1710
+ @staticmethod
1711
+ @skip_validation()
1712
+ def _validate_mutually_inclusive_arguments(arg1, err_disp_arg1_name, arg2,
1713
+ err_disp_arg2_name):
1714
+ """
1715
+ DESCRIPTION:
1716
+ Function to validate whether "arg1" and "arg2" are mutually inclusive.
1717
+
1718
+ PARAMETERS:
1719
+ arg1:
1720
+ Required Argument.
1721
+ Specifies the value of argument1.
1722
+ Types: Any
1723
+
1724
+ err_disp_arg1_name:
1725
+ Required Argument.
1726
+ Specifies the name of argument1.
1727
+ Types: str
1728
+
1729
+ arg2:
1730
+ Required Argument.
1731
+ Specifies the value of argument2.
1732
+ Types: Any
1733
+
1734
+ err_disp_arg2_name:
1735
+ Required Argument.
1736
+ Specifies the name of argument2.
1737
+ Types: str
1738
+
1739
+ RETURNS:
1740
+ True, if both arg1 and arg2 are present or both are None.
1741
+
1742
+ RAISES:
1743
+ TeradataMLException
1744
+
1745
+ EXAMPLES:
1746
+ _Validators._validate_mutually_inclusive_arguments(arg1, "arg1", arg2, "arg2")
1747
+ """
1748
+ both_args_none = arg1 is None and arg2 is None
1749
+ # If below handles 0 value.
1750
+ # 0 turns to False using bool(0) but 0 is a valid value and should return True.
1751
+ arg1 = True if arg1 == 0 else bool(arg1)
1752
+ arg2 = True if arg2 == 0 else bool(arg2)
1753
+
1754
+ # Either both the arguments are specified or both are None.
1755
+ if not(all([arg1, arg2]) or both_args_none):
1756
+ arg_order = [err_disp_arg1_name, err_disp_arg2_name] if arg1 \
1757
+ else [err_disp_arg2_name, err_disp_arg1_name]
1758
+ raise TeradataMlException(Messages.get_message(
1759
+ MessageCodes.DEPENDENT_ARGUMENT, arg_order[0],
1760
+ arg_order[1]), MessageCodes.DEPENDENT_ARGUMENT)
1761
+ return True
1762
+
1763
+ @staticmethod
1764
+ @skip_validation()
1765
+ def _validate_file_extension(file_path, extension):
1766
+ """
1767
+ DESCRIPTION:
1768
+ Function to validate whether the file has a specified extension.
1769
+
1770
+ PARAMETERS:
1771
+ file_path:
1772
+ Required Argument.
1773
+ Specifies the file path or file name.
1774
+ Types: str
1775
+
1776
+ extension:
1777
+ Required Argument.
1778
+ Specifies the extension of the file.
1779
+ Types: str OR list of Strings (str)
1780
+
1781
+ RETURNS:
1782
+ True, if the file has specified extension.
1783
+
1784
+ RAISES:
1785
+ TeradataMLException
1786
+
1787
+ EXAMPLES:
1788
+
1789
+ _Validators._validate_file_extension("/data/mapper.py",".py")
1790
+ _Validators._validate_file_extension("ml__demoenv_requirements_1605727131624097.txt",".txt")
1791
+ """
1792
+ extension = extension if isinstance(extension, list) else[extension]
1793
+ file_extension = file_path.lower().split('.')[-1]
1794
+ if file_extension not in extension:
1795
+ raise TeradataMlException(
1796
+ Messages.get_message(MessageCodes.UNSUPPORTED_FILE_EXTENSION).format("{}".format(extension)),
1797
+ MessageCodes.UNSUPPORTED_FILE_EXTENSION)
1798
+
1799
+ return True
1800
+
1801
+
1802
+ @staticmethod
1803
+ @skip_validation()
1804
+ def _validate_argument_is_not_None(arg, arg_name, additional_error="", reverse=False):
1805
+ """
1806
+ DESCRIPTION:
1807
+ Check whether the argument provided is not None.
1808
+ If parameter reverse is set to True, the validation is reversed to
1809
+ check whether argument provided is None.
1810
+
1811
+ PARAMETERS:
1812
+ arg:
1813
+ Required Argument.
1814
+ Specifies the argument to be validated.
1815
+ Types: str
1816
+
1817
+ arg_name:
1818
+ Required Argument.
1819
+ Specifies the name of the argument to be printed in error message.
1820
+ Types: str
1821
+
1822
+ additional_error:
1823
+ Optional Argument.
1824
+ Specifies the additional error message to display along with standard message.
1825
+ Default value=""
1826
+ Types: str
1827
+
1828
+ reverse:
1829
+ Optional Argument.
1830
+ Specifies whether to reverse the validation.
1831
+ Returns True if arg is None, False if arg is not None.
1832
+ Default value=False
1833
+ Types: bool
1834
+
1835
+
1836
+ RAISES:
1837
+ ValueError.
1838
+
1839
+ RETURNS:
1840
+ True, if the argument is not None, else False.
1841
+
1842
+ EXAMPLES:
1843
+ >>> _validate_argument_is_not_None(table_name, "table_name", additional_error)
1844
+ """
1845
+ if not reverse:
1846
+ # Raise an error if the argument is None.
1847
+ if arg is None:
1848
+ raise ValueError(Messages.get_message(MessageCodes.ARG_NONE, arg_name, "None", additional_error))
1849
+ return True
1850
+ else:
1851
+ # Raise an error if the argument is not None.
1852
+ if arg is not None:
1853
+ raise ValueError(Messages.get_message(MessageCodes.ARG_NONE, arg_name,
1854
+ "provided {}".format(additional_error), ""))
1855
+ return True
1856
+
1857
+
1858
+ @staticmethod
1859
+ @skip_validation()
1860
+ def _validate_dataframe(df, raise_error=True):
1861
+ """
1862
+ This is an internal function checks whether the dataframe is none
1863
+ or not. If not none then checks the dataframe type and length of columns.
1864
+
1865
+ PARAMETERS:
1866
+ df:
1867
+ Required Argument.
1868
+ Specifies the dataframe.
1869
+ Types: pandas.DataFrame or teradataml.dataframe.dataframe.DataFrame
1870
+
1871
+ raise_error:
1872
+ Optional Argument.
1873
+ Specifies whether to raise an exception or not.
1874
+ Default Values: True
1875
+ Types: bool
1876
+
1877
+ RETURNS:
1878
+ None
1879
+
1880
+ RAISES:
1881
+ TeradataMlException
1882
+
1883
+ EXAMPLES:
1884
+ _validate_dataframe(df)
1885
+
1886
+ """
1887
+ from teradataml.dataframe import dataframe as tdmldf
1888
+
1889
+ valid = False
1890
+ if df is not None:
1891
+ if isinstance(df, pd.DataFrame) and len(df.columns) > 0:
1892
+ valid = True
1893
+ elif isinstance(df, tdmldf.DataFrame) and len(df._metaexpr.c) > 0:
1894
+ valid = True
1895
+ else:
1896
+ valid = False
1897
+
1898
+ if raise_error and not valid:
1899
+ raise TeradataMlException(Messages.get_message(MessageCodes.IS_NOT_VALID_DF),
1900
+ MessageCodes.IS_NOT_VALID_DF)
1901
+
1902
+
1903
+ @staticmethod
1904
+ @skip_validation()
1905
+ def _validate_column_value_length(argument_name, argument_value, allowed_length,
1906
+ operation='perform the operation'):
1907
+ """
1908
+ DESCRIPTION:
1909
+ Function to validate length of string against permitted value.
1910
+
1911
+ PARAMETERS:
1912
+ argument_name:
1913
+ Required Argument.
1914
+ Specifies the name of the argument whose value
1915
+ will be checked against permitted length.
1916
+ This is used while raising an error.
1917
+ Types: str.
1918
+
1919
+ argument_value:
1920
+ Required Argument.
1921
+ Specifies the string whose length will be checked against permitted length.
1922
+ Types: str.
1923
+
1924
+ allowed_length:
1925
+ Required Argument.
1926
+ Specifies the allowed length for argument value.
1927
+ Types: int.
1928
+
1929
+ operation:
1930
+ Optional Argument.
1931
+ Specifies the name of operation which will fail, if this check fails.
1932
+ Default value: 'perform the operation'.
1933
+ Types: str.
1934
+
1935
+ RETURNS:
1936
+ None.
1937
+
1938
+ RAISES:
1939
+ TeradataMlException - EXECUTION_FAILED, ValueError
1940
+
1941
+ EXAMPLES:
1942
+ >>> _validate_column_value_length("Description", "KMeans model", 150, "save the model")
1943
+ """
1944
+ try:
1945
+ _Validators._validate_str_arg_length(argument_name, argument_value, 'LE', allowed_length)
1946
+ except ValueError:
1947
+ error_code = MessageCodes.EXECUTION_FAILED
1948
+ error_msg = Messages.get_message(
1949
+ error_code, operation,
1950
+ 'Length of argument {0} ({1}) is more than the allowed length ({2}).'
1951
+ .format(argument_name, len(argument_value), allowed_length))
1952
+ raise TeradataMlException(error_msg, error_code)
1953
+ return True
1954
+
1955
+
1956
+ @staticmethod
1957
+ @skip_validation()
1958
+ def _validate_list_lengths_equal(list1, arg_name1, list2, arg_name2):
1959
+ """
1960
+ DESCRIPTION:
1961
+ Check if length of the lists is same or not.
1962
+
1963
+ PARAMETERS:
1964
+ list1:
1965
+ Required Argument.
1966
+ Specifies the first list to check the length against "list2".
1967
+ Types: list
1968
+
1969
+ arg_name1:
1970
+ Required Argument.
1971
+ Specifies the name of the argument that accepts "list1" as input.
1972
+ This is used while raising an error.
1973
+ Types: str
1974
+
1975
+ list2:
1976
+ Required Argument.
1977
+ Specifies the second list to check the length against "list1".
1978
+ Types: list
1979
+
1980
+ arg_name2:
1981
+ Required Argument.
1982
+ Specifies the name of the argument that accepts "list2" as input.
1983
+ This is used while raising an error.
1984
+ Types: str
1985
+
1986
+ RETURNS:
1987
+ None.
1988
+
1989
+ RAISES:
1990
+ ValueError
1991
+
1992
+ EXAMPLES:
1993
+ _Validators._validate_list_lengths_equal(self.coordinates, "coordinates",
1994
+ self.timestamps, "timestamps")
1995
+ """
1996
+ if len(list1) != len(list2):
1997
+ # Raise error, if length of both lists is not same.
1998
+ err_ = Messages.get_message(MessageCodes.INVALID_LENGTH_ARGS,
1999
+ "'{}' and '{}'".format(arg_name1, arg_name2))
2000
+ raise ValueError(err_)
2001
+ return True
2002
+
2003
+ @staticmethod
2004
+ @skip_validation()
2005
+ def _validate_dict_argument_key_value(arg_name, arg_dict, key_types=None, value_types=None,
2006
+ key_permitted_values=None, value_permitted_values=None,
2007
+ value_empty_string=True):
2008
+ """
2009
+ DESCRIPTION:
2010
+ Internal function to validate type and permitted values
2011
+ for keys and values in a dictionary argument.
2012
+
2013
+ PARAMETERS:
2014
+ arg_name:
2015
+ Required Argument.
2016
+ Specifies the name of the dictionary argument.
2017
+ Types: str
2018
+
2019
+ arg_dict:
2020
+ Required Argument.
2021
+ Specifies the dictonary value of "arg_name".
2022
+ Types: dict
2023
+
2024
+ key_types:
2025
+ Optional Argument.
2026
+ Specifies the types, 'keys' of the "arg_dict" can take.
2027
+ Types: Any type or tuple of types
2028
+
2029
+ value_types:
2030
+ Optional Argument.
2031
+ Specifies the types, 'values' assigned to 'keys' of
2032
+ "arg_dict" can take.
2033
+ Types: Any type or tuple of types
2034
+
2035
+ key_permitted_values:
2036
+ Optional Argument.
2037
+ Specifies the permitted values for the 'keys' of "arg_dict".
2038
+ Types: list
2039
+
2040
+ value_permitted_values:
2041
+ Optional Argument.
2042
+ Specifies the permitted values for the 'values' assgined to 'keys'
2043
+ of "arg_dict".
2044
+ Types: list
2045
+
2046
+ value_empty_string:
2047
+ Optional Argument.
2048
+ Specifies the whether 'values' assigned to 'keys' of "arg_dict"
2049
+ can accept empty string.
2050
+ Set to True, dictionary value with empty string is accepted.
2051
+ Set to False, dictionary value with empty string is not accepted.
2052
+ Default Value: True
2053
+ Types: bool
2054
+
2055
+ RETURNS:
2056
+ bool
2057
+
2058
+ RAISES:
2059
+ TypeError, ValueError
2060
+
2061
+ EXAMPLES:
2062
+ _Validators._validate_dict_argument_key_value("name", {"a":3, "b":4}, (str), (int))
2063
+ _Validators._validate_dict_argument_key_value(arg_name="columns", arg_dict=columns,
2064
+ key_types=(ColumnExpression, _TupleOf(ColumnExpression)),
2065
+ value_types=(str, int, float, NoneType))
2066
+
2067
+ """
2068
+ info_matrix = []
2069
+ dict_keys_list = set()
2070
+ from teradataml.common.utils import UtilFuncs
2071
+
2072
+ try:
2073
+ for key, value in arg_dict.items():
2074
+ # Validate duplicate keys exists or not.
2075
+ # If keys are not of type tuple, convert it to tuple.
2076
+ keys_list = (key,) if not isinstance(key, tuple) else key
2077
+
2078
+ # If duplicate key exists raise exception. E.g.
2079
+ # di = {("key1", "key2"): "my_keys1",
2080
+ # ("key1", "key3"): "my_keys2",
2081
+ # "key2" : "my_keys3"}
2082
+ for k in keys_list:
2083
+ # If ColumnExpression, get the column name.
2084
+ if isinstance(k, ColumnExpression):
2085
+ k_name, name = k.name, "ColumnExpression(s)"
2086
+ else:
2087
+ k_name, name = k, "Key names"
2088
+
2089
+ # If duplicate key exists raise exception.
2090
+ if k_name in dict_keys_list:
2091
+ raise TeradataMlException(Messages.get_message(
2092
+ MessageCodes.DUPLICATE_DICT_KEYS_NAMES,
2093
+ name, arg_name),
2094
+ MessageCodes.DUPLICATE_PARAMETER)
2095
+ else:
2096
+ dict_keys_list.add(k_name)
2097
+
2098
+ # Append "keys" and "values" into arg info matrix for type validation.
2099
+ if key_types is not None:
2100
+ info_matrix.append(["<dict_key>", key, True, key_types, True])
2101
+
2102
+ if value_types is not None:
2103
+ info_matrix.append(
2104
+ ["<dict_value>", value, True, value_types, not value_empty_string])
2105
+
2106
+ # Validate permitted values for both "key" and "value" if permitted values
2107
+ # are provided.
2108
+ if key_permitted_values is not None:
2109
+ _Validators._validate_permitted_values(arg=key,
2110
+ permitted_values=key_permitted_values,
2111
+ arg_name="<dict_key>",
2112
+ case_insensitive=False,
2113
+ includeNone=True)
2114
+
2115
+ if value_permitted_values is not None:
2116
+ _Validators._validate_permitted_values(arg=value,
2117
+ permitted_values=value_permitted_values,
2118
+ arg_name="<dict_value>",
2119
+ case_insensitive=False,
2120
+ includeNone=True)
2121
+
2122
+ if key_types is not None or value_types is not None:
2123
+ # Validate types using already existing validator.
2124
+ _Validators._validate_function_arguments(info_matrix)
2125
+
2126
+ except ValueError as ve:
2127
+ # Catch ValueError raised by '_validate_permitted_values' to
2128
+ # raise proper error message for dictionary argument.
2129
+ if "TDML_2007" in str(ve):
2130
+ permitted_values = value_permitted_values
2131
+ err_str = "value"
2132
+ err_val = value
2133
+ if "<dict_key>" in str(ve):
2134
+ permitted_values = key_permitted_values
2135
+ err_str = "key"
2136
+ err_val = key
2137
+ raise ValueError(
2138
+ Messages.get_message(MessageCodes.INVALID_DICT_ARG_VALUE, err_val,
2139
+ err_str, arg_name, permitted_values))
2140
+
2141
+ # Catch ValueError raised by '_validate_function_arguments'
2142
+ # for empty string value.
2143
+ elif "TDML_2004" in str(ve):
2144
+ err_str = "Key" if "<dict_key>" in str(ve) else "Value"
2145
+ raise ValueError(
2146
+ Messages.get_message(MessageCodes.DICT_ARG_KEY_VALUE_EMPTY,
2147
+ err_str, arg_name))
2148
+
2149
+ except TypeError as te:
2150
+ # Catch TypeError raised by '_validate_function_arguments' to
2151
+ # raise proper error message for dictionary argument.
2152
+ permitted_types = value_types
2153
+ err_str = "value"
2154
+ if "<dict_key>" in str(te):
2155
+ permitted_types = key_types
2156
+ err_str = "key"
2157
+
2158
+ permitted_types = [''.join(_Validators.__getTypeAsStr(kv_type))
2159
+ if isinstance(kv_type, (_TupleOf, _ListOf)) else
2160
+ kv_type.__name__ for kv_type in permitted_types]
2161
+
2162
+ raise TypeError(
2163
+ Messages.get_message(MessageCodes.UNSUPPORTED_DICT_KEY_VALUE_DTYPE, err_str,
2164
+ arg_name, permitted_types))
2165
+
2166
+ return True
2167
+
2168
+ @staticmethod
2169
+ @skip_validation()
2170
+ def _validate_http_response(http_response, valid_status_code, error_msg):
2171
+ """
2172
+ DESCRIPTION:
2173
+ Internal function to validate the HTTP response.
2174
+
2175
+ PARAMETERS:
2176
+ http_response:
2177
+ Required Argument.
2178
+ Specifies the response object recieved from HTTP request.
2179
+ Types: requests.models.Response OR httpx.Response
2180
+
2181
+ valid_status_code:
2182
+ Required Argument.
2183
+ Specifies the HTTP response code of a request.
2184
+ Types: int
2185
+
2186
+ error_msg:
2187
+ Required Argument.
2188
+ Specifies the error message to be displayed when response code is
2189
+ not equal to "valid_status_code".
2190
+ Types: str
2191
+
2192
+ RETURNS:
2193
+ bool
2194
+
2195
+ RAISES:
2196
+ TeradatamlException
2197
+
2198
+ EXAMPLES:
2199
+ _Validators._validate_http_response(resp, 200, "test1")
2200
+ """
2201
+ if http_response.status_code != valid_status_code:
2202
+ err_ = Messages.get_message(MessageCodes.EXECUTION_FAILED,
2203
+ error_msg,
2204
+ "Error-details: ({}){}".format(http_response.status_code, http_response.text))
2205
+ raise TeradataMlException(err_, MessageCodes.EXECUTION_FAILED)
2206
+
2207
+ return True
2208
+
2209
+ @staticmethod
2210
+ @skip_validation()
2211
+ def _validate_module_presence(module_name, function_name):
2212
+ """
2213
+ DESCRIPTION:
2214
+ Check if module being imported is present.
2215
+
2216
+ PARAMETERS:
2217
+ module_name:
2218
+ Required Argument.
2219
+ Specifies the name of the module to import.
2220
+ Types: str
2221
+
2222
+ function_name:
2223
+ Required Argument.
2224
+ Specifies the name of the function from where module is imported.
2225
+ Types: str
2226
+
2227
+ RETURNS:
2228
+ None.
2229
+
2230
+ RAISES:
2231
+ TeradataMlException
2232
+
2233
+ EXAMPLES:
2234
+ _Validators._validate_module_presence("docker", "setup_sandbox_env")
2235
+ """
2236
+ import importlib
2237
+
2238
+ try:
2239
+ importlib.import_module(module_name, package=None)
2240
+ except Exception as err:
2241
+ message = \
2242
+ Messages.get_message(
2243
+ MessageCodes.IMPORT_PYTHON_PACKAGE,
2244
+ module_name, module_name, function_name)
2245
+ raise TeradataMlException(message,
2246
+ MessageCodes.IMPORT_PYTHON_PACKAGE)
2247
+ return True
2248
+
2249
+
2250
+ @staticmethod
2251
+ @skip_validation()
2252
+ def _validate_ipaddress(ip_address):
2253
+ """
2254
+ DESCRIPTION:
2255
+ Check if ipaddress is valid.
2256
+ PARAMETERS:
2257
+ ip_address:
2258
+ Required Argument.
2259
+ Specifies the ip address to be validated.
2260
+ Types: str
2261
+ RETURNS:
2262
+ None.
2263
+ RAISES:
2264
+ TeradataMlException
2265
+ EXAMPLES:
2266
+ _Validators._validate_ipaddress("190.132.12.15")
2267
+ """
2268
+ import ipaddress
2269
+
2270
+ try:
2271
+ ipaddress.ip_address(ip_address)
2272
+ except Exception as err:
2273
+ raise ValueError(Messages.get_message(
2274
+ MessageCodes.INVALID_ARG_VALUE).format(ip_address, "ip_address",
2275
+ 'of four numbers (each between 0 and 255) separated by periods'))
2276
+
2277
+ return True