File size: 4,093 Bytes
c341bcb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# 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

```bash
git clone https://huggingface.co/spaces/Asah-ML-Copilot-A25-CS047/Predictive-Machine
cd Predictive-Machine
```

### 2. Create a Virtual Environment

```bash
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
```

### 3. Install Dependencies

```bash
pip install -r requirements.txt
```

### 4. Download the Dataset

The project uses the Kaggle dataset: [Machine Predictive Maintenance Classification](https://www.kaggle.com/datasets/shivamb/machine-predictive-maintenance-classification/data)

- Download the dataset from Kaggle
- Extract it to a `data/` directory in the project root
- Or set up Kaggle API credentials:

```bash
pip install kaggle
kaggle datasets download -d shivamb/machine-predictive-maintenance-classification
unzip machine-predictive-maintenance-classification.zip -d data/
```

### 5. Run the Application

```bash
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:

1. **Never overwrite or delete `README.md`**
2. 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]
   ---
   ```
3. Use this `SETUP.md` file for development documentation instead
4. If you need to update README.md content, only modify the area AFTER the closing `---`

## Docker Deployment

### Build the Docker Image

```bash
docker build -t predictive-machine .
```

### Run the Container

```bash
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

1. Create a new branch for features:
   ```bash
   git checkout -b feature/your-feature-name
   ```

2. Make changes and test locally

3. Commit and push changes:
   ```bash
   git add .
   git commit -m "Description of changes"
   git push origin feature/your-feature-name
   ```

4. Create a pull request

5. 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
```bash
pip install --upgrade pip
pip install -r requirements.txt --force-reinstall
```

### Docker Build Issues
```bash
docker build --no-cache -t predictive-machine .
```

## License

This project is licensed under the Apache 2.0 License - see LICENSE file for details.

## Resources

- [Hugging Face Spaces Documentation](https://huggingface.co/docs/hub/spaces)
- [Hugging Face Spaces Config Reference](https://huggingface.co/docs/hub/spaces-config-reference)
- [Dataset: Machine Predictive Maintenance Classification](https://www.kaggle.com/datasets/shivamb/machine-predictive-maintenance-classification)