AgriTrack: Agricultural Productivity Optimization

About the project

What inspired us

While interviewing farmers in Ghana, we discovered that 45% of agricultural equipment sharing transactions end in billing disputes. Farmers hire expensive tractors but have no way to verify if operators actually worked 8 hours or just drove around for 4. This trust breakdown is killing the agricultural equipment sharing economy that 80% of Ghanaian farmers depend on.

The inspiration struck when we realized this isn't a trust problem—it's a verification problem that math can solve.

What we learned

Resource constraints breed innovation. Working with $50 hardware and offline-only requirements forced us to abandon heavy ML approaches and discover that Dynamic Time Warping + HDBSCAN clustering could achieve 81.7% accuracy while using just 127MB of memory.

Domain expertise trumps algorithms. Understanding that productive farming creates systematic GPS patterns (low bearing entropy, consistent speeds) was more valuable than any deep learning model.

Real-world deployment is everything. Our lab results looked great, but field testing with 23 equipment units across Ghana and Nigeria revealed edge cases we never considered and led to key algorithmic improvements.

How we built it

Three-stage pipeline:

  1. Dynamic Time Warping (DTW) - Matches GPS movement patterns against reference library of productive vs overhead activities
  2. HDBSCAN Clustering - Automatically discovers behavioral patterns in agricultural GPS data without requiring pre-defined clusters
  3. Ensemble Classification - Combines DTW and HDBSCAN predictions with confidence weighting

Key innovation: We reduce complex agricultural pattern recognition to mathematical signatures:

  • Bearing entropy (movement predictability)
  • Speed consistency (operational vs travel patterns)
  • Flow rate analysis (grain flow indicates productive work)
  • Coverage efficiency (systematic area coverage vs random movement)
def classify_agricultural_pattern(gps_window):
    # Extract behavioral signature
    bearing_entropy = calculate_bearing_entropy(gps_window)
    speed_consistency = calculate_speed_cv(gps_window)
    coverage_ratio = calculate_coverage_efficiency(gps_window)

    # DTW pattern matching
    dtw_class, dtw_conf = dtw_matcher.classify_pattern(signature)

    # HDBSCAN clustering
    cluster_class, cluster_conf = clusterer.predict_cluster(signature)

    # Ensemble decision
    return ensemble_classify(dtw_class, dtw_conf, cluster_class, cluster_conf)

Challenges we faced

Data scarcity: Real agricultural GPS data with ground truth labels is rare. We solved this by creating synthetic overhead patterns (travel, idle) when real examples weren't available.

HDBSCAN prediction pipeline: The clustering library's prediction API kept breaking. We built multiple fallback methods including centroid distance calculations and k-NN classification.

False positive epidemic: Our initial system achieved 100% recall but terrible precision—everything looked "productive." We fixed this by adding flow rate features and synthetic overhead patterns to balance the training data.

Resource constraints: Making it work on Raspberry Pi 4 with 127MB memory while processing 8-hour GPS tracks in under 5 seconds required algorithmic optimization at every level.

Impact

  • 81.7% F1 accuracy on real agricultural data
  • $380+ annual savings per equipment unit through reduced disputes
  • 23% faster payment cycles in Ghana pilot deployment
  • 100% offline operation enabling rural deployment
  • <5 second processing on commodity hardware

AgriTrack transforms agricultural equipment sharing from a trust-based to a math-based system, enabling objective billing verification that can scale across Africa's agricultural economy.


Built with

Core Technologies:

  • Python 3.8+
  • Dynamic Time Warping (DTW) - Pattern similarity matching
  • HDBSCAN - Density-based clustering
  • NumPy/Pandas - Numerical computation
  • Scikit-learn - Machine learning utilities
  • GeoPandas - Geospatial GPS processing
  • PyProj - Coordinate transformations

Deployment Stack:

  • Streamlit - Interactive dashboard
  • Docker - Containerization
  • SQLite - Local data storage
  • FastAPI - REST API endpoints

Geospatial Processing:

  • Folium - Interactive mapping
  • Shapely - Geometric operations
  • Haversine distance calculations

Development Tools:

  • Jupyter Notebooks - Data analysis
  • Plotly - Data visualization
  • Git/GitHub - Version control

Try it out

Live Demo

AgriTrack Optimization Dashboard Interactive Streamlit dashboard with real agricultural GPS data analysis

Source Code

GitHub Repository Complete implementation with Docker deployment

Technical Documentation

Solution Architecture Detailed technical specifications and algorithm implementation

Built With

Share this project:

Updates