teradataml 20.0.0.2__py3-none-any.whl → 20.0.0.3__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.
- teradataml/LICENSE-3RD-PARTY.pdf +0 -0
- teradataml/README.md +196 -2
- teradataml/__init__.py +4 -0
- teradataml/_version.py +1 -1
- teradataml/analytics/analytic_function_executor.py +79 -4
- teradataml/analytics/json_parser/metadata.py +12 -3
- teradataml/analytics/json_parser/utils.py +7 -2
- teradataml/analytics/sqle/__init__.py +1 -0
- teradataml/analytics/table_operator/__init__.py +1 -1
- teradataml/analytics/uaf/__init__.py +1 -1
- teradataml/analytics/utils.py +4 -0
- teradataml/automl/data_preparation.py +3 -2
- teradataml/automl/feature_engineering.py +15 -7
- teradataml/automl/model_training.py +39 -33
- teradataml/common/__init__.py +2 -1
- teradataml/common/constants.py +35 -0
- teradataml/common/garbagecollector.py +2 -1
- teradataml/common/messagecodes.py +8 -2
- teradataml/common/messages.py +3 -1
- teradataml/common/sqlbundle.py +25 -3
- teradataml/common/utils.py +134 -9
- teradataml/context/context.py +20 -10
- teradataml/data/SQL_Fundamentals.pdf +0 -0
- teradataml/data/dataframe_example.json +18 -2
- teradataml/data/docs/sqle/docs_17_20/NaiveBayes.py +1 -1
- teradataml/data/docs/sqle/docs_17_20/Shap.py +7 -1
- teradataml/data/docs/sqle/docs_17_20/TDNaiveBayesPredict.py +4 -4
- teradataml/data/docs/sqle/docs_17_20/TextParser.py +3 -3
- teradataml/data/docs/tableoperator/docs_17_20/Image2Matrix.py +118 -0
- teradataml/data/docs/uaf/docs_17_20/CopyArt.py +145 -0
- teradataml/data/docs/uaf/docs_17_20/DickeyFuller.py +18 -21
- teradataml/data/jsons/sqle/17.20/TD_TextParser.json +1 -1
- teradataml/data/jsons/sqle/20.00/TD_KMeans.json +250 -0
- teradataml/data/jsons/sqle/20.00/TD_SMOTE.json +266 -0
- teradataml/data/jsons/sqle/20.00/TD_VectorDistance.json +278 -0
- teradataml/data/jsons/storedprocedure/17.20/TD_COPYART.json +71 -0
- teradataml/data/jsons/tableoperator/17.20/IMAGE2MATRIX.json +53 -0
- teradataml/data/jsons/uaf/17.20/TD_DICKEY_FULLER.json +10 -19
- teradataml/data/jsons/uaf/17.20/TD_SAX.json +3 -1
- teradataml/data/jsons/uaf/17.20/TD_WINDOWDFFT.json +15 -5
- teradataml/data/medical_readings.csv +101 -0
- teradataml/data/patient_profile.csv +101 -0
- teradataml/data/scripts/lightgbm/dataset.template +157 -0
- teradataml/data/scripts/lightgbm/lightgbm_class_functions.template +247 -0
- teradataml/data/scripts/lightgbm/lightgbm_function.template +216 -0
- teradataml/data/scripts/lightgbm/lightgbm_sklearn.template +159 -0
- teradataml/data/scripts/sklearn/sklearn_fit.py +194 -167
- teradataml/data/scripts/sklearn/sklearn_fit_predict.py +136 -115
- teradataml/data/scripts/sklearn/sklearn_function.template +14 -19
- teradataml/data/scripts/sklearn/sklearn_model_selection_split.py +155 -137
- teradataml/data/scripts/sklearn/sklearn_transform.py +129 -42
- teradataml/data/target_udt_data.csv +8 -0
- teradataml/data/templates/open_source_ml.json +3 -2
- teradataml/data/vectordistance_example.json +4 -0
- teradataml/dataframe/dataframe.py +543 -175
- teradataml/dataframe/functions.py +553 -25
- teradataml/dataframe/sql.py +184 -15
- teradataml/dbutils/dbutils.py +556 -18
- teradataml/dbutils/filemgr.py +48 -1
- teradataml/lib/aed_0_1.dll +0 -0
- teradataml/opensource/__init__.py +1 -1
- teradataml/opensource/{sklearn/_class.py → _class.py} +102 -17
- teradataml/opensource/_lightgbm.py +950 -0
- teradataml/opensource/{sklearn/_wrapper_utils.py → _wrapper_utils.py} +1 -2
- teradataml/opensource/{sklearn/constants.py → constants.py} +13 -10
- teradataml/opensource/sklearn/__init__.py +0 -1
- teradataml/opensource/sklearn/_sklearn_wrapper.py +798 -438
- teradataml/options/__init__.py +7 -23
- teradataml/options/configure.py +29 -3
- teradataml/scriptmgmt/UserEnv.py +3 -3
- teradataml/scriptmgmt/lls_utils.py +74 -21
- teradataml/store/__init__.py +13 -0
- teradataml/store/feature_store/__init__.py +0 -0
- teradataml/store/feature_store/constants.py +291 -0
- teradataml/store/feature_store/feature_store.py +2223 -0
- teradataml/store/feature_store/models.py +1505 -0
- teradataml/store/vector_store/__init__.py +1586 -0
- teradataml/table_operators/query_generator.py +3 -0
- teradataml/table_operators/table_operator_query_generator.py +3 -1
- teradataml/table_operators/table_operator_util.py +37 -38
- teradataml/table_operators/templates/dataframe_register.template +69 -0
- teradataml/utils/dtypes.py +4 -2
- teradataml/utils/validators.py +33 -1
- {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.3.dist-info}/METADATA +200 -5
- {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.3.dist-info}/RECORD +88 -65
- {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.3.dist-info}/WHEEL +0 -0
- {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.3.dist-info}/top_level.txt +0 -0
- {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.3.dist-info}/zip-safe +0 -0
teradataml/dbutils/filemgr.py
CHANGED
|
@@ -15,12 +15,16 @@ import os
|
|
|
15
15
|
from pathlib import Path
|
|
16
16
|
from sqlalchemy import func
|
|
17
17
|
from sqlalchemy.sql.expression import text
|
|
18
|
+
import teradataml.dataframe as tdmldf
|
|
19
|
+
from teradataml.utils.internal_buffer import _InternalBuffer
|
|
18
20
|
from teradatasql import OperationalError as SqlOperationalError
|
|
19
21
|
from teradataml.common.exceptions import TeradataMlException
|
|
20
22
|
from teradataml.common.messages import Messages
|
|
21
23
|
from teradataml.common.messagecodes import MessageCodes
|
|
22
|
-
from teradataml.dbutils.dbutils import _execute_stored_procedure
|
|
24
|
+
from teradataml.dbutils.dbutils import _execute_stored_procedure, set_session_param
|
|
23
25
|
from teradataml.utils.validators import _Validators
|
|
26
|
+
from teradataml.options.configure import configure
|
|
27
|
+
from teradataml.common.constants import TableOperatorConstants
|
|
24
28
|
|
|
25
29
|
def install_file(file_identifier, file_path = None, file_on_client = True, is_binary = False,
|
|
26
30
|
replace = False, force_replace = False, suppress_output = False):
|
|
@@ -265,3 +269,46 @@ def remove_file(file_identifier, force_remove = None, suppress_output = False):
|
|
|
265
269
|
raise TeradataMlException(Messages.get_message(MessageCodes.REMOVE_FILE_FAILED, file_identifier) +
|
|
266
270
|
'\n' + str(err),
|
|
267
271
|
MessageCodes.REMOVE_FILE_FAILED)
|
|
272
|
+
|
|
273
|
+
def list_files():
|
|
274
|
+
"""
|
|
275
|
+
DESCRIPTION:
|
|
276
|
+
List all the files installed in Vantage or in Vantage Languages Ecosystem.
|
|
277
|
+
|
|
278
|
+
PARAMETERS:
|
|
279
|
+
None
|
|
280
|
+
|
|
281
|
+
RETURNS:
|
|
282
|
+
teradataml DataFrame
|
|
283
|
+
|
|
284
|
+
RAISES:
|
|
285
|
+
TeradataMLException.
|
|
286
|
+
|
|
287
|
+
EXAMPLES:
|
|
288
|
+
# Example 1: List files installed in the Vantage Ecosystem.
|
|
289
|
+
# Install the file mapper.py found at the relative path data/scripts/
|
|
290
|
+
>>> install_file (file_identifier='mapper', file_path='data/scripts/mapper.py')
|
|
291
|
+
File mapper.py installed in Vantage
|
|
292
|
+
|
|
293
|
+
# List file installed in the Vantage Ecosystem.
|
|
294
|
+
>>> list_files()
|
|
295
|
+
Files
|
|
296
|
+
0 mapper.py
|
|
297
|
+
"""
|
|
298
|
+
# Get the current database name.
|
|
299
|
+
import teradataml.context.context as context
|
|
300
|
+
database = context._get_current_databasename()
|
|
301
|
+
|
|
302
|
+
# set_session_param maintains a buffer of session parameters.
|
|
303
|
+
# If the session parameter is not set or if setted SearchUIFDBPath is different
|
|
304
|
+
# from the current database, then we will set the SEARCHUIFDBPATH to the current
|
|
305
|
+
# database. This will avoid setting the SEARCHUIFDBPATH multiple times.
|
|
306
|
+
session_params = _InternalBuffer.get('session_params')
|
|
307
|
+
if session_params is None or session_params["SearchUIFDBPath"] != database:
|
|
308
|
+
set_session_param("SEARCHUIFDBPATH", database)
|
|
309
|
+
|
|
310
|
+
# Get the query to list files installed in Vantage.
|
|
311
|
+
list_files_query = TableOperatorConstants.SCRIPT_LIST_FILES_QUERY.value \
|
|
312
|
+
.format(database, configure.default_varchar_size)
|
|
313
|
+
|
|
314
|
+
return tdmldf.dataframe.DataFrame.from_query(list_files_query)
|
teradataml/lib/aed_0_1.dll
CHANGED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
from teradataml.opensource.
|
|
1
|
+
from teradataml.opensource._class import td_sklearn, td_lightgbm
|
|
@@ -16,10 +16,9 @@
|
|
|
16
16
|
|
|
17
17
|
from importlib import import_module
|
|
18
18
|
from teradataml.opensource.sklearn._sklearn_wrapper import _SkLearnObjectWrapper, _SKLearnFunctionWrapper
|
|
19
|
-
from teradataml.opensource.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
sklearn_functions = ["k_means"]
|
|
19
|
+
from teradataml.opensource._lightgbm import _LightgbmDatasetWrapper, \
|
|
20
|
+
_LightgbmFunctionWrapper, _LightgbmBoosterWrapper, _LighgbmSklearnWrapper
|
|
21
|
+
from teradataml.opensource.constants import _SKL_MODULES, _LIGHTGBM_MODULES
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
class _OpenSource:
|
|
@@ -33,21 +32,30 @@ class _OpenSource:
|
|
|
33
32
|
self._object_wrapper = None
|
|
34
33
|
self._function_wrapper = None
|
|
35
34
|
|
|
35
|
+
def _get_module_and_class_instance(self, name):
|
|
36
|
+
"""
|
|
37
|
+
Internal function to get the module and class instance/function which will
|
|
38
|
+
be passed to object/function wrapper.
|
|
39
|
+
"""
|
|
40
|
+
class_instance = None
|
|
41
|
+
module = None
|
|
42
|
+
for module in self._modules:
|
|
43
|
+
lib = import_module(module)
|
|
44
|
+
try:
|
|
45
|
+
class_instance = getattr(lib, name)
|
|
46
|
+
break
|
|
47
|
+
except AttributeError as ex:
|
|
48
|
+
continue
|
|
49
|
+
|
|
50
|
+
if not class_instance:
|
|
51
|
+
raise ValueError(f"The class/function '{name}' does not exist in '{self.__class__.name.lower()}' modules.")
|
|
52
|
+
|
|
53
|
+
return module, class_instance
|
|
54
|
+
|
|
36
55
|
def __getattr__(self, name):
|
|
37
56
|
|
|
38
57
|
def __get_module(*c, **kwargs):
|
|
39
|
-
class_instance =
|
|
40
|
-
module = None
|
|
41
|
-
for module in self._modules:
|
|
42
|
-
lib = import_module(module)
|
|
43
|
-
try:
|
|
44
|
-
class_instance = getattr(lib, name)
|
|
45
|
-
break
|
|
46
|
-
except AttributeError as ex:
|
|
47
|
-
continue
|
|
48
|
-
|
|
49
|
-
if not class_instance:
|
|
50
|
-
raise ValueError(f"The class/function '{name}' does not exist in 'sklearn' modules.")
|
|
58
|
+
module, class_instance = self._get_module_and_class_instance(name)
|
|
51
59
|
|
|
52
60
|
# If the attribute is a function, then return the function object.
|
|
53
61
|
if type(class_instance).__name__ == "function":
|
|
@@ -247,9 +255,86 @@ class Sklearn(_OpenSource):
|
|
|
247
255
|
"""
|
|
248
256
|
def __init__(self):
|
|
249
257
|
super().__init__()
|
|
250
|
-
self._modules =
|
|
258
|
+
self._modules = _SKL_MODULES
|
|
251
259
|
self._object_wrapper = _SkLearnObjectWrapper
|
|
252
260
|
self._function_wrapper = _SKLearnFunctionWrapper
|
|
253
261
|
|
|
254
262
|
|
|
263
|
+
class Lightgbm(_OpenSource):
|
|
264
|
+
"""
|
|
265
|
+
DESCRIPTION:
|
|
266
|
+
Interface object to access exposed classes and functions of lightgbm
|
|
267
|
+
opensource package. All the classes and functions can be run and attributes
|
|
268
|
+
can be accessed using the object created by "td_lightgbm" interface object.
|
|
269
|
+
Refer Teradata Python Package User Guide for more information about OpenML
|
|
270
|
+
and exposed interface objects.
|
|
271
|
+
|
|
272
|
+
PARAMETERS:
|
|
273
|
+
None
|
|
274
|
+
|
|
275
|
+
RETURNS:
|
|
276
|
+
None
|
|
277
|
+
|
|
278
|
+
EXAMPLES:
|
|
279
|
+
# Load example data.
|
|
280
|
+
>>> load_example_data("openml", ["test_classification"])
|
|
281
|
+
>>> df = DataFrame("test_classification")
|
|
282
|
+
>>> df.head(3)
|
|
283
|
+
col2 col3 col4 label
|
|
284
|
+
col1
|
|
285
|
+
-2.560430 0.402232 -1.100742 -2.959588 0
|
|
286
|
+
-3.587546 0.291819 -1.850169 -4.331055 0
|
|
287
|
+
-3.697436 1.576888 -0.461220 -3.598652 0
|
|
288
|
+
|
|
289
|
+
# Get the feature and label data.
|
|
290
|
+
>>> df_x = df.select(df.columns[:-1])
|
|
291
|
+
>>> df_y = df.select(df.columns[-1])
|
|
292
|
+
|
|
293
|
+
# Create lightgbm Dataset object.
|
|
294
|
+
>>> lgbm_data = td_lightgbm.Dataset(data=df_x, label=df_y, free_raw_data=False)
|
|
295
|
+
>>> lgbm_data
|
|
296
|
+
<lightgbm.basic.Dataset object at 0x7f33f0656820>
|
|
297
|
+
"""
|
|
298
|
+
|
|
299
|
+
def __init__(self):
|
|
300
|
+
super().__init__()
|
|
301
|
+
self._modules = _LIGHTGBM_MODULES
|
|
302
|
+
self._object_wrapper = _LightgbmDatasetWrapper
|
|
303
|
+
self._function_wrapper = _LightgbmFunctionWrapper
|
|
304
|
+
|
|
305
|
+
def __getattr__(self, name):
|
|
306
|
+
|
|
307
|
+
def __get_module(*c, **kwargs):
|
|
308
|
+
module, class_instance = self._get_module_and_class_instance(name)
|
|
309
|
+
|
|
310
|
+
# If the attribute is a function, then return the function object.
|
|
311
|
+
if type(class_instance).__name__ == "function":
|
|
312
|
+
kwargs.update(zip(class_instance.__code__.co_varnames, c))
|
|
313
|
+
|
|
314
|
+
if module == "lightgbm.callback":
|
|
315
|
+
return {"module": module, "func_name": name, "kwargs": kwargs}
|
|
316
|
+
|
|
317
|
+
return self._function_wrapper(module_name=module, func_name=name)(**kwargs)
|
|
318
|
+
|
|
319
|
+
kwargs.update(zip(class_instance.__init__.__code__.co_varnames[1:], c))
|
|
320
|
+
if module == "lightgbm.basic" and name == "Booster":
|
|
321
|
+
return _LightgbmBoosterWrapper(module_name=module, class_name=name, kwargs=kwargs)
|
|
322
|
+
|
|
323
|
+
if module == "lightgbm.sklearn":
|
|
324
|
+
return _LighgbmSklearnWrapper(module_name=module, class_name=name, kwargs=kwargs)
|
|
325
|
+
|
|
326
|
+
return self._object_wrapper(module_name=module, class_name=name, kwargs=kwargs)
|
|
327
|
+
|
|
328
|
+
return __get_module
|
|
329
|
+
|
|
330
|
+
def deploy(self, model_name, model, replace_if_exists=False):
|
|
331
|
+
raise NotImplementedError("The deploy() function is not yet supported for td_lightgbm. \
|
|
332
|
+
Support will be added in future releases.")
|
|
333
|
+
|
|
334
|
+
def load(self, model_name):
|
|
335
|
+
raise NotImplementedError("The load() function is not yet supported for td_lightgbm. \
|
|
336
|
+
Support will be added in future releases.")
|
|
337
|
+
|
|
338
|
+
|
|
255
339
|
td_sklearn = Sklearn()
|
|
340
|
+
td_lightgbm = Lightgbm()
|