Skip to content

Insurance With Remote Worker

Insurance Sample SDK Usage with Remote Worker

Scenario: Process on the Notebook

  1. Open Jupyter Notebook

  2. Create json for worker and connection.(Json generation code coming soon)

  3. The Worker json file must contain the following configurations:
  4. Service url, worker_size, worker_image, email, and refresh_token

  5. The Connection json file must contain the following configurations:

  6. Connection_type, ws_uuid, ws_name, and file_path

  7. Encoding categorical variables

  8. Delete the originals of the columns you encoded

  9. Run the process and kill processing when finished

Create a new worker with practicuscore method of "create_worker" and use this new worker for your operations

worker_conf = {
    "worker_size": "Medium",
    "worker_image": "practicus",
    #"service_url": "",
    #"email": "",
    #"refresh_token": "**entry_your_token**"
}
import practicuscore as prt

worker = prt.create_worker(worker_conf)
  • To access the dataset you need to work with connection configuration dictionary
  • Also, you can choose a different Engine than Advance in the Deploy phase
# configuration of connection

data_set_conn = {
    "connection_type": "WORKER_FILE",
    "file_path": "/home/ubuntu/samples/insurance.csv"
}
proc = worker.load(data_set_conn, engine='AUTO') 

Data prep with Practicus ai SDK

proc.categorical_map(column_name='sex', column_suffix='category') 
proc.categorical_map(column_name='smoker', column_suffix='category') 
proc.categorical_map(column_name='region', column_suffix='category') 
proc.delete_columns(['region', 'smoker', 'sex']) 
proc.wait_until_done(timeout_min=600)
proc.show_logs()
df = proc.get_df_copy()
display(df)

Finish the process

proc.kill()

You can also prepare this code directly in pipeline:

If you make the process functional and do it with with, you don't need to kill the worker when the process is finished. The worker is automatically killed when this process is finished
with prt.create_worker(worker_conf) as worker: 
    with worker.load(data_set_conn) as proc:
        proc.categorical_map(column_name='sex', column_suffix='category'), 
        proc.categorical_map(column_name='smoker', column_suffix='category'),
        proc.categorical_map(column_name='region', column_suffix='category'),
        proc.delete_columns(['region', 'smoker', 'sex']) 
        proc.wait_until_done(timeout_min=600)
        proc.show_logs()

Previous: Insurance | Next: Spark Custom Config