A framework for data management and is used to do data science and machine learning's pipelines
Project description
Overview
Dama ML is a framework for data management and is used to do data science and machine learning’s pipelines, also dama-ml try to unify diverse data sources like csv, sql db, hdf5, zarr, etc, and also unify machine learning frameworks (sklearn, Keras, LigthGBM, etc) with a simplify interface.
For more detail read the docs.
Warning
Although, the API is stable this work is in alpha steps and there are methods that have limited functionality or aren’t implemented.
Installation
git clone https://github.com/elaeon/dama_ml.git
pip install dama_ml/
or
pip install DaMa-ML
You can install the python dependences with pip, but we strongly recommend install the dependences with conda and conda forge.
conda config --add channels conda-forge
conda create -n new_environment --file dama_ml/requirements.txt
conda activate new_environment
pip install DaMa-ML
Quick start
Configure the data paths where all data will be saved. This can be done with help of dama_ml cli tools.
$ dama-cli config --edit
This will display a nano editor where you can edit data_path, models_path, code_path, class_path and metadata_path.
data_path is where all datasets are saved.
models_path is where all files from your models are saved.
code_path is the repository of code. (In development)
metadata_path is where the metadata database is saved.
Building a dataset
from dama.data.ds import Data
from dama.drivers.core import Zarr, HDF5
import numpy as np
array_0 = np.random.rand(100, 1)
array_1 = np.random.rand(100,)
array_2 = np.random.rand(100, 3)
array_3 = np.random.rand(100, 6)
array_4 = (np.random.rand(100)*100).astype(int)
array_5 = np.random.rand(100).astype(str)
with Data(name=name, driver=Zarr(mode="w")) as data:
data.from_data({"x": array_0, "y": array_1, "z": array_2, "a": array_3, "b": array_4, "c": array_5})
We can use a regression model, in this case we use RandomForestRegressor
from dama.reg.extended.w_sklearn import RandomForestRegressor
from dama.utils.model_selection import CV
data.driver.mode = "r" # we changed mode "w" to "r" to not overwrite the data previously saved
with data, Data(name="test_from_hash", driver=HDF5(mode="w")) as ds:
cv = CV(group_data="x", group_target="y", train_size=.7, valid_size=.1) # cross validation class
stc = cv.apply(data)
ds.from_data(stc, from_ds_hash=data.hash)
reg = RandomForestRegressor()
model_params = dict(n_estimators=25, min_samples_split=2)
reg.train(ds, num_steps=1, data_train_group="train_x", target_train_group='train_y',
data_test_group="test_x", target_test_group='test_y', model_params=model_params,
data_validation_group="validation_x", target_validation_group="validation_y")
reg.save(name="test_model", model_version="1")
Using RandomForestRegressor to do predictions is like this:
with RandomForestRegressor.load(model_name="test_model", model_version="1") as reg:
for pred in reg.predict(data):
prediction = pred.batch.to_ndarray()
CLI
dama-ml has a CLI where you can view your datasets and models. For example
dama-cli datasets
Return a table of datasets previously saved.
Using metadata ..../metadata/metadata.sqlite3
Total 2 / 2
hash name driver group name size num groups datetime UTC
--------------------- -------------- -------- ------------ -------- ------------ -------------------
sha1.3124d5f16eb0e... test_from_hash HDF5 s/n 9.12 KB 6 2019-02-27 19:39:00
sha1.e832f56e33491... reg0 Zarr s/n 23.68 KB 6 2019-02-27 19:39:00
dama-cli models
Total 3 / 3
from_ds name group_name model version score name score
------------------------- ---------- ------------ ------------------------------------------------- --------- --------------- ----------
sha1.d8ff5a342d2d7229... test_model s/n dama.reg.extended.w_sklearn.RandomForestRegressor 1 mse 0.162365
sha1.d8ff5a342d2d7229... test_model s/n dama.reg.extended.w_sklearn.RandomForestRegressor 1 msle 0.0741331
sha1.d8ff5a342d2d7229... test_model s/n dama.reg.extended.w_sklearn.RandomForestRegressor 1 gini_normalized -0.307407
You can use “–help” for view more options.
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
Built Distribution
File details
Details for the file DaMa ML-1.0a1.tar.gz
.
File metadata
- Download URL: DaMa ML-1.0a1.tar.gz
- Upload date:
- Size: 698.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 588c66919ad0a601b06333a9ae6fa8805ea55a6990f87ec2b497588cefdeec45 |
|
MD5 | 60a91f0222db942225f4141fc6c3e3b1 |
|
BLAKE2b-256 | 2350ae01536d28a1ef40c9642bb1f6a119e33a4681a6e78fc9723ad294d8077e |
File details
Details for the file DaMa_ML-1.0a1-py3-none-any.whl
.
File metadata
- Download URL: DaMa_ML-1.0a1-py3-none-any.whl
- Upload date:
- Size: 74.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44bdd248fd599a1066052ecefb03bad98c38a579fb634f4625565987b4f6b1d7 |
|
MD5 | 67a790e6d016bb44cb2f60ccf67cea5c |
|
BLAKE2b-256 | 44c6668bfeb58731161cc957271ef62712467dac6313eba799a63b97f6b62f28 |