https://github.com/conect2ai/conect2py-package
Main repository for Conect2Py, a python package for online data compression in Internet of Things (IoT) devices.
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
Repository
Main repository for Conect2Py, a python package for online data compression in Internet of Things (IoT) devices.
Basic Info
Statistics
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
- Releases: 0
Metadata Files
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.
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
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.9698Parameter 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,nccandcf_score.Python plot_multirun_metric_results(result_df=result_df) - The result should look like this;
Running a single complession with the optimal parameter found
You don't need to run the visualization and the
display_multirun_optimal_valuesin 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:
Other Models
Please check the informations for more information about the other models been implemented in this package.
Literature reference
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
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
- Repositories: 1
- Profile: https://github.com/conect2ai
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)
- Homepage: https://github.com/conect2ai/Conect2Py-Package
- Documentation: https://conect2py-pckg.readthedocs.io/
- License: MIT License
- Status: removed
-
Latest release: 0.1.1
published over 2 years ago
Rankings
Maintainers (1)
pypi.org: conect2py-package
A python library for data compression using TAC (Tiny Anomaly Compression)
- Homepage: https://github.com/conect2ai/Conect2Py-Package
- Documentation: https://conect2py-package.readthedocs.io/
- License: MIT License
- Status: removed
-
Latest release: 0.1.0
published over 2 years ago
Rankings
Maintainers (1)
pypi.org: conect2py
A python library for data compression using TAC (Tiny Anomaly Compression)
- Homepage: https://github.com/conect2ai/Conect2Py-Package
- Documentation: https://conect2py.readthedocs.io/
- License: MIT License
-
Latest release: 0.1.4
published about 2 years ago