Skip to main content

A library to calculate power, energy, and training time of machine learning algorithms

Project description

EnergyEfficientAI

Overview

The EnergyEfficientAI Library provides a framework for training machine learning models while monitoring CPU and memory utilization. This library is particularly useful for understanding the energy consumption of various machine learning algorithms during training and inference. By tracking system performance metrics, users can make informed decisions about model efficiency and power consumption.

Features

  • Monitor CPU and memory utilization during model training.
  • Calculate power and energy consumption based on system performance.
  • Generate detailed reports including training metrics and classification results.
  • Visualize CPU utilization with modern, aesthetically pleasing line graphs.

Installation

To use this library, you need to have Python 3.x installed along with the following dependencies:

  • numpy
  • psutil
  • scikit-learn
  • matplotlib
  • seaborn

You can install the required packages using pip:

pip install numpy psutil scikit-learn matplotlib seaborn

You can install the library using pip:

pip install EnergyEfficientAI

How to use in Code

import numpy as np
from sklearn.datasets import fetch_openml
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from EnergyEfficientAI import EnergyConsumptionML  # Import the class from the file

mnist = fetch_openml(data_id=554)

# Load MNIST data
# mnist = fetch_openml('mnist_784', as_frame=True)
X, y = mnist.data.astype('float32').to_numpy(), mnist.target.astype('int')

# Flatten the images
X_flatten = np.array([image.flatten() for image in X])

# Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X_flatten, y, test_size=0.2, random_state=42)

# Define the model (you can pass any model here)
logreg_model = LogisticRegression()
cpuIdl = 70
cpuFull = 170
# Instantiate the CustomModelTrainer with the model
model_trainer = EnergyConsumptionML(logreg_model, cpuIdl, cpuFull)

# Generate the final report by calling generate_report
model_trainer.generate_report(X_train, y_train, X_test, y_test)
model_trainer.plot_cpu_usage()

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

EnergyEfficientAI-0.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

EnergyEfficientAI-0.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file EnergyEfficientAI-0.2.tar.gz.

File metadata

  • Download URL: EnergyEfficientAI-0.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for EnergyEfficientAI-0.2.tar.gz
Algorithm Hash digest
SHA256 609b55acea37467886bc59f454b99d220d85cf3e19f87e485c7268a5cf06ecc8
MD5 e587011cea7ff6070d4ca6368c76cca2
BLAKE2b-256 cc2cb37dc8b115f583fcf437754586109268ed9c50b084f31f4179138d9a1a84

See more details on using hashes here.

File details

Details for the file EnergyEfficientAI-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for EnergyEfficientAI-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5ddd5b1512529f5a01a07afef59b6460efa0c3cb366ec9b0ceb8ca0acb1a78e5
MD5 3e99b4c55d21cc71101a8c6b95f7aa83
BLAKE2b-256 bc712a57b2363f53d24f108299aa7d92fcbd29b9b4e293adc5aa4de2f57c7fd1

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