singhn9 commited on
Commit
12b9dfa
·
verified ·
1 Parent(s): c81962c

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +9 -2
src/streamlit_app.py CHANGED
@@ -686,8 +686,15 @@ with tabs[4]:
686
  # Prevent premature __len__() access on unfitted ensemble models
687
  for r in tuned_results:
688
  m = r.get("model_obj")
689
- if m and hasattr(m, "__len__") and not hasattr(m, "estimators_"):
690
- m.__len__ = lambda self=m: 0
 
 
 
 
 
 
 
691
 
692
 
693
  for fam, entry in [(r["family"], r) for r in tuned_results if r.get("model_obj")]:
 
686
  # Prevent premature __len__() access on unfitted ensemble models
687
  for r in tuned_results:
688
  m = r.get("model_obj")
689
+ # Avoid implicit truth check that calls __len__
690
+ if m is not None:
691
+ try:
692
+ # If model defines __len__, override before fit
693
+ if "__len__" in dir(m) and not hasattr(m, "estimators_"):
694
+ setattr(m, "__len__", lambda self=m: 0)
695
+ except Exception:
696
+ pass
697
+
698
 
699
 
700
  for fam, entry in [(r["family"], r) for r in tuned_results if r.get("model_obj")]: