Updated description and use slider as input
Browse files
app.py
CHANGED
@@ -40,15 +40,34 @@ def select_features(method,num_features):
|
|
40 |
toc_bwd = time()
|
41 |
selected_features = feature_names[sfs_backward.get_support()]
|
42 |
execution_time = toc_bwd - tic_bwd
|
43 |
-
return f"Selected the following features: {selected_features} in {execution_time:.3f} seconds"
|
44 |
|
45 |
title = "Selecting features with Sequential Feature Selection"
|
46 |
with gr.Blocks(title=title) as demo:
|
47 |
gr.Markdown(f"## {title}")
|
48 |
-
gr.Markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
method = gr.Radio(["model", "sfs-forward", "sfs-backward"], label="Method")
|
51 |
-
num_features = gr.
|
52 |
output = gr.Textbox(label="Output Box")
|
53 |
select_btn = gr.Button("Select")
|
54 |
select_btn.click(fn=select_features, inputs=[method,num_features], outputs=output)
|
|
|
40 |
toc_bwd = time()
|
41 |
selected_features = feature_names[sfs_backward.get_support()]
|
42 |
execution_time = toc_bwd - tic_bwd
|
43 |
+
return f"Selected the following features: {' '.join(selected_features)} in {execution_time:.3f} seconds"
|
44 |
|
45 |
title = "Selecting features with Sequential Feature Selection"
|
46 |
with gr.Blocks(title=title) as demo:
|
47 |
gr.Markdown(f"## {title}")
|
48 |
+
gr.Markdown("""
|
49 |
+
This app demonstrates feature selection techniques using model based selection and sequential feature selection.\n
|
50 |
+
Model based selection is based on feature importance. Each feature is assigned a score on how much influence they
|
51 |
+
have on the model output.The feature with highest score is considered the most important feature.\n
|
52 |
+
Sequential feature selection is based on greedy approach. In greedy approach, the feature is added or removed
|
53 |
+
to the selected features at each iteration based on the model performance score.\n
|
54 |
+
This app uses Ridge estimator and the diabetes dataset from sklearn. Diabetes dataset consist of
|
55 |
+
quantitative measure of diabetes progression and 10 following variables obtained from 442 diabetes patients:\n
|
56 |
+
1. Age\n
|
57 |
+
2. Sex\n
|
58 |
+
3. Body mass index\n
|
59 |
+
4. Average blood pressure\n
|
60 |
+
5. Total serum cholesterol\n
|
61 |
+
6. Low-density lipoproteins\n
|
62 |
+
7. High-density lipoproteins\n
|
63 |
+
8. Total cholesterol / HDL\n
|
64 |
+
9. Possibly log of serum triglycerides level\n
|
65 |
+
10. Blood sugar level\n
|
66 |
+
This app is developed based on [scikit-learn example](https://scikit-learn.org/stable/auto_examples/feature_selection/plot_select_from_model_diabetes.html#sphx-glr-auto-examples-feature-selection-plot-select-from-model-diabetes-py)
|
67 |
+
""")
|
68 |
|
69 |
method = gr.Radio(["model", "sfs-forward", "sfs-backward"], label="Method")
|
70 |
+
num_features = gr.Slider(minimum=2, maximum=10, step=1, label = "Number of features")
|
71 |
output = gr.Textbox(label="Output Box")
|
72 |
select_btn = gr.Button("Select")
|
73 |
select_btn.click(fn=select_features, inputs=[method,num_features], outputs=output)
|