Add better description of the space
Browse files
app.py
CHANGED
@@ -87,13 +87,29 @@ def get_proba_plots(
|
|
87 |
|
88 |
|
89 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
with gr.Row():
|
91 |
with gr.Column(scale=3):
|
92 |
-
gr.Markdown(
|
93 |
-
"Choose the type of model and the weight of each model in the final vote." # noqa: E501
|
94 |
-
+ " For example if you set weights to 1, 1, 5 for the three models,"
|
95 |
-
+ " the third model will have 5 times more weight than the other two models." # noqa: E501
|
96 |
-
)
|
97 |
with gr.Row():
|
98 |
model_1 = gr.Dropdown(
|
99 |
[
|
@@ -104,7 +120,9 @@ with gr.Blocks() as demo:
|
|
104 |
label="Model 1",
|
105 |
value="Logistic Regression",
|
106 |
)
|
107 |
-
model_1_weight = gr.
|
|
|
|
|
108 |
with gr.Row():
|
109 |
model_2 = gr.Dropdown(
|
110 |
[
|
@@ -115,7 +133,9 @@ with gr.Blocks() as demo:
|
|
115 |
label="Model 2",
|
116 |
value="Random Forest",
|
117 |
)
|
118 |
-
model_2_weight = gr.
|
|
|
|
|
119 |
with gr.Row():
|
120 |
model_3 = gr.Dropdown(
|
121 |
[
|
@@ -127,7 +147,9 @@ with gr.Blocks() as demo:
|
|
127 |
value="Gaussian Naive Bayes",
|
128 |
)
|
129 |
|
130 |
-
model_3_weight = gr.
|
|
|
|
|
131 |
with gr.Column(scale=4):
|
132 |
proba_plots = gr.Plot()
|
133 |
|
|
|
87 |
|
88 |
|
89 |
with gr.Blocks() as demo:
|
90 |
+
gr.Markdown(
|
91 |
+
"""
|
92 |
+
# Class probabilities by the `VotingClassifier`
|
93 |
+
|
94 |
+
This space shows the effect of the weight of different classifiers when using sklearn's [VotingClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.VotingClassifier.html#sklearn.ensemble.VotingClassifier).
|
95 |
+
|
96 |
+
For example, suppose you set the weights as in the table below, and the models have the following predicted probabilities:
|
97 |
+
|
98 |
+
| | Weights | Predicted Probabilities |
|
99 |
+
|---------|:-------:|:----------------:|
|
100 |
+
| Model 1 | 1 | 0.5 |
|
101 |
+
| Model 2 | 2 | 0.8 |
|
102 |
+
| Model 3 | 5 | 0.9 |
|
103 |
+
|
104 |
+
The predicted probability by the `VotingClassifier` will be $(1*0.5 + 2*0.8 + 5*0.9) / (1 + 2 + 5)$
|
105 |
+
|
106 |
+
You can experiment with different model types and weights and see their effect on the VotingClassifier's prediction.
|
107 |
+
|
108 |
+
This space is based on [sklearn’s original demo](https://scikit-learn.org/stable/auto_examples/ensemble/plot_voting_probas.html#sphx-glr-auto-examples-ensemble-plot-voting-probas-py).
|
109 |
+
"""
|
110 |
+
)
|
111 |
with gr.Row():
|
112 |
with gr.Column(scale=3):
|
|
|
|
|
|
|
|
|
|
|
113 |
with gr.Row():
|
114 |
model_1 = gr.Dropdown(
|
115 |
[
|
|
|
120 |
label="Model 1",
|
121 |
value="Logistic Regression",
|
122 |
)
|
123 |
+
model_1_weight = gr.Slider(
|
124 |
+
value=1, label="Model 1 Weight", max=10, step=1
|
125 |
+
)
|
126 |
with gr.Row():
|
127 |
model_2 = gr.Dropdown(
|
128 |
[
|
|
|
133 |
label="Model 2",
|
134 |
value="Random Forest",
|
135 |
)
|
136 |
+
model_2_weight = gr.Slider(
|
137 |
+
value=1, label="Model 2 Weight", max=10, step=1
|
138 |
+
)
|
139 |
with gr.Row():
|
140 |
model_3 = gr.Dropdown(
|
141 |
[
|
|
|
147 |
value="Gaussian Naive Bayes",
|
148 |
)
|
149 |
|
150 |
+
model_3_weight = gr.Slider(
|
151 |
+
value=5, label="Model 3 Weight", max=10, step=1
|
152 |
+
)
|
153 |
with gr.Column(scale=4):
|
154 |
proba_plots = gr.Plot()
|
155 |
|