Skip to main content

airt client

Project description

Python client for airt service (beta)

A python library encapsulating airt service REST API available at:

Docs

Full documentation can be found at the following link:

How to install

If you don't have the airt library already installed, please install it using pip.

pip install airt-client

How to use

Before you can use the service, you must acquire a username and password for your developer account. Please fill in the following form to get one:

The username, password, and server address can be passed explicitly while calling the authenticate method in the Client class or stored permanently in environment variables AIRT_SERVICE_USERNAME, AIRT_SERVICE_PASSWORD, and AIRT_SERVER_URL respectively.

Upon successful authentication, the airt services will be available to access.

Below is a minimal example explaining how to train a model and make predictions using airt services. The below example assumes the username, password, and server address required for authenticating the Client is stored in the environment variables AIRT_SERVICE_USERNAME, AIRT_SERVICE_PASSWORD, and AIRT_SERVER_URL respectively.

For more information, please check:

  • Tutorial with more elaborate example, and

  • API with reference documentation.

0. Authenticate

from airt.client import Client, DataSource

Client.authenticate()

1. Connect data

data_source_s3 = DataSource.s3(
    uri="s3://test-airt-service/ecommerce_behavior"
)

data_source_s3.pull().progress_bar()
print(data_source_s3.head())
100%|██████████| 1/1 [00:35<00:00, 35.39s/it]


                  event_time event_type  product_id          category_id  \
0  2019-11-01T00:00:00+00:00       view     1003461  2053013555631882655   
1  2019-11-01T00:00:00+00:00       view     5000088  2053013566100866035   
2  2019-11-01T00:00:01+00:00       view    17302664  2053013553853497655   
3  2019-11-01T00:00:01+00:00       view     3601530  2053013563810775923   
4  2019-11-01T00:00:01+00:00       view     1004775  2053013555631882655   

               category_code   brand   price    user_id  \
0     electronics.smartphone  xiaomi  489.07  520088904   
1  appliances.sewing_machine  janome  293.65  530496790   
2                       None   creed   28.31  561587266   
3  appliances.kitchen.washer      lg  712.87  518085591   
4     electronics.smartphone  xiaomi  183.27  558856683   

                           user_session  
0  4d3b30da-a5e4-49df-b1a8-ba5943f1dd33  
1  8e5f4f83-366c-4f70-860e-ca7417414283  
2  755422e7-9040-477b-9bd2-6a6e8fd97387  
3  3bfb58cd-7892-48cc-8020-2f17e6de6e7f  
4  313628f1-68b8-460d-84f6-cec7a8796ef2  

2. Train

from datetime import timedelta

model = data_source_s3.train(
    client_column="user_id",
    target_column="event_type",
    target="*purchase",
    predict_after=timedelta(hours=3),
)
model.progress_bar()
print(model.evaluate())
100%|██████████| 5/5 [00:00<00:00, 112.87it/s]

            eval
accuracy   0.985
recall     0.962
precision  0.934

3. Predict

predictions = model.predict()
predictions.progress_bar()
print(predictions.to_pandas().head())
100%|██████████| 3/3 [00:00<00:00, 72.70it/s]

              Score
user_id            
520088904  0.979853
530496790  0.979157
561587266  0.979055
518085591  0.978915
558856683  0.977960

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

airt-client-2021.10.1rc3.tar.gz (25.5 kB view hashes)

Uploaded Source

Built Distribution

airt_client-2021.10.1rc3-py3-none-any.whl (26.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page