Skip to main content

Python client for oka repository

Project description

test codecov pypi Python version license: GPL v3

DOI arXiv User Manual API Documentation

oka - Client for OKA repository

Latest version as a package

Current code

User manual

API documentation

Overview

oka is a client for Oka repository. It also provides utilities to process data.

Installation

...as a standalone lib

# Set up a virtualenv. 
python3 -m venv venv
source venv/bin/activate

# Install from PyPI...
pip install --upgrade pip
pip install -U oka
pip install -U oka[full]  # use the flag 'full' for extra functionality (recommended)

# ...or, install from updated source code.
pip install git+https://github.com/rabizao/oka

...from source

sudo apt install python3.8-venv python3.8-dev python3.8-distutils # For Debian-like systems.
git clone https://github.com/rabizao/oka
cd oka
python3.8 -m venv venv
source venv/bin/activate
pip install -e .

Usage

Hello world

from oka import Oka, generate_token, toy_df

# Create a pandas dataframe.
df = toy_df()
print(df.head())
"""
   attr1  attr2  class
0    5.1    6.4      0
1    1.1    2.5      1
2    6.1    3.6      0
3    1.1    3.5      1
4    3.1    2.5      0
"""
# Login.
token = generate_token("http://localhost:5000")
client = Oka(token, "http://localhost:5000")

# Store.
id = client.send(df)

# Store again.
id = client.send(df)
"""
Content already stored for id iJ_e4463c51904e9efb800533d25082af2a7bf77
"""

# Fetch.
df = client.get(id)

print(df.head())
"""
   attr1  attr2  class
0    5.1    6.4      0
1    1.1    2.5      1
2    6.1    3.6      0
3    1.1    3.5      1
4    3.1    2.5      0
"""

DataFrame by hand

import pandas as pd
from oka import Oka, generate_token

# Create a pandas dataframe.
df = pd.DataFrame(
    [[1, 2, "+"],
     [3, 4, "-"]],
    index=["row 1", "row 2"],
    columns=["col 1", "col 2", "class"],
)
print(df.head())
"""
       col 1  col 2 class
row 1      1      2     +
row 2      3      4     -
"""
# Login.
token = generate_token("http://localhost:5000")
client = Oka(token, "http://localhost:5000")

# Store.
id = client.send(df)

# Store again.
id = client.send(df)
"""
Content already stored for id f7_6b9deafec2562edde56bfdc573b336b55cb16
"""

# Fetch.
df = client.get(id)

print(df.head())
"""
       col 1  col 2 class
row 1      1      2     +
row 2      3      4     -
"""

Machine Learning workflow

import json

from sklearn.ensemble import RandomForestClassifier as RF

from idict import let, idict
from idict.function.classification import fit, predict
from idict.function.evaluation import split
from oka import Oka, generate_token

# Login.
token = generate_token("http://localhost:5000")
cache = Oka(token, "http://localhost:5000")
d = (
        idict.fromtoy()
        >> split
        >> let(fit, algorithm=RF, config={"n_estimators": 55}, Xin="Xtr", yin="ytr")
        >> let(predict, Xin="Xts")
        >> (lambda X: {"X2": X * X, "_history": ...})
        >> [cache]
)
cache.send(d)
print(json.dumps(list(d.history.keys()), indent=2))
"""
ssssssssssssssssssssssssssssssssssssssss
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
----setitem-------------------
444444444444444444444444
3333333333333333333333333
[
  "split----------------------sklearn-1.0.1",
  "fit--------------------------------idict",
  "predict----------------------------idict",
  "RwMG040tZc3XNoJkwkBe6A1aIUGNQ4EAQVqi.uAl"
]
"""
#
# d.show()
#
# print(d.z)
#
# d.show()
#
# # A field '_' means this function is a noop process triggered only once by accessing one of the other provided fields."
# d >>= (lambda _, X2, y: print("Some logging/printing that doesn't affect data...\nX²=\n", X2[:3]))
# d.show()
#
# print("Triggering noop function by accessing 'y'...")
# print("y", d.y[:3])
#
# d.show()
#
# # The same workflow will not be processed again if the same cache is used.
# d = (
#         idict.fromtoy()
#         >> split
#         >> let(fit, algorithm=RF, config={"n_estimators": 55}, Xin="Xtr", yin="ytr")
#         >> let(predict, Xin="Xts")
#         >> (lambda X: {"X2": X * X})
#         >> (lambda _, X2, y: print("Some logging/printing that doesn't affect data...", X2.head()))
#         >> [cache]
# )
# d.show()
#
# cache.send(d)
#
# d = cache.get(d.id)
# d.show()

More info

Aside from the papers on identification and on similarity (not ready yet), the PyPI package and GitHub repository,

A lower level perspective is provided in the API documentation.

Grants

This work was supported by Fapesp under supervision of Prof. André C. P. L. F. de Carvalho at CEPID-CeMEAI (Grants 2013/07375-0 – 2019/01735-0).

.>>>>>>>>> outros <<<<<<<<<<<.

Project details


Download files

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

Source Distribution

oka-0.211202.4.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oka-0.211202.4-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file oka-0.211202.4.tar.gz.

File metadata

  • Download URL: oka-0.211202.4.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.8.10 Linux/5.4.0-89-generic

File hashes

Hashes for oka-0.211202.4.tar.gz
Algorithm Hash digest
SHA256 691625eff2b162e7cfa028c5fdc7073f34f0017df97d3def3162936e3dee088e
MD5 29b2e572a3701b88d0a68f714e311cfc
BLAKE2b-256 9f9ec973ae6b587a70a948bdb5c1542d08b58de06b4ce1caef24ecbd86018357

See more details on using hashes here.

File details

Details for the file oka-0.211202.4-py3-none-any.whl.

File metadata

  • Download URL: oka-0.211202.4-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.8.10 Linux/5.4.0-89-generic

File hashes

Hashes for oka-0.211202.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d7ecd6b828b98ac1c0ec4b46c105c8b03031b057170a6a13efad9c94db440bab
MD5 7513c7a3498625dc8699d4a40e2a6a89
BLAKE2b-256 fc38efc2f1d393c27cdaae25e4ec358e2947c76d528e2762b33ba3c7a18b54d3

See more details on using hashes here.

Supported by

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