Commit Β·
950bce5
1
Parent(s): 1029010
Improve UI/UX - add custom CSS styling and better layout
Browse files
app.py
CHANGED
|
@@ -220,33 +220,85 @@ def process_dataset(file, prompt):
|
|
| 220 |
return f"β Error: {str(e)}", None, None, None, None, f"β Processing failed: {str(e)}"
|
| 221 |
|
| 222 |
# Create Gradio interface
|
| 223 |
-
with gr.Blocks(title="PromptPrepML", theme=gr.themes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
gr.Markdown("# π€ PromptPrepML")
|
| 225 |
-
gr.Markdown("AI-Powered Machine Learning Data Preprocessing Assistant")
|
| 226 |
gr.Markdown("Upload your dataset and get ML-ready results in seconds! π")
|
| 227 |
|
| 228 |
with gr.Row():
|
| 229 |
with gr.Column(scale=1):
|
| 230 |
-
|
|
|
|
|
|
|
|
|
|
| 231 |
prompt_input = gr.Textbox(
|
| 232 |
-
label="
|
| 233 |
value="Prepare this dataset for machine learning. Handle missing values, remove identifier columns, extract date features, encode categorical variables, and scale numeric features.",
|
| 234 |
-
lines=
|
| 235 |
)
|
| 236 |
-
process_btn = gr.Button("π Process Dataset", variant="primary")
|
| 237 |
|
| 238 |
with gr.Column(scale=2):
|
| 239 |
-
|
|
|
|
| 240 |
status_output = gr.Textbox(label="π Status", interactive=False)
|
| 241 |
|
| 242 |
-
gr.Markdown("
|
| 243 |
-
|
|
|
|
| 244 |
|
| 245 |
-
gr.Markdown("
|
|
|
|
| 246 |
with gr.Row():
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
|
|
|
|
|
|
|
|
|
| 250 |
|
| 251 |
# Event handlers
|
| 252 |
process_btn.click(
|
|
@@ -255,24 +307,34 @@ with gr.Blocks(title="PromptPrepML", theme=gr.themes.Soft()) as demo:
|
|
| 255 |
outputs=[output_summary, processed_download, train_download, test_download, preview_output, status_output]
|
| 256 |
)
|
| 257 |
|
| 258 |
-
gr.Markdown("
|
| 259 |
-
gr.Markdown(""
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
- **Feature scaling**
|
| 274 |
-
- **Train/test splitting**
|
| 275 |
-
""")
|
| 276 |
|
| 277 |
# Launch the app
|
| 278 |
if __name__ == "__main__":
|
|
|
|
| 220 |
return f"β Error: {str(e)}", None, None, None, None, f"β Processing failed: {str(e)}"
|
| 221 |
|
| 222 |
# Create Gradio interface
|
| 223 |
+
with gr.Blocks(title="PromptPrepML", theme=gr.themes.Base(), css="""
|
| 224 |
+
.gradio-container {
|
| 225 |
+
max-width: 1200px !important;
|
| 226 |
+
margin: auto !important;
|
| 227 |
+
}
|
| 228 |
+
.gr-button {
|
| 229 |
+
background: linear-gradient(45deg, #667eea 0%, #764ba2 100%) !important;
|
| 230 |
+
border: none !important;
|
| 231 |
+
color: white !important;
|
| 232 |
+
font-weight: bold !important;
|
| 233 |
+
padding: 12px 24px !important;
|
| 234 |
+
border-radius: 8px !important;
|
| 235 |
+
transition: all 0.3s ease !important;
|
| 236 |
+
}
|
| 237 |
+
.gr-button:hover {
|
| 238 |
+
transform: translateY(-2px) !important;
|
| 239 |
+
box-shadow: 0 8px 25px rgba(0,0,0,0.15) !important;
|
| 240 |
+
}
|
| 241 |
+
.gr-file {
|
| 242 |
+
border: 2px dashed #667eea !important;
|
| 243 |
+
border-radius: 12px !important;
|
| 244 |
+
background: #f8f9ff !important;
|
| 245 |
+
transition: all 0.3s ease !important;
|
| 246 |
+
}
|
| 247 |
+
.gr-file:hover {
|
| 248 |
+
border-color: #764ba2 !important;
|
| 249 |
+
background: #f0f2ff !important;
|
| 250 |
+
}
|
| 251 |
+
.gr-textbox {
|
| 252 |
+
border-radius: 8px !important;
|
| 253 |
+
border: 1px solid #e1e5e9 !important;
|
| 254 |
+
}
|
| 255 |
+
.gr-textbox:focus {
|
| 256 |
+
border-color: #667eea !important;
|
| 257 |
+
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
|
| 258 |
+
}
|
| 259 |
+
.gr-markdown {
|
| 260 |
+
text-align: center !important;
|
| 261 |
+
}
|
| 262 |
+
.gr-dataframe {
|
| 263 |
+
border-radius: 8px !important;
|
| 264 |
+
overflow: hidden !important;
|
| 265 |
+
}
|
| 266 |
+
""") as demo:
|
| 267 |
gr.Markdown("# π€ PromptPrepML")
|
| 268 |
+
gr.Markdown("**AI-Powered Machine Learning Data Preprocessing Assistant**")
|
| 269 |
gr.Markdown("Upload your dataset and get ML-ready results in seconds! π")
|
| 270 |
|
| 271 |
with gr.Row():
|
| 272 |
with gr.Column(scale=1):
|
| 273 |
+
gr.Markdown("### π Upload Dataset")
|
| 274 |
+
file_input = gr.File(label="Choose CSV file", file_types=[".csv"])
|
| 275 |
+
|
| 276 |
+
gr.Markdown("### π¬ Processing Instructions")
|
| 277 |
prompt_input = gr.Textbox(
|
| 278 |
+
label="Describe your needs",
|
| 279 |
value="Prepare this dataset for machine learning. Handle missing values, remove identifier columns, extract date features, encode categorical variables, and scale numeric features.",
|
| 280 |
+
lines=4
|
| 281 |
)
|
| 282 |
+
process_btn = gr.Button("π Process Dataset", variant="primary", size="lg")
|
| 283 |
|
| 284 |
with gr.Column(scale=2):
|
| 285 |
+
gr.Markdown("### π Results")
|
| 286 |
+
output_summary = gr.Markdown(label="Processing Summary")
|
| 287 |
status_output = gr.Textbox(label="π Status", interactive=False)
|
| 288 |
|
| 289 |
+
gr.Markdown("---")
|
| 290 |
+
gr.Markdown("### π Dataset Preview")
|
| 291 |
+
preview_output = gr.Dataframe(label="First 10 rows of processed dataset")
|
| 292 |
|
| 293 |
+
gr.Markdown("---")
|
| 294 |
+
gr.Markdown("### π₯ Download Files")
|
| 295 |
with gr.Row():
|
| 296 |
+
with gr.Column():
|
| 297 |
+
processed_download = gr.File(label="π Processed Dataset")
|
| 298 |
+
with gr.Column():
|
| 299 |
+
train_download = gr.File(label="π Training Set")
|
| 300 |
+
with gr.Column():
|
| 301 |
+
test_download = gr.File(label="π§ͺ Test Set")
|
| 302 |
|
| 303 |
# Event handlers
|
| 304 |
process_btn.click(
|
|
|
|
| 307 |
outputs=[output_summary, processed_download, train_download, test_download, preview_output, status_output]
|
| 308 |
)
|
| 309 |
|
| 310 |
+
gr.Markdown("---")
|
| 311 |
+
gr.Markdown("### π How to Use")
|
| 312 |
+
with gr.Accordion("π Instructions", open=False):
|
| 313 |
+
gr.Markdown("""
|
| 314 |
+
1. **Upload your CSV dataset** (any size)
|
| 315 |
+
2. **Describe your preprocessing needs** (or use default)
|
| 316 |
+
3. **Click "Process Dataset"**
|
| 317 |
+
4. **Download your ML-ready results**
|
| 318 |
+
5. **Use for machine learning!**
|
| 319 |
+
|
| 320 |
+
### π§ **Intelligent Features**
|
| 321 |
+
- **Automatic identifier detection** and removal
|
| 322 |
+
- **Smart date feature extraction**
|
| 323 |
+
- **Text feature handling**
|
| 324 |
+
- **Categorical encoding** for low-cardinality features
|
| 325 |
+
- **High cardinality handling**
|
| 326 |
+
- **Missing value imputation**
|
| 327 |
+
- **Feature scaling**
|
| 328 |
+
- **Train/test splitting**
|
| 329 |
+
""")
|
| 330 |
|
| 331 |
+
gr.Markdown("---")
|
| 332 |
+
gr.Markdown("""
|
| 333 |
+
<div style='text-align: center; color: #6b7280; margin-top: 2rem;'>
|
| 334 |
+
<p><strong>π€ PromptPrepML</strong> - Automated ML Data Preprocessing</p>
|
| 335 |
+
<p><small>Convert natural language prompts into ML-ready datasets</small></p>
|
| 336 |
+
</div>
|
| 337 |
+
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
| 338 |
|
| 339 |
# Launch the app
|
| 340 |
if __name__ == "__main__":
|