rishirajpathak commited on
Commit
a7d2fe5
·
0 Parent(s):

initial commit

Browse files
Files changed (12) hide show
  1. .gitignore +26 -0
  2. DEPLOYMENT.md +49 -0
  3. README.md +73 -0
  4. app.py +241 -0
  5. assignment_engine.py +306 -0
  6. deploy.bat +23 -0
  7. requirements.txt +5 -0
  8. results.csv +7 -0
  9. task_manager.py +80 -0
  10. task_progress.json +26 -0
  11. tasks.csv +10 -0
  12. users.csv +6 -0
.gitignore ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ env/
8
+ .venv/
9
+ venv/
10
+ ENV/
11
+
12
+ # AI Models (these will be generated)
13
+ *.pkl
14
+
15
+ # IDE
16
+ .vscode/
17
+ .idea/
18
+ *.swp
19
+ *.swo
20
+
21
+ # OS
22
+ .DS_Store
23
+ Thumbs.db
24
+
25
+ # Logs
26
+ *.log
DEPLOYMENT.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🚀 Deploy to Hugging Face Spaces
2
+
3
+ ## Target URL: https://huggingface.co/spaces/rishirajpathak/task-management
4
+
5
+ ## Quick Deployment Steps
6
+
7
+ 1. **Go to**: https://huggingface.co/new-space
8
+ 2. **Space name**: `task-management`
9
+ 3. **Owner**: `rishirajpathak`
10
+ 4. **License**: MIT
11
+ 5. **SDK**: Gradio
12
+ 6. **Hardware**: CPU (free tier)
13
+
14
+ ## Files to Upload (All Required)
15
+
16
+ Upload these files from your D:\Task Management folder:
17
+
18
+ ### ✅ Core System
19
+ - `app.py` - Main Gradio interface
20
+ - `assignment_engine.py` - AI engine
21
+ - `task_manager.py` - System controller
22
+ - `requirements.txt` - Dependencies
23
+
24
+ ### ✅ Data Files
25
+ - `users.csv` - Team members
26
+ - `tasks.csv` - Task definitions
27
+ - `results.csv` - Completion history
28
+ - `task_progress.json` - Progress tracking
29
+
30
+ ### ✅ Documentation
31
+ - `README.md` - Space description
32
+ - `.gitignore` - Git ignore rules
33
+
34
+ ## ⚠️ DO NOT Upload
35
+ - `.venv/` folder (virtual environment)
36
+ - `assignment_model.pkl` (will be auto-generated)
37
+ - Any `__pycache__/` folders
38
+
39
+ ## After Upload
40
+ 1. Space will auto-build from requirements.txt
41
+ 2. App will be available at: https://huggingface.co/spaces/rishirajpathak/task-management
42
+ 3. First run will create the AI model automatically
43
+
44
+ ## Testing the Deployed App
45
+ 1. Add users and tasks
46
+ 2. Get AI assignments
47
+ 3. Update progress
48
+ 4. Complete tasks
49
+ 5. Retrain AI - system improves!
README.md ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: AI Task Assignment System
3
+ emoji: 🧠
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: 4.44.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ ---
12
+
13
+ # 🧠 AI Task Assignment System
14
+
15
+ A self-learning task assignment engine that automatically optimizes team productivity by learning from real task completion results.
16
+
17
+ ## 🎯 What This System Does
18
+
19
+ - **Enter People & Tasks**: Add team members and work items
20
+ - **AI Decides Assignments**: Optimal matching based on learned patterns
21
+ - **System Learns**: From real completion results (time, quality)
22
+ - **Gets Smarter**: Continuous improvement with each task
23
+
24
+ ## ✨ Key Features
25
+
26
+ - **Zero-bias assignments** based on real performance data
27
+ - **Universal application** - works for any task type (coding, design, research, etc.)
28
+ - **Real-time progress tracking** with notes and updates
29
+ - **Automatic skill discovery** - learns who's good at what
30
+ - **Burnout prevention** through workload analysis
31
+ - **Self-improving AI** that gets better with more data
32
+
33
+ ## 🚀 How to Use
34
+
35
+ 1. **Add Users**: Start with your team members
36
+ 2. **Add Tasks**: Enter work items with complexity (0-1) and deadline (hours)
37
+ 3. **Get Assignments**: AI recommends optimal person for each task
38
+ 4. **Track Progress**: Update task progress and add notes
39
+ 5. **Complete Tasks**: Enter time taken and quality score (1-5)
40
+ 6. **Retrain AI**: System learns and improves future assignments
41
+
42
+ ## 🧠 The Learning Process
43
+
44
+ Initially assigns tasks randomly (no data), but learns from every completion:
45
+ - User skill patterns
46
+ - Task complexity preferences
47
+ - Time efficiency trends
48
+ - Quality consistency
49
+ - Workload capacity
50
+
51
+ ## 📊 Real-World Applications
52
+
53
+ - **Software Teams**: Frontend, backend, testing assignments
54
+ - **Study Groups**: Subject-based task distribution
55
+ - **Project Management**: Optimal resource allocation
56
+ - **Any Team Environment**: Universal skill-based matching
57
+
58
+ ## 🔄 Self-Learning Cycle
59
+
60
+ ```
61
+ Add People & Tasks → AI Assigns → Work Completed →
62
+ Enter Results → AI Learns → Better Assignments
63
+ ```
64
+
65
+ **Result**: Maximum efficiency, minimum burnout, automatic skill discovery.
66
+
67
+ ## 🛠️ Technical Details
68
+
69
+ - **AI Model**: Random Forest Regressor (scikit-learn)
70
+ - **Features**: User ID, task complexity, deadline pressure
71
+ - **Target**: Success score (quality × efficiency)
72
+ - **Framework**: Gradio for web interface
73
+ - **Data**: CSV files for users, tasks, results, JSON for progress tracking
app.py ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ from task_manager import TaskManager
4
+ import os
5
+
6
+ # Initialize the task manager
7
+ tm = TaskManager()
8
+
9
+ def show_dashboard():
10
+ """Display system dashboard"""
11
+ try:
12
+ # Capture dashboard information
13
+ stats = []
14
+
15
+ # Basic stats
16
+ if len(tm.engine.results) > 0:
17
+ stats.append(f"📊 **SYSTEM STATISTICS**")
18
+ stats.append(f"- Total completed tasks: {len(tm.engine.results)}")
19
+ stats.append(f"- Average quality: {tm.engine.results['quality'].mean():.2f}/5")
20
+ stats.append(f"- Average time: {tm.engine.results['time_taken'].mean():.1f}h")
21
+ else:
22
+ stats.append("📊 No results yet - system ready for assignments")
23
+
24
+ # User performance
25
+ if len(tm.engine.results) > 0:
26
+ user_stats = tm.engine.results.merge(tm.engine.users, on='user_id').groupby('name').agg({
27
+ 'quality': 'mean',
28
+ 'time_taken': 'mean',
29
+ 'task_id': 'count'
30
+ }).round(2)
31
+
32
+ stats.append("\n👥 **USER PERFORMANCE**")
33
+ for user, row in user_stats.iterrows():
34
+ stats.append(f"- {user}: {row['quality']:.1f}/5 quality, {row['time_taken']:.1f}h avg, {int(row['task_id'])} tasks")
35
+
36
+ # Active tasks
37
+ if hasattr(tm.engine, 'progress_data') and tm.engine.progress_data:
38
+ active_tasks = [task for task in tm.engine.progress_data.values()
39
+ if task['status'] in ['assigned', 'in_progress']]
40
+ if active_tasks:
41
+ stats.append("\n📋 **ACTIVE TASKS**")
42
+ for task in active_tasks:
43
+ status_icon = "🔄" if task['status'] == 'in_progress' else "📋"
44
+ stats.append(f"{status_icon} Task {task['task_id']}: {task['user_name']} → {task['task_type']}")
45
+
46
+ # AI status
47
+ ai_status = "🤖 **AI Status**: " + ("Trained ✅" if tm.engine.is_trained else "Random Assignment ⚠️")
48
+ stats.append(f"\n{ai_status}")
49
+
50
+ return "\n".join(stats)
51
+
52
+ except Exception as e:
53
+ return f"Error: {str(e)}"
54
+
55
+ def assign_tasks():
56
+ """Assign pending tasks"""
57
+ try:
58
+ assignments = []
59
+
60
+ for _, task in tm.engine.tasks.iterrows():
61
+ task_id = task['task_id']
62
+
63
+ # Check if task already completed
64
+ completed = tm.engine.results[tm.engine.results['task_id'] == task_id]
65
+ if len(completed) > 0:
66
+ continue
67
+
68
+ user_id, user_name = tm.engine.assign_task(task_id)
69
+ if user_name:
70
+ assignments.append(f"✅ Task {task_id} ({task['type']}) assigned to {user_name}")
71
+
72
+ if not assignments:
73
+ return "📋 No pending tasks to assign"
74
+
75
+ return "\n".join(assignments)
76
+
77
+ except Exception as e:
78
+ return f"Error: {str(e)}"
79
+
80
+ def add_user(name):
81
+ """Add new user"""
82
+ try:
83
+ if not name.strip():
84
+ return "❌ Please enter a valid name"
85
+
86
+ tm.add_user(name.strip())
87
+ return f"✅ Added user: {name.strip()}"
88
+
89
+ except Exception as e:
90
+ return f"Error: {str(e)}"
91
+
92
+ def add_task(task_type, complexity, deadline):
93
+ """Add new task"""
94
+ try:
95
+ if not task_type.strip():
96
+ return "❌ Please enter a task type"
97
+ if not (0 <= complexity <= 1):
98
+ return "❌ Complexity must be between 0 and 1"
99
+ if deadline <= 0:
100
+ return "❌ Deadline must be positive"
101
+
102
+ tm.add_task(task_type.strip(), complexity, deadline)
103
+ return f"✅ Added task: {task_type.strip()} (Complexity: {complexity}, Deadline: {deadline}h)"
104
+
105
+ except Exception as e:
106
+ return f"Error: {str(e)}"
107
+
108
+ def update_progress(task_id, user_id, progress, notes):
109
+ """Update task progress"""
110
+ try:
111
+ if not (0 <= progress <= 100):
112
+ return "❌ Progress must be between 0 and 100"
113
+
114
+ tm.update_progress(int(task_id), int(user_id), int(progress), notes.strip())
115
+ return f"✅ Updated progress: Task {task_id} → {progress}%"
116
+
117
+ except Exception as e:
118
+ return f"Error: {str(e)}"
119
+
120
+ def complete_task(task_id, user_id, time_taken, quality):
121
+ """Complete a task"""
122
+ try:
123
+ if not (1 <= quality <= 5):
124
+ return "❌ Quality must be between 1 and 5"
125
+ if time_taken <= 0:
126
+ return "❌ Time taken must be positive"
127
+
128
+ tm.enter_result(int(task_id), int(user_id), float(time_taken), int(quality))
129
+ return f"✅ Task {task_id} completed successfully"
130
+
131
+ except Exception as e:
132
+ return f"Error: {str(e)}"
133
+
134
+ def retrain_ai():
135
+ """Retrain the AI model"""
136
+ try:
137
+ tm.retrain_ai()
138
+ return "✅ AI model retrained successfully"
139
+
140
+ except Exception as e:
141
+ return f"Error: {str(e)}"
142
+
143
+ def get_users_list():
144
+ """Get list of users for dropdowns"""
145
+ try:
146
+ return [(f"{row['user_id']} - {row['name']}", row['user_id']) for _, row in tm.engine.users.iterrows()]
147
+ except:
148
+ return []
149
+
150
+ def get_tasks_list():
151
+ """Get list of tasks for dropdowns"""
152
+ try:
153
+ return [(f"Task {row['task_id']} - {row['type']}", row['task_id']) for _, row in tm.engine.tasks.iterrows()]
154
+ except:
155
+ return []
156
+
157
+ # Create Gradio interface
158
+ with gr.Blocks(title="🧠 AI Task Assignment System") as app:
159
+ gr.Markdown("""
160
+ # 🧠 AI Task Assignment System
161
+
162
+ **Self-learning task assignment engine that gets smarter with every completed task!**
163
+
164
+ - 🎯 Enter people and tasks
165
+ - 🤖 AI decides optimal assignments
166
+ - 📊 System learns from real results
167
+ - 📈 Continuous improvement
168
+ """)
169
+
170
+ with gr.Tabs():
171
+ # Dashboard Tab
172
+ with gr.Tab("📊 Dashboard"):
173
+ dashboard_btn = gr.Button("🔄 Refresh Dashboard", variant="primary")
174
+ dashboard_output = gr.Markdown()
175
+ dashboard_btn.click(show_dashboard, outputs=dashboard_output)
176
+
177
+ # Assignment Tab
178
+ with gr.Tab("🎯 Task Assignment"):
179
+ gr.Markdown("### Assign pending tasks to optimal users")
180
+ assign_btn = gr.Button("🎯 Assign Tasks", variant="primary")
181
+ assign_output = gr.Markdown()
182
+ assign_btn.click(assign_tasks, outputs=assign_output)
183
+
184
+ # Add User Tab
185
+ with gr.Tab("👤 Add User"):
186
+ gr.Markdown("### Add new team member")
187
+ user_name = gr.Textbox(label="User Name", placeholder="Enter name...")
188
+ add_user_btn = gr.Button("➕ Add User", variant="primary")
189
+ add_user_output = gr.Markdown()
190
+ add_user_btn.click(add_user, inputs=user_name, outputs=add_user_output)
191
+
192
+ # Add Task Tab
193
+ with gr.Tab("📋 Add Task"):
194
+ gr.Markdown("### Add new task")
195
+ with gr.Row():
196
+ task_type = gr.Textbox(label="Task Type", placeholder="e.g., coding, design, research...")
197
+ task_complexity = gr.Slider(0, 1, value=0.5, label="Complexity (0=Easy, 1=Hard)")
198
+ task_deadline = gr.Number(label="Deadline (hours)", value=24)
199
+ add_task_btn = gr.Button("➕ Add Task", variant="primary")
200
+ add_task_output = gr.Markdown()
201
+ add_task_btn.click(add_task, inputs=[task_type, task_complexity, task_deadline], outputs=add_task_output)
202
+
203
+ # Progress Update Tab
204
+ with gr.Tab("📈 Update Progress"):
205
+ gr.Markdown("### Update task progress")
206
+ with gr.Row():
207
+ prog_task_id = gr.Number(label="Task ID", precision=0)
208
+ prog_user_id = gr.Number(label="User ID", precision=0)
209
+ progress_pct = gr.Slider(0, 100, value=50, label="Progress %")
210
+ progress_notes = gr.Textbox(label="Notes (optional)", placeholder="Progress notes...")
211
+ update_prog_btn = gr.Button("📈 Update Progress", variant="primary")
212
+ update_prog_output = gr.Markdown()
213
+ update_prog_btn.click(update_progress, inputs=[prog_task_id, prog_user_id, progress_pct, progress_notes], outputs=update_prog_output)
214
+
215
+ # Complete Task Tab
216
+ with gr.Tab("✅ Complete Task"):
217
+ gr.Markdown("### Mark task as completed")
218
+ with gr.Row():
219
+ comp_task_id = gr.Number(label="Task ID", precision=0)
220
+ comp_user_id = gr.Number(label="User ID", precision=0)
221
+ time_taken = gr.Number(label="Time Taken (hours)", value=1)
222
+ quality_score = gr.Slider(1, 5, value=3, label="Quality (1=Poor, 5=Excellent)", step=1)
223
+ complete_btn = gr.Button("✅ Complete Task", variant="primary")
224
+ complete_output = gr.Markdown()
225
+ complete_btn.click(complete_task, inputs=[comp_task_id, comp_user_id, time_taken, quality_score], outputs=complete_output)
226
+
227
+ # AI Training Tab
228
+ with gr.Tab("🧠 AI Training"):
229
+ gr.Markdown("""
230
+ ### Retrain AI Model
231
+ After completing tasks and entering results, retrain the AI to improve future assignments.
232
+ """)
233
+ retrain_btn = gr.Button("🧠 Retrain AI", variant="primary")
234
+ retrain_output = gr.Markdown()
235
+ retrain_btn.click(retrain_ai, outputs=retrain_output)
236
+
237
+ # Auto-load dashboard on startup
238
+ app.load(show_dashboard, outputs=dashboard_output)
239
+
240
+ if __name__ == "__main__":
241
+ app.launch(share=True, theme=gr.themes.Soft())
assignment_engine.py ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import numpy as np
3
+ from sklearn.ensemble import RandomForestRegressor
4
+ import joblib
5
+ import os
6
+ from datetime import datetime
7
+ import json
8
+
9
+ class TaskAssignmentEngine:
10
+ def __init__(self):
11
+ self.model = None
12
+ self.is_trained = False
13
+ self.results_file = "results.csv"
14
+ self.progress_file = "task_progress.json"
15
+
16
+ def load_data(self):
17
+ """Load users, tasks, and results"""
18
+ self.users = pd.read_csv("users.csv")
19
+ self.tasks = pd.read_csv("tasks.csv")
20
+
21
+ # Load results if exists
22
+ if os.path.exists(self.results_file):
23
+ self.results = pd.read_csv(self.results_file)
24
+ else:
25
+ # Create empty results file
26
+ self.results = pd.DataFrame(columns=['task_id', 'user_id', 'time_taken', 'quality'])
27
+ self.results.to_csv(self.results_file, index=False)
28
+
29
+ # Load progress tracking
30
+ if os.path.exists(self.progress_file):
31
+ with open(self.progress_file, 'r') as f:
32
+ self.progress_data = json.load(f)
33
+ else:
34
+ self.progress_data = {}
35
+ self.save_progress_data()
36
+
37
+ print(f"✅ Loaded {len(self.users)} users, {len(self.tasks)} tasks, {len(self.results)} results")
38
+
39
+ def prepare_training_data(self):
40
+ """Convert results into training data for AI"""
41
+ if len(self.results) == 0:
42
+ print("⚠️ No results data - will use random assignment")
43
+ return None, None
44
+
45
+ # Merge results with task and user data
46
+ training_data = self.results.merge(self.tasks, on='task_id').merge(self.users, on='user_id')
47
+
48
+ # Create features: user_id, complexity, deadline
49
+ X = training_data[['user_id', 'complexity', 'deadline']].values
50
+
51
+ # Create target: success score (quality/5 * efficiency)
52
+ # efficiency = 1 - (time_taken / deadline)
53
+ efficiency = 1 - (training_data['time_taken'] / training_data['deadline'])
54
+ efficiency = np.clip(efficiency, 0, 1) # Keep between 0-1
55
+
56
+ quality_score = training_data['quality'] / 5.0 # Normalize to 0-1
57
+
58
+ # Success = weighted combination of quality and efficiency
59
+ y = (quality_score * 0.7 + efficiency * 0.3) # 70% quality, 30% efficiency
60
+
61
+ print(f"✅ Prepared training data: {len(X)} samples")
62
+ return X, y
63
+
64
+ def train_model(self):
65
+ """Train the AI model"""
66
+ X, y = self.prepare_training_data()
67
+
68
+ if X is None:
69
+ print("⚠️ No training data available")
70
+ return
71
+
72
+ # Train Random Forest model
73
+ self.model = RandomForestRegressor(n_estimators=100, random_state=42)
74
+ self.model.fit(X, y)
75
+ self.is_trained = True
76
+
77
+ # Save model
78
+ joblib.dump(self.model, 'assignment_model.pkl')
79
+ print("✅ Model trained and saved")
80
+
81
+ def load_model(self):
82
+ """Load existing model if available"""
83
+ if os.path.exists('assignment_model.pkl'):
84
+ self.model = joblib.load('assignment_model.pkl')
85
+ self.is_trained = True
86
+ print("✅ Loaded existing model")
87
+
88
+ def predict_success(self, user_id, task_row):
89
+ """Predict success probability for user-task combination"""
90
+ if not self.is_trained:
91
+ # Random assignment if no model
92
+ return np.random.random()
93
+
94
+ features = [[user_id, task_row['complexity'], task_row['deadline']]]
95
+ prediction = self.model.predict(features)[0]
96
+ return max(0, min(1, prediction)) # Ensure 0-1 range
97
+
98
+ def assign_task(self, task_id):
99
+ """Assign a task to the best user"""
100
+ task_row = self.tasks[self.tasks['task_id'] == task_id].iloc[0]
101
+
102
+ best_user = None
103
+ best_score = -1
104
+ predictions = {}
105
+
106
+ for _, user in self.users.iterrows():
107
+ user_id = user['user_id']
108
+
109
+ # Skip if user already has this task assigned
110
+ existing = self.results[
111
+ (self.results['task_id'] == task_id) &
112
+ (self.results['user_id'] == user_id)
113
+ ]
114
+ if len(existing) > 0:
115
+ continue
116
+
117
+ score = self.predict_success(user_id, task_row)
118
+ predictions[user['name']] = score
119
+
120
+ if score > best_score:
121
+ best_score = score
122
+ best_user = user
123
+
124
+ print(f"\n🎯 Task {task_id} ({task_row['type']}) - Complexity: {task_row['complexity']}")
125
+ print("Predictions:")
126
+ for name, score in predictions.items():
127
+ print(f" {name}: {score:.3f}")
128
+
129
+ if best_user is not None:
130
+ print(f"✅ ASSIGNED to {best_user['name']} (confidence: {best_score:.3f})")
131
+ # Track assignment
132
+ self.start_task_tracking(task_id, best_user['user_id'], best_user['name'])
133
+ return best_user['user_id'], best_user['name']
134
+ else:
135
+ print(f"❌ No available users for this task")
136
+ return None, None
137
+
138
+ def save_progress_data(self):
139
+ """Save progress data to JSON file"""
140
+ with open(self.progress_file, 'w') as f:
141
+ json.dump(self.progress_data, f, indent=2, default=str)
142
+
143
+ def start_task_tracking(self, task_id, user_id, user_name):
144
+ """Start tracking a task"""
145
+ task_key = f"{task_id}_{user_id}"
146
+ task_info = self.tasks[self.tasks['task_id'] == task_id].iloc[0]
147
+
148
+ self.progress_data[task_key] = {
149
+ 'task_id': task_id,
150
+ 'user_id': user_id,
151
+ 'user_name': user_name,
152
+ 'task_type': task_info['type'],
153
+ 'complexity': task_info['complexity'],
154
+ 'deadline': task_info['deadline'],
155
+ 'start_time': datetime.now().isoformat(),
156
+ 'status': 'assigned',
157
+ 'progress_updates': [],
158
+ 'completion_time': None
159
+ }
160
+ self.save_progress_data()
161
+ print(f"⏱️ Started tracking: {user_name} → {task_info['type']} (Task {task_id})")
162
+
163
+ def update_task_progress(self, task_id, user_id, progress_percent, notes=""):
164
+ """Update task progress"""
165
+ task_key = f"{task_id}_{user_id}"
166
+
167
+ if task_key not in self.progress_data:
168
+ print(f"❌ Task {task_id} for user {user_id} not found in tracking")
169
+ return
170
+
171
+ update = {
172
+ 'timestamp': datetime.now().isoformat(),
173
+ 'progress_percent': progress_percent,
174
+ 'notes': notes
175
+ }
176
+
177
+ self.progress_data[task_key]['progress_updates'].append(update)
178
+ self.progress_data[task_key]['status'] = 'in_progress' if progress_percent < 100 else 'completed'
179
+
180
+ self.save_progress_data()
181
+
182
+ user_name = self.progress_data[task_key]['user_name']
183
+ task_type = self.progress_data[task_key]['task_type']
184
+ print(f"📈 Progress Update: {user_name} → {task_type} ({progress_percent}%)")
185
+ if notes:
186
+ print(f" Note: {notes}")
187
+
188
+ def add_result(self, task_id, user_id, time_taken, quality):
189
+ """Add task completion result"""
190
+ # Update progress tracking with completion
191
+ task_key = f"{task_id}_{user_id}"
192
+ completion_time = datetime.now()
193
+
194
+ if task_key in self.progress_data:
195
+ self.progress_data[task_key]['completion_time'] = completion_time.isoformat()
196
+ self.progress_data[task_key]['status'] = 'completed'
197
+ self.progress_data[task_key]['actual_time_taken'] = time_taken
198
+
199
+ # Calculate how long it actually took from start
200
+ start_time = datetime.fromisoformat(self.progress_data[task_key]['start_time'])
201
+ actual_duration = (completion_time - start_time).total_seconds() / 3600 # hours
202
+ self.progress_data[task_key]['actual_duration'] = round(actual_duration, 2)
203
+
204
+ self.save_progress_data()
205
+
206
+ new_result = {
207
+ 'task_id': task_id,
208
+ 'user_id': user_id,
209
+ 'time_taken': time_taken,
210
+ 'quality': quality
211
+ }
212
+
213
+ # Add to results dataframe
214
+ self.results = pd.concat([self.results, pd.DataFrame([new_result])], ignore_index=True)
215
+
216
+ # Save to CSV
217
+ self.results.to_csv(self.results_file, index=False)
218
+
219
+ # Get names for display
220
+ task_name = self.tasks[self.tasks['task_id'] == task_id]['type'].iloc[0]
221
+ user_name = self.users[self.users['user_id'] == user_id]['name'].iloc[0]
222
+
223
+ print(f"✅ Task Completed: {user_name} → {task_name} in {time_taken}h with quality {quality}/5")
224
+
225
+ # Show completion analytics
226
+ if task_key in self.progress_data:
227
+ actual_duration = self.progress_data[task_key]['actual_duration']
228
+ deadline = self.progress_data[task_key]['deadline']
229
+ efficiency = (deadline - time_taken) / deadline * 100
230
+ print(f" 📊 Analytics: {actual_duration}h real time, {efficiency:+.1f}% vs deadline")
231
+
232
+ def show_stats(self):
233
+ """Show system statistics"""
234
+ if len(self.results) == 0:
235
+ print("📊 No results yet - system ready for first assignments")
236
+ return
237
+
238
+ print("\n📊 SYSTEM STATISTICS")
239
+ print(f"Total completed tasks: {len(self.results)}")
240
+ print(f"Average quality: {self.results['quality'].mean():.2f}/5")
241
+ print(f"Average time taken: {self.results['time_taken'].mean():.1f}h")
242
+
243
+ # User performance
244
+ user_stats = self.results.merge(self.users, on='user_id').groupby('name').agg({
245
+ 'quality': 'mean',
246
+ 'time_taken': 'mean',
247
+ 'task_id': 'count'
248
+ }).round(2)
249
+ user_stats.columns = ['Avg Quality', 'Avg Time', 'Tasks Done']
250
+ print("\n👥 USER PERFORMANCE")
251
+ print(user_stats)
252
+
253
+ def get_user_skills(self):
254
+ """Discover user skills automatically"""
255
+ if len(self.results) == 0:
256
+ print("No data to analyze skills yet")
257
+ return
258
+
259
+ # Merge with all data
260
+ full_data = self.results.merge(self.tasks, on='task_id').merge(self.users, on='user_id')
261
+
262
+ print("\n🎯 DISCOVERED SKILLS")
263
+ for user_name in full_data['name'].unique():
264
+ user_data = full_data[full_data['name'] == user_name]
265
+
266
+ print(f"\n{user_name}:")
267
+ for task_type in user_data['type'].unique():
268
+ type_data = user_data[user_data['type'] == task_type]
269
+ avg_quality = type_data['quality'].mean()
270
+ avg_time = type_data['time_taken'].mean()
271
+ skill_level = "Expert" if avg_quality >= 4 else "Good" if avg_quality >= 3 else "Learning"
272
+ print(f" {task_type}: {avg_quality:.1f}/5 quality, {avg_time:.1f}h avg ({skill_level})")
273
+
274
+ def show_active_tasks(self):
275
+ """Show currently active/assigned tasks"""
276
+ if not self.progress_data:
277
+ print("📋 No active tasks")
278
+ return
279
+
280
+ active_tasks = [task for task in self.progress_data.values()
281
+ if task['status'] in ['assigned', 'in_progress']]
282
+
283
+ if not active_tasks:
284
+ print("📋 No active tasks")
285
+ return
286
+
287
+ print("\n📋 ACTIVE TASKS")
288
+ print("-" * 50)
289
+
290
+ for task in active_tasks:
291
+ start_time = datetime.fromisoformat(task['start_time'])
292
+ time_elapsed = (datetime.now() - start_time).total_seconds() / 3600
293
+
294
+ status_icon = "🔄" if task['status'] == 'in_progress' else "📋"
295
+
296
+ print(f"{status_icon} Task {task['task_id']}: {task['user_name']} → {task['task_type']}")
297
+ print(f" Complexity: {task['complexity']}, Deadline: {task['deadline']}h")
298
+ print(f" Started: {time_elapsed:.1f}h ago")
299
+
300
+ if task['progress_updates']:
301
+ latest = task['progress_updates'][-1]
302
+ print(f" Progress: {latest['progress_percent']}%")
303
+ if latest['notes']:
304
+ print(f" Note: {latest['notes']}")
305
+
306
+ print("-" * 50)
deploy.bat ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @echo off
2
+ echo 🚀 PREPARING FILES FOR HUGGING FACE DEPLOYMENT
3
+ echo Target: https://huggingface.co/spaces/rishirajpathak/task-management
4
+ echo.
5
+
6
+ echo 📁 Files ready for upload:
7
+ echo.
8
+ dir /b app.py assignment_engine.py task_manager.py requirements.txt README.md users.csv tasks.csv results.csv task_progress.json .gitignore 2>nul
9
+
10
+ echo.
11
+ echo ✅ All files are ready!
12
+ echo.
13
+ echo 📋 NEXT STEPS:
14
+ echo 1. Go to: https://huggingface.co/new-space
15
+ echo 2. Space name: task-management
16
+ echo 3. Owner: rishirajpathak
17
+ echo 4. SDK: Gradio
18
+ echo 5. Upload the files listed above
19
+ echo 6. Your app will be live at: https://huggingface.co/spaces/rishirajpathak/task-management
20
+ echo.
21
+ echo 🚫 DO NOT upload: .venv folder or any .pkl files
22
+ echo.
23
+ pause
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio>=4.0.0
2
+ pandas>=1.5.0
3
+ scikit-learn>=1.0.0
4
+ joblib>=1.0.0
5
+ numpy>=1.20.0
results.csv ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ task_id,user_id,time_taken,quality
2
+ 1,1,8,4
3
+ 2,2,3,5
4
+ 3,3,25,2
5
+ 4,1,6,5
6
+ 5,2,2,5
7
+ 6,1,15,4
task_manager.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from assignment_engine import TaskAssignmentEngine
2
+ import pandas as pd
3
+
4
+ class TaskManager:
5
+ def __init__(self):
6
+ self.engine = TaskAssignmentEngine()
7
+ self.setup()
8
+
9
+ def setup(self):
10
+ """Initialize the system"""
11
+ print("🚀 TASK ASSIGNMENT SYSTEM STARTING...")
12
+ self.engine.load_data()
13
+ self.engine.load_model() # Load existing model if available
14
+
15
+ def assign_tasks(self):
16
+ """Assign all pending tasks"""
17
+ print("\n🎯 ASSIGNING TASKS...")
18
+
19
+ for _, task in self.engine.tasks.iterrows():
20
+ task_id = task['task_id']
21
+
22
+ # Check if task already completed
23
+ completed = self.engine.results[self.engine.results['task_id'] == task_id]
24
+ if len(completed) > 0:
25
+ print(f"Task {task_id} already completed")
26
+ continue
27
+
28
+ user_id, user_name = self.engine.assign_task(task_id)
29
+
30
+ def enter_result(self, task_id, user_id, time_taken, quality):
31
+ """Enter task completion result"""
32
+ self.engine.add_result(task_id, user_id, time_taken, quality)
33
+
34
+ def update_progress(self, task_id, user_id, progress_percent, notes=""):
35
+ """Update task progress"""
36
+ self.engine.update_task_progress(task_id, user_id, progress_percent, notes)
37
+
38
+ def retrain_ai(self):
39
+ """Retrain the AI with new data"""
40
+ print("\n🧠 RETRAINING AI...")
41
+ self.engine.train_model()
42
+
43
+ def show_dashboard(self):
44
+ """Show system dashboard"""
45
+ print("\n" + "="*50)
46
+ print("📋 TASK ASSIGNMENT DASHBOARD")
47
+ print("="*50)
48
+
49
+ self.engine.show_stats()
50
+ self.engine.get_user_skills()
51
+ self.engine.show_active_tasks()
52
+
53
+ print(f"\n🤖 AI Status: {'Trained' if self.engine.is_trained else 'Random Assignment'}")
54
+
55
+ def add_user(self, name):
56
+ """Add new user"""
57
+ new_id = self.engine.users['user_id'].max() + 1
58
+ new_user = pd.DataFrame({'user_id': [new_id], 'name': [name]})
59
+ self.engine.users = pd.concat([self.engine.users, new_user], ignore_index=True)
60
+ self.engine.users.to_csv("users.csv", index=False)
61
+ print(f"✅ Added user: {name} (ID: {new_id})")
62
+
63
+ def add_task(self, task_type, complexity, deadline):
64
+ """Add new task"""
65
+ new_id = self.engine.tasks['task_id'].max() + 1
66
+ new_task = pd.DataFrame({
67
+ 'task_id': [new_id],
68
+ 'type': [task_type],
69
+ 'complexity': [complexity],
70
+ 'deadline': [deadline]
71
+ })
72
+ self.engine.tasks = pd.concat([self.engine.tasks, new_task], ignore_index=True)
73
+ self.engine.tasks.to_csv("tasks.csv", index=False)
74
+ print(f"✅ Added task: {task_type} (ID: {new_id}, Complexity: {complexity}, Deadline: {deadline}h)")
75
+
76
+ if __name__ == "__main__":
77
+ # Example usage
78
+ tm = TaskManager()
79
+ tm.show_dashboard()
80
+ tm.assign_tasks()
task_progress.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "7_2": {
3
+ "task_id": 7,
4
+ "user_id": 2,
5
+ "user_name": "Amit",
6
+ "task_type": "design",
7
+ "complexity": 0.5,
8
+ "deadline": 30.0,
9
+ "start_time": "2026-01-11T13:40:39.520692",
10
+ "status": "assigned",
11
+ "progress_updates": [],
12
+ "completion_time": null
13
+ },
14
+ "8_2": {
15
+ "task_id": 8,
16
+ "user_id": 2,
17
+ "user_name": "Amit",
18
+ "task_type": "add login page",
19
+ "complexity": 1.0,
20
+ "deadline": 6.0,
21
+ "start_time": "2026-01-11T13:40:39.545921",
22
+ "status": "assigned",
23
+ "progress_updates": [],
24
+ "completion_time": null
25
+ }
26
+ }
tasks.csv ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ task_id,type,complexity,deadline
2
+ 1,study,0.6,48.0
3
+ 2,fitness,0.4,24.0
4
+ 3,project,0.9,72.0
5
+ 4,study,0.7,36.0
6
+ 5,fitness,0.3,12.0
7
+ 6,project,0.8,48.0
8
+ 7,design,0.5,30.0
9
+ 8,add login page,1.0,6.0
10
+ 9,login page,0.5,6.0
users.csv ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ user_id,name
2
+ 1,Rishiraj
3
+ 2,Amit
4
+ 3,Rahul
5
+ 4,Priya
6
+ 5,Utkarsh