Lecture 29: User Feedback and Iterative Optimization
Master user feedback collection and data analysis methods to continuously optimize Skill experience.
一、Feedback Collection Channels
1.1 Feedback Channel Matrix
| Channel | Advantages | Disadvantages | Applicable Scenario |
|---|
| In-app feedback | Immediate | Low user initiative | Real-time issue collection |
| User interviews | High depth | High cost | Before major redesigns |
| Survey | Wide coverage | Low response rate | Satisfaction surveys |
| Data analytics | Objective quantification | Lacks reasons | Usage behavior analysis |
| Community forum | User mutual help | Scattered information | Long-term operations |
1.2 Feedback Collection Implementation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| from datetime import datetime from typing import Dict, List
class FeedbackCollector: """Feedback collector"""
def __init__(self, storage): self.storage = storage
def collect_feedback(self, user_id: str, feedback_type: str, content: str, metadata: Dict = None) -> str: """Collect user feedback""" feedback_id = generate_id()
feedback = { 'id': feedback_id, 'user_id': user_id, 'type': feedback_type, 'content': content, 'metadata': metadata or {}, 'status': 'new', 'created_at': datetime.now().isoformat(), 'updated_at': datetime.now().isoformat() }
self.storage.save(f"feedback:{feedback_id}", feedback)
self._notify_team(feedback)
return feedback_id
def get_feedback_stats(self, days: int = 30) -> Dict: """Get feedback statistics""" feedbacks = self._get_recent_feedbacks(days)
stats = { 'total': len(feedbacks), 'by_type': {}, 'by_status': {}, 'avg_response_time': 0 }
for fb in feedbacks: fb_type = fb['type'] stats['by_type'][fb_type] = stats['by_type'].get(fb_type, 0) + 1
status = fb['status'] stats['by_status'][status] = stats['by_status'].get(status, 0) + 1
return stats
|
二、Data Analytics
2.1 Core Metrics
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| from dataclasses import dataclass from typing import List
@dataclass class SkillMetrics: """Skill metrics""" total_sessions: int active_users: int avg_session_duration: float
avg_response_time: float error_rate: float availability: float
completion_rate: float fallback_rate: float user_rating: float
class AnalyticsDashboard: """Analytics dashboard"""
def __init__(self, storage): self.storage = storage
def get_daily_metrics(self, date: str) -> SkillMetrics: """Get daily metrics""" data = self.storage.load(f"metrics:{date}")
return SkillMetrics( total_sessions=data.get('sessions', 0), active_users=data.get('active_users', 0), avg_session_duration=data.get('avg_duration', 0), avg_response_time=data.get('avg_response_time', 0), error_rate=data.get('error_rate', 0), availability=data.get('availability', 100), completion_rate=data.get('completion_rate', 0), fallback_rate=data.get('fallback_rate', 0), user_rating=data.get('user_rating', 0) )
def get_intent_distribution(self, days: int = 7) -> Dict: """Get intent distribution""" intents = {}
for i in range(days): date = (datetime.now() - timedelta(days=i)).strftime('%Y-%m-%d') daily_intents = self.storage.load(f"intents:{date}") or {}
for intent, count in daily_intents.items(): intents[intent] = intents.get(intent, 0) + count
return intents
def identify_issues(self) -> List[Dict]: """Identify issues""" issues = []
recent_errors = self._get_recent_errors(hours=24) if len(recent_errors) > 10: issues.append({ 'type': 'high_error_rate', 'severity': 'high', 'description': f'{len(recent_errors)} errors occurred in 24 hours', 'suggestion': 'Check recent updates or external dependencies' })
avg_response_time = self._get_avg_response_time(hours=24) if avg_response_time > 3.0: issues.append({ 'type': 'slow_response', 'severity': 'medium', 'description': f'Average response time {avg_response_time:.2f}s', 'suggestion': 'Optimize performance or add resources' })
recent_ratings = self._get_recent_ratings(days=7) if recent_ratings and statistics.mean(recent_ratings) < 3.0: issues.append({ 'type': 'low_satisfaction', 'severity': 'high', 'description': 'User satisfaction below 3.0', 'suggestion': 'Collect feedback and improve experience' })
return issues
|
三、Iterative Optimization
3.1 A/B Testing
# ab_test.py
import random
from typing import Dict, Any
class ABTestManager:
"""A/B test manager"""
def __init__(self, storage):
self.storage = storage
self.tests = {}
def create_test(self, test_id: str, variants: List[str],
traffic_split: List[float]):
## 🎓 AI 编程实战课程
想系统学习 AI 编程?程序员晚枫的 **AI 编程实战课** 帮你从零上手!
- 👉 **课程报名**:[点击这里报名,前3讲免费试听](https://r7up9.xetslk.com/s/1uP5YW)
- 👉 **免费试看**:[B站免费试看前3讲,先看看适不适合自己](https://www.bilibili.com/cheese/play/ss982042944)