portalytics
Portable Jupyter Setup for Machine Learning.
A consistent interface for creating Machine Learning Models compatible with VisualFabriq environment.
Build models using our portalytics module. The module is available as pip package, install simply by:
pip install vf-portalytics
Pay attention to the requirements because it is important for the model to be built with the ones that we support.
There are examples of how you can use portalytics. Examples for a simple model or more complex models like MultiModel.
Make sure that after saving the model using portalyctis, its possible that the model can be loaded and still contains all the important information (eg. the loaded model is able to perform a prediction?)
MultiModel and MultiTransformer
MultiModel is a custom sklearn model that contains one model for each group of training data. It is valuable in cases that our dataset vary a lot, but we still need to manage one model because the problem is the same.
-
Define the groups using input parameter
clusterswhich is a list of all possible groups andgroup_colwhich is a string that indicates in which feature the groups can be found. -
selected_featuresgive the ability of using different features for each group. -
paramsgive the ability of using different model and categorical-feature transformer for each group.
The Jupyter notebook multimodel_example.ipynb contains an end-to-end example of how MultiModel can be trained and saved using vf_portalytics Model wrapper.
MultiModel can support every sklearn based model, the only thing that is need to be done is to extend
POTENTIAL_MODELS dictionary. Feel free to raise a PR.
MultiTransformer is the transformer that is being used inside MultiModel to transform categorical features into numbers. It is a custom sklearn transformer that contains one transformer for each group of training data.
- Can be used also separately, in the same way as MultiModel. Check example
MultiTransformer can support every sklearn based transformer, the only thing that is need to be done is to extend
POTENTIAL_TRANSFORMER dictionary. Feel free to raise a PR.
Model
Model is a wrapper for ML models to make the model more portable and easier to use inside Visualfabriq environment.
import numpy as np
import pandas as pd
from sklearn.dummy import DummyRegressor
from vf_portalytics.model import PredictionModel
model_name = 'test_model'
prediction_model = PredictionModel(model_name, '.')
train_df = pd.DataFrame({
'baseline_units': [800, 700],
'promotion_technical_id': ['promotion_id_1', 'promotion_id_1'],
'promotion_type': [1, 2],
'promotion_ext_id': [1, 1],
'account_id': ['pa_1', 'pa_1'],
'pid': ['pid_1', 'pid_2']
})
dummy_regression = DummyRegressor(strategy="mean")
dummy_regression.fit(train_df, np.array([1800, 1700]))
prediction_model.features = {
'baseline_units': [],
'total_baseline_units': [],
'total_nr_products': [],
'base_price': [],
'discount_perc': [],
'discount_amt': [],
'account_id': [],
}
prediction_model.model = dummy_regression
prediction_model.save()
The save function will generate 2 files: test_model.pkl and test_model.meta in the current directory. These are the files needed to load the model and make predictions inside Visualfabriq environment.
For more details check the example of how to use the model wrapper.
Metadata
Release files for vf-portalytics 2.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| vf_portalytics-2.1.2.tar.gz | 62.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vf_portalytics-2.1.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 135.0 kB
Release files / vf_portalytics-2.1.2.tar.gz
| Download URL | vf_portalytics-2.1.2.tar.gz |
|---|---|
| Size | 62.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d40be038ce0196c070b9104a56796133d9c10e3cdfd842f09763d694f43000a
|
|
BLAKE2b-256 checksum How to use checksums |
0b185026f086cdb67f1b48d69301650e5d7262639ec7133bdd17dc7820b5adc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / vf_portalytics-2.1.2-py2.py3-none-any.whl
| Download URL | vf_portalytics-2.1.2-py2.py3-none-any.whl |
|---|---|
| Size | 72.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a0d99d96c47e793e60256b0d05c351739fd11403accd258d9204e2e286fb72e2
|
|
BLAKE2b-256 checksum How to use checksums |
4be162fa9b53f6136c6d8903dbe59c16f030ab7eb07f105dacfbe9efd970a9d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Security for vf-portalytics 2.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.