Commit
·
8780bfc
1
Parent(s):
ba335a6
Update app.py
Browse files
app.py
CHANGED
@@ -19,6 +19,10 @@ description = f"""
|
|
19 |
|
20 |
This demo computes a Bayesian Ridge Regression of Sinusoids.
|
21 |
|
|
|
|
|
|
|
|
|
22 |
The demo is based on the [scikit-learn docs](https://scikit-learn.org/stable/auto_examples/linear_model/plot_bayesian_ridge_curvefit.html#sphx-glr-auto-examples-linear-model-plot-bayesian-ridge-curvefit-py)
|
23 |
"""
|
24 |
|
@@ -63,7 +67,8 @@ def curve_fit(size, alpha, lam):
|
|
63 |
reg.alpha_, reg.lambda_, reg.scores_[-1]
|
64 |
)
|
65 |
ax.text(0.05, -1.0, text, fontsize=12)
|
66 |
-
|
|
|
67 |
|
68 |
|
69 |
with gr.Blocks(theme=theme) as demo:
|
@@ -79,7 +84,8 @@ with gr.Blocks(theme=theme) as demo:
|
|
79 |
with gr.Row():
|
80 |
run_button = gr.Button('Fit the Curve')
|
81 |
with gr.Row():
|
82 |
-
|
83 |
-
|
|
|
84 |
|
85 |
demo.launch()
|
|
|
19 |
|
20 |
This demo computes a Bayesian Ridge Regression of Sinusoids.
|
21 |
|
22 |
+
In general, when fitting a curve with a polynomial by Bayesian ridge regression, the selection of initial values of the regularization parameters (alpha, lambda) may be important. This is because the regularization parameters are determined by an iterative procedure that depends on initial values.
|
23 |
+
|
24 |
+
In this demo, the sinusoid is approximated by a cubic polynomial using different pairs of initial values.
|
25 |
+
|
26 |
The demo is based on the [scikit-learn docs](https://scikit-learn.org/stable/auto_examples/linear_model/plot_bayesian_ridge_curvefit.html#sphx-glr-auto-examples-linear-model-plot-bayesian-ridge-curvefit-py)
|
27 |
"""
|
28 |
|
|
|
67 |
reg.alpha_, reg.lambda_, reg.scores_[-1]
|
68 |
)
|
69 |
ax.text(0.05, -1.0, text, fontsize=12)
|
70 |
+
|
71 |
+
return axes[0], axes[1]
|
72 |
|
73 |
|
74 |
with gr.Blocks(theme=theme) as demo:
|
|
|
84 |
with gr.Row():
|
85 |
run_button = gr.Button('Fit the Curve')
|
86 |
with gr.Row():
|
87 |
+
plot_default = gr.Plot('Default Initialization')
|
88 |
+
plot_chosen = gr.Plot('Chosen Initialization')
|
89 |
+
run_button.click(fn=curve_fit, inputs=[size, alpha, lam], outputs=[plot_default, plot_chosen])
|
90 |
|
91 |
demo.launch()
|