BACK_TO_LOGS// STEP_3_OF_10
HANDBOOK_GUIDE2026-06-29

OptiCrop: Smart Agricultural Production Optimization Engine ML Guide

By Rayan Syed
45 min read

Part 3: Creating the Project Workspace & Libraries

3. Creating the Workspace

To keep our project organized, we separate our files logically. A structured folder layout ensures our raw data remains isolated, our serialized models are stored securely, and our web backend assets are cleanly separated.

Create a folder named opticrop on your computer. Inside, organize your folders and empty files exactly like this:

opticrop/
├── data/
│   └── Crop_recommendation.csv     (We will download this next!)
├── models/
│   ├── crop_model.joblib           (This is generated by train.py later!)
│   └── scaler.joblib               (This is generated by train.py later!)
├── templates/
│   └── index.html
├── static/
│   ├── style.css
│   └── script.js
├── notebook.ipynb
└── app.py

[!IMPORTANT] Beginner Rule: Whenever you write or paste code into any file in VS Code, remember to press Ctrl + S (Windows) or Cmd + S (macOS) to save your changes. If you do not save, the file remains empty and your code will not run!


3.1 Installing Required Libraries

Open your terminal inside your project folder and run the following installation command:

pip install numpy pandas matplotlib seaborn scikit-learn joblib flask

We install these key libraries:

  • pandas: Serves as our “Virtual Excel”. It loads, merges, and cleans our tabular CSV data.
  • numpy: Handles low-level mathematical operations on multi-dimensional matrix arrays.
  • matplotlib & seaborn: Generates statistical charts and correlation heatmaps.
  • scikit-learn: Houses our classifiers, data splitters, and validation metrics.
  • joblib: Saves our trained model weights into a portable binary file.
  • flask: Runs our lightweight local backend application server.