Spaces:
Running
Running
| from pathlib import Path | |
| import gradio as gr | |
| BASE_DIR = Path(__file__).resolve().parent | |
| # Expose both interface folders through Gradio's built-in static file route: | |
| # /gradio_api/file=<relative_path> | |
| gr.set_static_paths(paths=[str(BASE_DIR / "linear-regression"), str(BASE_DIR / "logistic-regression")]) | |
| with gr.Blocks(title="DDW Machine Learning") as demo: | |
| with gr.Row(): | |
| gr.HTML( | |
| """ | |
| <div style="border:1px solid #ddd;border-radius:12px;padding:16px;"> | |
| <h3>Linear Regression</h3> | |
| <p>Week10 interactive pages:</p> | |
| <ul> | |
| <li><strong>NumPy Matrix Lab:</strong> matrix operations, shape-aware input fields, generated NumPy code, and output visualization.</li> | |
| <li><strong>Gradient Descent Studio:</strong> one-feature linear regression optimization with step-level gradients, cost, and trajectory visualization.</li> | |
| <li><strong>Linear Regression Step Trainer:</strong> hand-calculation practice for gradients and one-step parameter updates with optional normalization.</li> | |
| </ul> | |
| <a href="/gradio_api/file=linear-regression/index.html" target="_blank" rel="noopener noreferrer">Open Linear Regression Interface</a> | |
| </div> | |
| """ | |
| ) | |
| gr.HTML( | |
| """ | |
| <div style="border:1px solid #ddd;border-radius:12px;padding:16px;"> | |
| <h3>Logistic Regression</h3> | |
| <p>Week11 interactive pages:</p> | |
| <ul> | |
| <li><strong>Simple Sigmoid:</strong> basic view of sigmoid output from a single z value.</li> | |
| <li><strong>Confusion Matrix Practice:</strong> threshold-based classification practice with confusion matrix and metrics.</li> | |
| <li><strong>Sigmoid Function:</strong> interactive plot for p = 1 / (1 + exp(-(b0 + b1x))) with parameter controls.</li> | |
| <li><strong>Cost Function Visualization:</strong> compare logistic-model cases and observe gradient-descent behavior on the cost surface.</li> | |
| <li><strong>Notes:</strong> supporting lecture notes and page context.</li> | |
| </ul> | |
| <a href="/gradio_api/file=logistic-regression/index.html" target="_blank" rel="noopener noreferrer">Open Logistic Regression Interface</a> | |
| </div> | |
| """ | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |