Skip to main content

Assist small-scale machine learning.

Project description

learning-utility

Assist small-scale machine learning.

learning-utility is a package of utilities for small-scale machine learning tasks with scikit-learn.

image image PyPI - Python Version Downloads PyPI

Installation

pip install Lutil

Key Features

Cache Intermediate Results

InlineCheckpoint can cache the computation result in the first call. Since then, if nothing has changed, it retrieves the cache and skips computation.

Suppose you have such a .py file.

from Lutil.checkpoints import InlineCheckpoint

a, b = 1, 2
with InlineCheckpoint(watch=["a", "b"], produce=["c"]):
   print("Heavy computation.")
   c = a + b

print(c)

Run the script, you will get:

Heavy computation.
3

Run this script again, the with-statement will be skipped. You will get:

3

Once a value among watch changes or the code inside the with-statement changes, re-calculation takes place to ensure the correct output.

Save Prediction Result According to the Given Format

Lots of machine learning competitions require a .csv file in a given format. Most of them provide an example file.

In example.csv:

id, pred
1, 0.25
2, 0.45
3, 0.56

Run:

>>> import numpy as np
>>> from Lutil.dataIO import AutoSaver

>>> result = np.array([0.2, 0.4, 0.1, 0.5])
       # Typical output of a scikit-learn predictor

>>> ac = AutoSaver(save_dir="somedir", example_path="path/to/example.csv")
>>> ac.save(result, "some_name.csv")

Then in your somedir/some_name.csv:

id, pred
1, 0.2
2, 0.4
3, 0.1
4, 0.5

It also works if the result is a pandas DataFrame, Series, 2-dim numpy array, etc. Also, the encoding, seperator, header, index of the example.csv will all be recognized.

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

Lutil-0.1.8.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

Lutil-0.1.8-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file Lutil-0.1.8.tar.gz.

File metadata

  • Download URL: Lutil-0.1.8.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for Lutil-0.1.8.tar.gz
Algorithm Hash digest
SHA256 03006e5db421145874b91a32e476bf50aedee5366dc558eced4c73dd3f17bfdb
MD5 f1336078ca92cb7baf711f1239fc5885
BLAKE2b-256 345ac4dc1d24e87db70e79de60d3cf5e6c540d52a30cda60f6a5b10bc74f623d

See more details on using hashes here.

File details

Details for the file Lutil-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: Lutil-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for Lutil-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 e02e56f90e1eae5812e9568ae0d0a7320ffaf31b2cb914c5fb575f34328907c0
MD5 336e2c438e8a15c20509c59fcd973151
BLAKE2b-256 f141dda265f7d0c16444f328028640c6fba763c1cfb9958b0ba41ec3b8f155fb

See more details on using hashes here.

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