Bor Hodošček commited on
Commit
4becfa2
·
unverified ·
1 Parent(s): 209daf0

feat: check for min>=max

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -679,6 +679,7 @@ def _():
679
  step=0.05,
680
  value=0.25,
681
  show_value=True,
 
682
  label="Minimum proportion of samples feature appears in",
683
  )
684
  max_df_setting = mo.ui.slider(
@@ -687,6 +688,7 @@ def _():
687
  step=0.05,
688
  value=0.8,
689
  show_value=True,
 
690
  label="Maximum proportion of samples feature appears in",
691
  )
692
  max_features_setting = mo.ui.slider(
@@ -695,6 +697,7 @@ def _():
695
  step=1,
696
  value=100,
697
  show_value=True,
 
698
  label="Maximum number of features to use",
699
  )
700
 
@@ -711,6 +714,15 @@ def _():
711
  return max_df_setting, max_features_setting, min_df_setting
712
 
713
 
 
 
 
 
 
 
 
 
 
714
  @app.cell
715
  def stopword_switch():
716
  stop_filter = mo.ui.switch(label="Enable stop-word filtering?", value=False)
@@ -781,10 +793,13 @@ def _(
781
  max_df_setting,
782
  max_features_setting,
783
  min_df_setting,
 
784
  sw: set[str],
785
  texts,
786
  train_scikit_cached,
787
  ):
 
 
788
  scikit_corpus, tfidf_X, vectorizer, chunk_cats, chunk_fnames = train_scikit_cached(
789
  texts,
790
  cats,
 
679
  step=0.05,
680
  value=0.25,
681
  show_value=True,
682
+ include_input=True,
683
  label="Minimum proportion of samples feature appears in",
684
  )
685
  max_df_setting = mo.ui.slider(
 
688
  step=0.05,
689
  value=0.8,
690
  show_value=True,
691
+ include_input=True,
692
  label="Maximum proportion of samples feature appears in",
693
  )
694
  max_features_setting = mo.ui.slider(
 
697
  step=1,
698
  value=100,
699
  show_value=True,
700
+ include_input=True,
701
  label="Maximum number of features to use",
702
  )
703
 
 
714
  return max_df_setting, max_features_setting, min_df_setting
715
 
716
 
717
+ @app.cell
718
+ def _(max_df_setting, min_df_setting):
719
+ min_max_check = None
720
+ if max_df_setting.value <= min_df_setting.value:
721
+ min_max_check = mo.md(f"**Error**: minimum value {min_df_setting.value} must be smaller then maximum value {max_df_setting.value}.\n\nChange the sliders so that the min is smaller than the max.").callout(kind="danger")
722
+ min_max_check
723
+ return (min_max_check,)
724
+
725
+
726
  @app.cell
727
  def stopword_switch():
728
  stop_filter = mo.ui.switch(label="Enable stop-word filtering?", value=False)
 
793
  max_df_setting,
794
  max_features_setting,
795
  min_df_setting,
796
+ min_max_check,
797
  sw: set[str],
798
  texts,
799
  train_scikit_cached,
800
  ):
801
+ mo.stop(min_max_check is not None)
802
+
803
  scikit_corpus, tfidf_X, vectorizer, chunk_cats, chunk_fnames = train_scikit_cached(
804
  texts,
805
  cats,