Transitioning from v1 to v5
This section serves as a guide to transitioning from an older version of the TIM Python client to v5 of the TIM Python client. It does so by walking through plausible usage scenarios of the older versions and outlining how to replicate these scenarios with v5 of the Python client.
Loading a CSV dataset
This part looks specifically at using the TIM Python client load a CSV dataset to a Pandas DataFrame.
In older versions of the TIM Python client, this makes use of the following function:
tim_client.load_dataset_from_csv_file()
Since Pandas itself offers support for reading a CSV file into a DataFrame (with the read_csv
function), this functionality is no longer included in v5 of the TIM Python client. Datasets are expected in DataFrame format.
Forecasting
This part looks specifically at using the Python client to make use of TIM's forecasting capabilities.
InstantML
Using the TIM Python client for InstantML forecasting comes down to the scenario described as Case 1 in the documentation of older versions.
It makes use of the following functions:
api_client.prediction_build_model()
prediction = api_client.prediction_predict()
prediction_result = prediction.get_prediction()
Exactly replicating this approach with v5 of the TIM Python client is currently not possible, and should be emulated by the RTInstantML approach described below.
RTInstantML
Using the TIM Python client for RTInstantML forecasting comes down to the scenario described as Case 2 in the documentation of older versions.
It makes use of the following functions:
prediction = api_client.prediction_build_model_predict()
prediction.get_prediction()
Replicating this with v5 of the TIM Python client would go through the following steps:
- uploading the data to the TIM repository, using the
upload_dataset
function, - creating and executing a forecast job, using the
build_forecasting_model_and_execute
function.
Retrieving the results at a later time is possible too, using the get_forecast_results
function.
Another, potentially more similar approach to replicate this with v5 of the TIM Python client uses the clean_forecast
function, which uploads the dataset in the default workspace, creates a forecast job in this workspace, executes it, returns the results and deletes the dataset and job from the TIM Repository.
Anomaly Detection
This part looks specifically at using the Python client to make use of TIM's anomaly detection capabilities.
Using the TIM Python client for anomaly detection makes use of the following functions:
anomaly_detection_model = api_client.detection_build_model()
new_anomaly_detection_model = api_client.detection_rebuild_model()
anomaly_detection = api_client.detection_detect()
anomaly_detection.get_anomaly_indicator()
anomaly_detection.get_normal_behavior()
as described in the documentation of older versions.
Replicating this with v5 of the TIM Python client would go through the following steps:
- uploading the data to the TIM repository, using the
upload_dataset
function, - creating and executing an anomaly detection model building job (to build and apply an anomaly detection model), using the
build_anomaly_detection_model_and_execute
function, - creating and executing an anomaly detection detect job (to detect with an existing model), using the
create_anomaly_detection_and_execute
function.
Retrieving the results at a later time is possible too, using the get_anomaly_detection_results
function.
Rebuilding an anomaly detection model is currently not supported in v5 of the TIM Python client.