Comprehensive AI/ML library integrating machine learning, computer vision, audio processing, and conversational AI
Project description
Gurulearn
A unified AI/ML toolkit for deep learning, computer vision, audio processing, and conversational AI.
Built with lazy loading for minimal import overhead (~0.001s). Production-ready with type hints.
📦 Installation
pip install gurulearn # Core only
pip install gurulearn[vision] # + PyTorch image classification
pip install gurulearn[audio] # + TensorFlow audio recognition
pip install gurulearn[agent] # + LangChain RAG agent
pip install gurulearn[full] # All features
🖼️ ImageClassifier
PyTorch-based image classification with 9 model architectures.
Data Loading Options
from gurulearn import ImageClassifier
clf = ImageClassifier()
# Option 1: From directory structure (data/train/{class_name}/*.jpg)
model, history = clf.train(train_dir="data/train", test_dir="data/test")
# Option 2: From CSV file
model, history = clf.train(
csv_file="data.csv",
img_column="image_path",
label_column="class"
)
Training Parameters
model, history = clf.train(
train_dir="data/train",
epochs=20,
batch_size=32,
model_name="resnet50", # See models below
finetune=True, # Finetune all layers
learning_rate=0.001,
use_amp=True, # Mixed precision (GPU)
save_path="model.pth"
)
Available Models
| Model | Best For | Parameters |
|---|---|---|
simple_cnn |
Small datasets (<1K) | 3M |
vgg16 |
General purpose | 138M |
resnet50 |
Large datasets | 25M |
mobilenet |
Mobile deployment | 3.5M |
inceptionv3 |
Fine-grained | 23M |
densenet |
Feature reuse | 8M |
efficientnet |
Accuracy/size balance | 5M |
convnext |
Modern CNN | 28M |
vit |
Vision Transformer | 86M |
Prediction
# Load saved model
clf.load("model.pth", model_name="resnet50")
# Single image prediction
result = clf.predict("image.jpg", top_k=3)
print(result.class_name) # "cat"
print(result.probability) # 0.95
print(result.top_k) # [("cat", 0.95), ("dog", 0.03), ...]
# From PIL Image
from PIL import Image
result = clf.predict(image=Image.open("image.jpg"))
# Export for production
clf.export_onnx("model.onnx")
🎵 AudioRecognition
TensorFlow/Keras CNN-LSTM for audio classification.
Data Loading
from gurulearn import AudioRecognition
audio = AudioRecognition(sample_rate=16000, n_mfcc=20)
# From directory structure (data/{class_name}/*.wav)
# Supports: .wav, .mp3, .flac, .ogg, .m4a
history = audio.audiotrain(
data_path="data/audio",
epochs=50,
batch_size=32,
augment=True, # Time stretch, pitch shift, noise
model_dir="models"
)
Training Output
models/audio_recognition_model.keras- Trained modelmodels/label_mapping.json- Class labelsmodels/confusion_matrix.png- Evaluation plotmodels/training_history.png- Loss/accuracy curves
Prediction
# Single file
result = audio.predict("sample.wav", model_dir="models")
print(result.label) # "speech"
print(result.confidence) # 0.92
print(result.all_probabilities) # [0.92, 0.05, 0.03]
# Batch prediction
results = audio.predict_batch(
["file1.wav", "file2.wav"],
model_dir="models"
)
📊 MLModelAnalysis
AutoML for regression and classification with 10+ algorithms.
Data Loading
from gurulearn import MLModelAnalysis
ml = MLModelAnalysis(
task_type="auto", # "auto", "regression", "classification"
auto_feature_engineering=True # Extract date features
)
# From CSV
result = ml.train_and_evaluate(
csv_file="data.csv",
target_column="price",
test_size=0.2,
model_name=None, # Auto-select best model
save_path="model.joblib"
)
Available Models
Regression: linear_regression, decision_tree, random_forest, gradient_boosting, svm, knn, ada_boost, mlp, xgboost, lightgbm
Classification: logistic_regression, decision_tree, random_forest, gradient_boosting, svm, knn, ada_boost, mlp, xgboost, lightgbm
*Optional dependencies
Prediction
# Load and predict
ml.load_model("model.joblib")
# From dictionary
prediction = ml.predict({"feature1": 42, "category": "A"})
# From DataFrame
predictions = ml.predict(test_df)
# Compare all models
comparison = ml.compare_models("data.csv", "target", cv=5)
💬 FlowBot
Guided conversation flows with real-time data filtering.
Data Loading
from gurulearn import FlowBot
import pandas as pd
# From DataFrame
bot = FlowBot(pd.read_csv("hotels.csv"), data_dir="user_sessions")
# From list of dicts
bot = FlowBot([
{"city": "Paris", "price": "$$$", "name": "Le Grand"},
{"city": "Tokyo", "price": "$$", "name": "Sakura Inn"}
])
Building Flows
# Add filter steps
bot.add("city", "Select destination:", required=True)
bot.add("price", "Choose budget:")
# Define output columns
bot.finish("name", "price")
# Validate flow
errors = bot.validate()
Processing & Prediction
# Process user input (maintains session state)
response = bot.process("user123", "Paris")
# Response structure
{
"message": "Choose budget:",
"suggestions": ["$$$", "$$"],
"completed": False
}
# Final response
{
"completed": True,
"results": [{"name": "Le Grand", "price": "$$$"}],
"message": "Found 1 matching options"
}
# Async support
response = await bot.aprocess("user123", "Paris")
# Export history
history_df = bot.export_history("user123", format="dataframe")
🤖 QAAgent
RAG-based question answering with LangChain + Ollama.
Data Loading
from gurulearn import QAAgent
import pandas as pd
# From DataFrame
agent = QAAgent(
data=pd.read_csv("docs.csv"),
page_content_fields=["title", "content"],
metadata_fields=["category", "date"],
llm_model="llama3.2",
embedding_model="mxbai-embed-large",
db_location="./vector_db"
)
# From list of dicts
agent = QAAgent(
data=[{"title": "Policy", "content": "..."}],
page_content_fields="content"
)
# Load existing index (no data needed)
agent = QAAgent(db_location="./existing_db")
Querying
# Simple query
answer = agent.query("What is the refund policy?")
# With source documents
result = agent.query("What is the refund policy?", return_sources=True)
print(result["answer"])
print(result["sources"])
# Direct similarity search (no LLM)
docs = agent.similarity_search("refund", k=5)
# Interactive mode
agent.interactive_mode()
# Add more documents
agent.add_documents(new_df, "content", ["category"])
🏥 CTScanProcessor
Medical image enhancement with quality metrics.
Processing
from gurulearn import CTScanProcessor
processor = CTScanProcessor(
kernel_size=5,
clip_limit=2.0,
tile_grid_size=(8, 8)
)
# Single image - supports .jpg, .png, .dcm, .nii
result = processor.process_ct_scan(
"scan.jpg",
output_folder="output/",
compare=True # Save side-by-side comparison
)
# Batch processing
results = processor.process_batch(
input_folder="scans/",
output_folder="processed/"
)
Quality Metrics
# result.metrics contains:
print(result.metrics.mse) # Mean Squared Error
print(result.metrics.psnr) # Peak Signal-to-Noise Ratio (dB)
print(result.metrics.snr) # Signal-to-Noise Ratio (dB)
print(result.metrics.detail_preservation) # Percentage
Individual Operations
import numpy as np
# Apply individual filters
sharpened = processor.sharpen(image)
denoised = processor.median_denoise(image)
enhanced = processor.enhance_contrast(image)
bilateral = processor.bilateral_denoise(image)
# Compare quality
metrics = processor.evaluate_quality(original, processed)
⚡ Performance
- Lazy Loading: ~0.001s import time
- GPU Auto-Detection: CUDA for PyTorch/TensorFlow
- Mixed Precision: Automatic FP16 on compatible GPUs
- Batch Processing: All modules support batch inference
📄 License
MIT License - Guru Dharsan T
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gurulearn-5.0.1.tar.gz.
File metadata
- Download URL: gurulearn-5.0.1.tar.gz
- Upload date:
- Size: 36.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af1624151ec2c767621fd3cbd799ec634cc4076e493a34acf15217c5c26aa715
|
|
| MD5 |
0a8c815b89a7f5a4391c541e1c60c684
|
|
| BLAKE2b-256 |
c25952bd47d80221b01e37b95a14397fa493ae091bdf2fca57816a2f3d91c68a
|
File details
Details for the file gurulearn-5.0.1-py3-none-any.whl.
File metadata
- Download URL: gurulearn-5.0.1-py3-none-any.whl
- Upload date:
- Size: 36.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9b14aab7d0899c233dca1859480284bb78c22461b7478df3bb5feecddf461e6
|
|
| MD5 |
ecc783099c44e02dad27c52210d8136c
|
|
| BLAKE2b-256 |
82e96dc982538ed9acf168b2f1c525ec4658b6a6782aafbcd4ac8e6dd3ce2bba
|