Setup and Recreation Guide
This document provides instructions on how to set up and recreate the Predictive Machine project locally without overwriting the README.md file (which is essential for Hugging Face Spaces).
Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
- Git
- Docker (optional, for containerized deployment)
Local Setup
1. Clone the Repository
git clone https://huggingface.co/spaces/Asah-ML-Copilot-A25-CS047/Predictive-Machine
cd Predictive-Machine
2. Create a Virtual Environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
3. Install Dependencies
pip install -r requirements.txt
4. Download the Dataset
The project uses the Kaggle dataset: Machine Predictive Maintenance Classification
- Download the dataset from Kaggle
- Extract it to a
data/directory in the project root - Or set up Kaggle API credentials:
pip install kaggle
kaggle datasets download -d shivamb/machine-predictive-maintenance-classification
unzip machine-predictive-maintenance-classification.zip -d data/
5. Run the Application
uvicorn app:app --reload
Preserving README.md for Hugging Face Spaces
Important: The README.md file contains critical Hugging Face Spaces configuration metadata (YAML front matter). When updating the project:
- Never overwrite or delete
README.md Keep the YAML header intact: ```yaml
title: Predictive Machine emoji: π¨ colorFrom: pink colorTo: indigo sdk: docker pinned: true license: apache-2.0 short_description: Predictive Machine Copilot for Asah by Dicoding x Accenture datasets: [https://www.kaggle.com/datasets/shivamb/machine-predictive-maintenance-classification/data]
- Use this
SETUP.mdfile for development documentation instead - If you need to update README.md content, only modify the area AFTER the closing
---
Docker Deployment
Build the Docker Image
docker build -t predictive-machine .
Run the Container
docker run -p 7860:7860 predictive-machine
The application will be available at http://localhost:7860
Project Structure
Predictive-Machine/
βββ README.md # Hugging Face Spaces config (DO NOT OVERWRITE)
βββ SETUP.md # This file - local setup instructions
βββ Dockerfile # Docker configuration
βββ requirements.txt # Python dependencies
βββ app.py # Main application
βββ data/ # Dataset directory
βββ models/ # Trained models
βββ src/ # Source code modules
Development Workflow
Create a new branch for features:
git checkout -b feature/your-feature-nameMake changes and test locally
Commit and push changes:
git add . git commit -m "Description of changes" git push origin feature/your-feature-nameCreate a pull request
Once merged, the changes will be reflected in the Hugging Face Spaces deployment
Troubleshooting
Dataset Download Issues
- Ensure you have Kaggle API credentials configured:
~/.kaggle/kaggle.json - Or download manually from Kaggle and place files in
data/directory
Dependency Conflicts
pip install --upgrade pip
pip install -r requirements.txt --force-reinstall
Docker Build Issues
docker build --no-cache -t predictive-machine .
License
This project is licensed under the Apache 2.0 License - see LICENSE file for details.