Update app.py
Browse files
app.py
CHANGED
@@ -656,7 +656,7 @@ class AdvancedAnalysisEngine:
|
|
656 |
|
657 |
@handle_errors(default_return=("Analysis failed", None, None))
|
658 |
def analyze_with_lime(self, text: str, language: str = 'auto', num_samples: int = 100) -> Tuple[str, go.Figure, Dict]:
|
659 |
-
"""FIXED LIME analysis implementation"""
|
660 |
if not text.strip():
|
661 |
return "Please enter text for analysis", None, {}
|
662 |
|
@@ -684,11 +684,8 @@ class AdvancedAnalysisEngine:
|
|
684 |
else:
|
685 |
class_names = ['Negative', 'Positive']
|
686 |
|
687 |
-
# Initialize LIME explainer
|
688 |
-
explainer = LimeTextExplainer(
|
689 |
-
class_names=class_names,
|
690 |
-
mode='classification'
|
691 |
-
)
|
692 |
|
693 |
# Get LIME explanation
|
694 |
exp = explainer.explain_instance(
|
@@ -742,7 +739,7 @@ class AdvancedAnalysisEngine:
|
|
742 |
}
|
743 |
|
744 |
summary_text = f"""
|
745 |
-
**LIME Analysis Results (FIXED):**
|
746 |
- **Language:** {detected_lang.upper()}
|
747 |
- **Features Analyzed:** {analysis_data['features_analyzed']}
|
748 |
- **Classes:** {', '.join(class_names)}
|
@@ -750,7 +747,7 @@ class AdvancedAnalysisEngine:
|
|
750 |
- **Positive Features:** {analysis_data['positive_features']}
|
751 |
- **Negative Features:** {analysis_data['negative_features']}
|
752 |
- **Top Features:** {', '.join([f"{word}({score:.3f})" for word, score in lime_data[:5]])}
|
753 |
-
- **Status:** ✅ LIME analysis completed successfully
|
754 |
"""
|
755 |
|
756 |
return summary_text, fig, analysis_data
|
@@ -763,6 +760,10 @@ class AdvancedAnalysisEngine:
|
|
763 |
- **Language:** {detected_lang.upper()}
|
764 |
- **Suggestion:** Try with a shorter text or reduce number of samples
|
765 |
|
|
|
|
|
|
|
|
|
766 |
**Common fixes:**
|
767 |
- Reduce sample size to 50-100
|
768 |
- Use shorter input text (< 200 words)
|
|
|
656 |
|
657 |
@handle_errors(default_return=("Analysis failed", None, None))
|
658 |
def analyze_with_lime(self, text: str, language: str = 'auto', num_samples: int = 100) -> Tuple[str, go.Figure, Dict]:
|
659 |
+
"""FIXED LIME analysis implementation - Bug Fix for mode parameter"""
|
660 |
if not text.strip():
|
661 |
return "Please enter text for analysis", None, {}
|
662 |
|
|
|
684 |
else:
|
685 |
class_names = ['Negative', 'Positive']
|
686 |
|
687 |
+
# Initialize LIME explainer - FIXED: Remove 'mode' parameter
|
688 |
+
explainer = LimeTextExplainer(class_names=class_names)
|
|
|
|
|
|
|
689 |
|
690 |
# Get LIME explanation
|
691 |
exp = explainer.explain_instance(
|
|
|
739 |
}
|
740 |
|
741 |
summary_text = f"""
|
742 |
+
**LIME Analysis Results (BUG FIXED):**
|
743 |
- **Language:** {detected_lang.upper()}
|
744 |
- **Features Analyzed:** {analysis_data['features_analyzed']}
|
745 |
- **Classes:** {', '.join(class_names)}
|
|
|
747 |
- **Positive Features:** {analysis_data['positive_features']}
|
748 |
- **Negative Features:** {analysis_data['negative_features']}
|
749 |
- **Top Features:** {', '.join([f"{word}({score:.3f})" for word, score in lime_data[:5]])}
|
750 |
+
- **Status:** ✅ LIME analysis completed successfully (mode parameter bug fixed)
|
751 |
"""
|
752 |
|
753 |
return summary_text, fig, analysis_data
|
|
|
760 |
- **Language:** {detected_lang.upper()}
|
761 |
- **Suggestion:** Try with a shorter text or reduce number of samples
|
762 |
|
763 |
+
**Bug Fix Applied:**
|
764 |
+
- ✅ Removed 'mode' parameter from LimeTextExplainer initialization
|
765 |
+
- ✅ This should resolve the "unexpected keyword argument 'mode'" error
|
766 |
+
|
767 |
**Common fixes:**
|
768 |
- Reduce sample size to 50-100
|
769 |
- Use shorter input text (< 200 words)
|