https://github.com/conect2ai/conect2py-package

Main repository for Conect2Py, a python package for online data compression in Internet of Things (IoT) devices.

https://github.com/conect2ai/conect2py-package

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: ieee.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.8%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Main repository for Conect2Py, a python package for online data compression in Internet of Things (IoT) devices.

Basic Info
  • Host: GitHub
  • Owner: conect2ai
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 282 MB
Statistics
  • Stars: 1
  • Watchers: 2
  • Forks: 1
  • Open Issues: 0
  • Releases: 0
Created over 2 years ago · Last pushed about 2 years ago
Metadata Files
Readme License

README.md

   

 

Conect2Ai - TAC python package

Conect2Py-Package is the name given for the Conect2ai Python software package. The package contains the implementation of TAC, an algorithm for data compression using TAC (Tiny Anomaly Compression). The TAC algorithm is based on the concept the data eccentricity and does not require previously established mathematical models or any assumptions about the underlying data distribution. Additionally, it uses recursive equations, which enables an efficient computation with low computational cost, using little memory and processing power.

version


Dependencies

bash Pandas, Numpy, Matplotlib, Seaborn, Scikit-learn, Ipython


Installation

You can download our package from the PyPi repository using the following command:

bash pip install conect2py

If you want to install it locally you download the Wheel distribution from Build Distribution.

First navigate to the folder where you downloaded the file and run the following command:

bash pip install conect2py-0.1.1-py3-none-any.whl


Usage Example

This usage example can be run on a Colab Notebook here Jupyter

To begin you can import conect2py using

```Python

FULL PACKAGE

import conect2py ```

Or try each of our implemented functionalities

```Python

MODEL FUNCTIONS

from conect2py.models import TAC from conect2py.models import AutoTAC

RUN FUNCTIONS

from conect2py.run.single import printrundetails, runsingleonline, runsingleoffline from conect2py.run.multiple import runmultipleinstances, getoptimalparams, displaymultirunoptimalvalues, runoptimal_combination

UTILS FUNCTIONS

from conect2py.utils.formatsave import createparamcombinations, createcompressorlist, createevaldf from conect2py.utils.metrics import getcompressionreport, printcompressionreport, calcstatistics from conect2py.utils.plots import plotcurvecomparison, plotdistcomparison, plotmultirunmetric_results

```

Running Multiple tests with TAC

  • Setting up the initial variables

```Python modelname = 'TACCompression'

params = { 'window_size': np.arange(2, 30, 1), 'm': np.round(np.arange(0.1, 2.1, 0.1), 2), }

paramcombination = createparamcombinations(params) compressorlist = createcompressorlist(param_combination) ```

  • Once you created the list of compressors you can run

Python result_df = run_multiple_instances(compressor_list=compressor_list, param_list=param_combination, series_to_compress=dataframe['sensor_data'].dropna(), cf_score_beta=2 )

  • This function returns a pandas Dataframe containing the results of all compression methods. You can expect something like:

| | param | reductionrate | reductionfactor | mse | rmse | nrmse | mae | psnr | ncc | cf_score | | - | --------- | -------------- | ---------------- | ------- | ------ | ------- | ------- | ------- | ------ | --------- | | 0 | (2, 0.1) | 0.4507 | 1.8204 | 0.0648 | 0.2545 | 0.0609 | 0.0127 | 39.9824 | 0.9982 | 0.8031 | | 1 | (2, 0.2) | 0.4507 | 1.8204 | 0.0648 | 0.2545 | 0.0609 | 0.0127 | 39.9823 | 0.9982 | 0.8031 | | 2 | (2, 0.3) | 0.4507 | 1.8204 | 0.0648 | 0.2545 | 0.0609 | 0.0127 | 39.9823 | 0.9982 | 0.8031 | | 3 | (2, 0.4) | 0.4508 | 1.8209 | 0.0648 | 0.2545 | 0.0609 | 0.0127 | 39.9824 | 0.9982 | 0.8032 | | 4 | (2, 0.5) | 0.4511 | 1.8217 | 0.0648 | 0.2545 | 0.0609 | 0.0128 | 39.9823 | 0.9982 | 0.8033 |

  • You can also check the optimal combination by running the following code:

Python display_multirun_optimal_values(result_df=result_df)

Parameter combinations for MAX CF_SCORE

              param    reduction_rate  reduction_factor     mse      rmse    nrmse  \
      440  (24, 0.1)          0.9224           12.8919    0.6085  0.7801  0.1867   

             mae    psnr     ncc    cf_score  
      440  0.1294  30.254  0.9825    0.9698

Parameter combinations for NEAR MAX CF_SCORE

        param  reduction_rate    reduction_factor     mse    rmse   nrmse  \
 521  (28, 0.2)          0.9336           15.0531  1.1504  1.0726  0.2567   
 364  (20, 0.5)          0.9118           11.3396  0.9458  0.9725  0.2328   
 262  (15, 0.3)          0.8810            8.4029  0.6337  0.7960  0.1905   
 363  (20, 0.4)          0.9102           11.1352  0.9084  0.9531  0.2281   
 543  (29, 0.4)          0.9372           15.9222  1.1474  1.0712  0.2564   

       mae     psnr     ncc     cf_score  
 521  0.1810  27.4883  0.9666    0.9598  
 364  0.1431  28.3388  0.9726    0.9598  
 262  0.0907  30.0780  0.9817    0.9598  
 363  0.1323  28.5140  0.9737    0.9603  
 543  0.1925  27.4996  0.9667    0.9607   

Visualize multirun results with a plot

  • By default this plot returns a visualization for the metrics reduction_rate, ncc and cf_score. Python plot_multirun_metric_results(result_df=result_df)
  • The result should look like this;

image


Running a single complession with the optimal parameter found

  • You don't need to run the visualization and the display_multirun_optimal_values in order to get the optimal compressor created, by running the following code it's possible to get the best result: Python optimal_param_list = get_optimal_params(result_df=result_df) print("Best compressor param combination: ", optimal_param_list)

  • With the list of optimal parameter (There is a possibility that multiple compressors are considered the best) run the function below to get get the compression result.

Python points_to_keep, optimal_results_details = run_optimal_combination(optimal_list=optimal_param_list, serie_to_compress=dataframe['sensor_data'].dropna(), model='TAC' )

  • If you want to see the result details use: Python print_run_details(optimal_results_details) > POINTS: > - total checked: 30889 > - total kept: 1199 > - percentage discaded: 96.12 % > > POINT EVALUATION TIMES (ms): > - mean: 0.003636738161744472 > - std: 0.15511020000857362 > - median: 0.0 > - max: 13.513565063476562 > - min: 0.0 > - total: 112.335205078125 > > RUN TIME (ms): > - total: 124.2864

Evaluating the Results

  • Now, to finish the process of the compression, you should follow the next steps:

1. Step - Create the evaluation dataframe:

Python evaluation_df = create_eval_df(original=dataframe['sensor_data'].dropna(), flag=points_to_keep) evaluation_df.info()

2. Step - Evaluate the performance:

```Python report = getcompressionreport( original=evaluationdf['original'], compressed=evaluationdf['compressed'], decompressed=evaluationdf['decompressed'], cfscore_beta=2 )

printcompressionreport( report, modelname=modelname, cfscorebeta=2, modelparams=optimalparam_list ) ```

After that you expect to see something like the following informations:

RUN INFO - Model: TAC_Compression - Optimal Params: [(24, 0.1)] - CF-Score Beta: 2

RESULTS

SAMPLES NUMBER reduction - Original length: 30889 samples - Reduced length: 1199 samples - Samples reduced by a factor of 25.76 times - Sample reduction rate: 96.12%

FILE SIZE compression - Original size: 385549 Bytes - Compressed size: 14974 Bytes - file compressed by a factor of 25.75 times - file compression rate: 96.12%

METRICS - MSE: 0.622 - RMSE: 0.7886 - NRMSE: 0.1888 - MAE: 0.1384 - PSNR: 30.1591 - NCC: 0.9821 - CF-Score: 0.9778

3. Step - Create the model visualizations:

```Python

plot the curves comparison (original vs decompressed)

plotcurvecomparison( evaluationdf.original, evaluationdf.decompressed, show=True )

```

And finally here is a example of the result:

image

Other Models

Please check the informations for more information about the other models been implemented in this package.

Literature reference

  1. Signoretti, G.; Silva, M.; Andrade, P.; Silva, I.; Sisinni, E.; Ferrari, P. "An Evolving TinyML Compression Algorithm for IoT Environments Based on Data Eccentricity". Sensors 2021, 21, 4153. https://doi.org/10.3390/s21124153

  2. Medeiros, T.; Amaral, M.; Targino, M; Silva, M.; Silva, I.; Sisinni, E.; Ferrari, P.; "TinyML Custom AI Algorithms for Low-Power IoT Data Compression: A Bridge Monitoring Case Study" - 2023 IEEE International Workshop on Metrology for Industry 4.0 & IoT (MetroInd4.0&IoT), 2023. 10.1109/MetroInd4.0IoT57462.2023.10180152

License

This package is licensed under the MIT License - 2023 Conect2ai.

Owner

  • Name: conect2ai
  • Login: conect2ai
  • Kind: organization

GitHub Events

Total
Last Year

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 14 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 8
  • Total maintainers: 1
pypi.org: conect2py-pckg

A python library for data compression using TAC (Tiny Anomaly Compression)

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 9.2%
Average: 38.7%
Dependent repos count: 68.2%
Maintainers (1)
Last synced: almost 2 years ago
pypi.org: conect2py-package

A python library for data compression using TAC (Tiny Anomaly Compression)

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 9.2%
Average: 38.7%
Dependent repos count: 68.2%
Maintainers (1)
Last synced: almost 2 years ago
pypi.org: conect2py

A python library for data compression using TAC (Tiny Anomaly Compression)

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 14 Last month
Rankings
Dependent packages count: 9.3%
Average: 38.7%
Dependent repos count: 68.2%
Maintainers (1)
Last synced: 10 months ago