forked from ShaikMustafa/Basic1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
99 lines (81 loc) · 2.87 KB
/
main.py
File metadata and controls
99 lines (81 loc) · 2.87 KB
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
93
94
95
96
97
98
99
import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.pipeline import make_pipeline
import random
# Initialize an empty task list
tasks = pd.DataFrame(columns=['description', 'priority'])
# Load pre-existing tasks from a CSV file (if any)
try:
tasks = pd.read_csv('tasks.csv')
except FileNotFoundError:
pass
# Function to save tasks to a CSV file
def save_tasks():
tasks.to_csv('tasks.csv', index=False)
# Train the task priority classifier
vectorizer = CountVectorizer()
clf = MultinomialNB()
model = make_pipeline(vectorizer, clf)
model.fit(tasks['description'], tasks['priority'])
# Function to add a task to the list
# Function to add a task to the list
# Function to add a task to the list
def add_task(description, priority):
global tasks # Declare tasks as a global variable
new_task = pd.DataFrame({'description': [description], 'priority': [priority]})
tasks = pd.concat([tasks, new_task], ignore_index=True)
save_tasks()
# Function to remove a task by description
def remove_task(description):
global tasks # Declare tasks as a global variable
tasks = tasks[tasks['description'] != description]
save_tasks()
# Function to list all tasks
def list_tasks():
if tasks.empty:
print("No tasks available.")
else:
print(tasks)
# Function to recommend a task based on machine learning
# Function to recommend a task based on machine learning
def recommend_task():
if not tasks.empty:
# Get high-priority tasks
high_priority_tasks = tasks[tasks['priority'] == 'High']
if not high_priority_tasks.empty:
# Choose a random high-priority task
random_task = high_priority_tasks.sample(n=1)
print(f"Recommended task: {random_task['description'].values[0]} - Priority: High")
else:
print("No high-priority tasks available for recommendation.")
else:
print("No tasks available for recommendations.")
4
# Main menu
while True:
print("\nTask Management App")
print("1. Add Task")
print("2. Remove Task")
print("3. List Tasks")
print("4. Recommend Task")
print("5. Exit")
choice = input("Select an option: ")
if choice == "1":
description = input("Enter task description: ")
priority = input("Enter task priority (Low/Medium/High): ").capitalize()
add_task(description, priority)
print("Task added successfully.")
elif choice == "2":
description = input("Enter task description to remove: ")
remove_task(description)
print("Task removed successfully.")
elif choice == "3":
list_tasks()
elif choice == "4":
recommend_task()
elif choice == "5":
print("Goodbye!")
break
else:
print("Invalid option. Please select a valid option.")