| name | survey-analyzer |
| description | Analyze survey responses with Likert scale analysis, cross-tabulations, sentiment scoring, and frequency distributions with visualizations. |
Survey Analyzer
Comprehensive survey data analysis with Likert scales, cross-tabs, and sentiment analysis.
Features
- Likert Scale Analysis: Agreement scale scoring and visualization
- Cross-Tabulation: Relationship analysis between categorical variables
- Frequency Analysis: Response distributions and percentages
- Sentiment Scoring: Text response sentiment analysis
- Open-Ended Analysis: Theme extraction from text responses
- Statistical Tests: Chi-square, correlations, significance testing
- Visualizations: Bar charts, heatmaps, word clouds, distribution plots
- Report Generation: Comprehensive PDF/HTML reports
Quick Start
from survey_analyzer import SurveyAnalyzer
analyzer = SurveyAnalyzer()
analyzer.load_csv('survey_responses.csv')
results = analyzer.likert_analysis('satisfaction', scale_type='agreement')
print(f"Mean score: {results['mean_score']:.2f}")
crosstab = analyzer.crosstab('age_group', 'product_preference')
print(crosstab)
analyzer.generate_report('survey_report.pdf')
CLI Usage
python survey_analyzer.py --data survey.csv --likert satisfaction --output results.pdf
python survey_analyzer.py --data survey.csv --crosstab age_group product --output crosstab.png
python survey_analyzer.py --data survey.csv --sentiment comments --output sentiment.html
python survey_analyzer.py --data survey.csv --report --output full_report.pdf
API Reference
SurveyAnalyzer Class
class SurveyAnalyzer:
def __init__(self)
def load_csv(self, filepath, **kwargs) -> 'SurveyAnalyzer'
def load_data(self, data: pd.DataFrame) -> 'SurveyAnalyzer'
def likert_analysis(self, column, scale_type='agreement') -> Dict
def likert_comparison(self, columns: List[str]) -> pd.DataFrame
def plot_likert(self, column, output, scale_type='agreement') -> str
def frequency_table(self, column) -> pd.DataFrame
def multiple_choice(self, column, delimiter=',') -> pd.DataFrame
def plot_frequencies(self, column, output, top_n=None) -> str
def crosstab(self, row_var, col_var, normalize=None) -> pd.DataFrame
def () ->
() ->
() -> pd.DataFrame
() ->
() ->
() -> pd.DataFrame
() ->
() -> []
() ->
() ->
() -> pd.DataFrame
() ->
() ->
Likert Scale Analysis
Standard Scales
analyzer.likert_analysis('satisfaction', scale_type='agreement')
analyzer.likert_analysis('usage', scale_type='frequency')
analyzer.likert_analysis('rating', scale_type='custom',
labels=['Poor', 'Fair', 'Good', 'Excellent'])
Results
results = analyzer.likert_analysis('satisfaction')
Visualization
analyzer.plot_likert('satisfaction', 'likert_chart.png')
analyzer.likert_comparison(['quality', 'value', 'service'])
analyzer.plot_likert_comparison(['quality', 'value', 'service'],
'comparison.png')
Frequency Analysis
Single Choice
freq = analyzer.frequency_table('age_group')
analyzer.plot_frequencies('age_group', 'age_distribution.png')
Multiple Choice
For questions allowing multiple selections:
results = analyzer.multiple_choice('features_liked', delimiter=',')
analyzer.plot_frequencies('features_liked', 'features.png', top_n=10)
Cross-Tabulation
Basic Cross-Tab
crosstab = analyzer.crosstab('age_group', 'satisfaction')
crosstab_pct = analyzer.crosstab('age_group', 'satisfaction',
normalize='index')
Statistical Testing
result = analyzer.chi_square_test('age_group', 'satisfaction')
Visualization
analyzer.plot_crosstab('age_group', 'satisfaction', 'crosstab_heatmap.png')
Sentiment Analysis
Analyze open-ended text responses:
sentiment_df = analyzer.sentiment_analysis('comments')
summary = analyzer.sentiment_summary('comments')
analyzer.plot_sentiment('comments', 'sentiment_distribution.png')
Open-Ended Analysis
Word Frequency
words = analyzer.word_frequency('comments', top_n=20)
Word Cloud
analyzer.word_cloud('comments', 'wordcloud.png')
Theme Extraction
themes = analyzer.extract_themes('feedback', n_themes=5)
Satisfaction Metrics
Net Promoter Score (NPS)
nps = analyzer.nps_score('recommendation')
Overall Satisfaction
satisfaction = analyzer.satisfaction_score([
'product_quality',
'customer_service',
'value_for_money',
'ease_of_use'
])
Demographics Analysis
demographics = analyzer.demographics_summary([
'age_group',
'gender',
'location',
'income_range'
])
Response Rate Analysis
response_rate = analyzer.response_rate()
Report Generation
Comprehensive Report
analyzer.generate_report('survey_report.pdf', format='pdf')
Report includes:
- Executive summary
- Response rate and demographics
- Question-by-question analysis
- Likert scale visualizations
- Cross-tabulations
- Sentiment analysis
- Key findings and recommendations
Custom Report Sections
analyzer.set_report_sections([
'executive_summary',
'demographics',
'likert_questions',
'cross_tabs',
'sentiment',
'recommendations'
])
Advanced Features
Filter by Segment
analyzer.filter('age_group', '25-34')
results = analyzer.likert_analysis('satisfaction')
analyzer.clear_filter()
Compare Segments
comparison = analyzer.compare_segments(
segment_col='age_group',
metric_col='satisfaction'
)
Trend Analysis
For longitudinal surveys:
trends = analyzer.trend_analysis(
metric='satisfaction',
time_col='survey_date',
period='month'
)
analyzer.plot_trends(trends, 'satisfaction_trend.png')
Dependencies
- pandas>=2.0.0
- numpy>=1.24.0
- scipy>=1.10.0
- textblob>=0.17.0
- matplotlib>=3.7.0
- seaborn>=0.12.0
- wordcloud>=1.9.0
- reportlab>=4.0.0