Skip to main content

Agricultural data auditing and explainable machine learning framework

Project description

🌱 Agro-Data-Intelligence (v0.2.1)

GitHub PyPI

Welcome to the agro-data-intelligence framework! This package is designed to make data auditing, cleaning, and Explainable Machine Learning (XAI) for agricultural datasets incredibly simple, robust, and professional.

🏆 Test Results & Reliability

We take data integrity seriously. This package is fully tested:

  • Unit & Integration Tests: ✅ Passed (100% success rate)
  • Real Dataset Tests: ✅ Passed (Handles missing, duplicate, and extreme bounds seamlessly)
  • Code Coverage: 🛡️ 87% Code Coverage

📥 1. Installation & Setup

Install the package via PyPI and import it alongside pandas.

# Install from PyPI (Terminal)
pip install agro-data-intelligence

# In your Python script / Jupyter Notebook
import pandas as pd
import data_audit  # Registers the 'audit' accessor automatically

🔍 2. Scanning Data for Issues (scan)

The first step is to scan the dataset for missing values, duplicates, and outliers.

# Load your dataset
df = pd.read_csv("agricultural_data.csv")

# Scan the data
issues = df.audit.scan()

# View the issues
print(issues)

[!TIP] Advanced Scanning: Users can customize outlier detection:

df.audit.scan(outlier_method='zscore', zscore_thresh=2.5)
# Or using custom bounds for a specific column like pH level:
df.audit.scan(custom_bounds={'Soil_pH': (5.5, 7.5)})

🛠️ 3. Fixing the Data (fix)

Once the data is scanned, users can fix the issues. There are three modes:

A. Auto Mode (Default)

Automatically fills missing values (median/mode) and clips outliers.

df.audit.fix(mode='auto')

B. Suggest Mode

Doesn't change the data, but suggests what should be done.

suggestions = df.audit.fix(mode='suggest')
print(suggestions)

C. Manual Mode (Professional Syntax)

Allows the user to precisely fix data by using the sid (Specific ID) helper.

from data_audit import sid

df.audit.fix(
    mode="manual",
    fixes=[
        sid(10, 120.0),             # Fix Issue ID 10 -> Replace with 120.0
        sid("Soil_Type", "Loamy"),  # Fill missing values in 'Soil_Type' with 'Loamy'
        sid((15, "Age"), 99.0),     # Change row 15, column 'Age' directly to 99.0
        sid(12, "ignore")           # Explicitly ignore Issue ID 12
    ]
)

📊 4. Generating Reports (summary & report)

Users can generate detailed statistical summary and audit reports.

# Quick statistical summary of the dataframe
print(df.audit.summary())

# Full audit report (Including ML status)
print(df.audit.report())

🤖 5. Machine Learning & AI (ml)

The package has an integrated Machine Learning module that automatically configures models based on your data.

Recommend a Model

Find the best model for your target variable based on dataset size and distribution:

print(df.audit.ml.recommend(target='Crop_Yield'))

Train a Model

# Tell the model what column you want to predict
df.audit.ml.train(target='Crop_Yield')

Evaluate the Model

See how well the model performed (Accuracy, F1-Score, R2 Score, RMSE, etc.).

print(df.audit.ml.evaluate())

Explain Predictions (XAI)

Explain why the model made a specific prediction for a specific row of data.

# Get a single row of data (e.g., the first farm in the dataset)
local_farm_data = df.iloc[0:1]

# Explain the prediction
explanation = df.audit.ml.explain(local_data=local_farm_data)
print(explanation)

👽 6. Finding Anomalies (anomaly)

Find completely weird or unusual rows in the dataset using Unsupervised Machine Learning (Isolation Forests).

# Get the rows that are considered severe anomalies
weird_farms = df.audit.anomaly()
print(weird_farms)

📜 7. Viewing History Log (history)

Users can see a trail of every action the auditor performed on their data.

print(df.audit.history())

📜 License

This project is licensed under the strict open-source AGPL-3.0 License. Any commercial online service utilizing this package must disclose their modified source code.

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

agro_data_intelligence-0.2.2.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agro_data_intelligence-0.2.2-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file agro_data_intelligence-0.2.2.tar.gz.

File metadata

  • Download URL: agro_data_intelligence-0.2.2.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for agro_data_intelligence-0.2.2.tar.gz
Algorithm Hash digest
SHA256 f01ab0ae2dc59005ae09ef4c57db9d830f8f1fa21940c5e00e497f26f9afd4f1
MD5 6b9f9a251ee09331bd39b71dd5b38fe9
BLAKE2b-256 279c7c811cbead55bf10a9d7c15795e925f22b05f907db8802b539e8169843a2

See more details on using hashes here.

File details

Details for the file agro_data_intelligence-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for agro_data_intelligence-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4050031fae4620fda5a8143a48e72fb526567737cd58266e0c0143490615425a
MD5 9080cc2da076c67a1ce64a05d3c56e2b
BLAKE2b-256 9bb96dafef52a1b6dfe64ec0a59f335bb4f55e29304045bebc6f3ba765092e1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page