Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Task Scheduling & Time Management.py #306

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Task Scheduling & Time Management.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score

# Load the dataset (assumed to be a CSV file)
# Example dataset can be downloaded from Kaggle, for example, "Task Completion Prediction"
# Replace the path with your local dataset file
df = pd.read_csv('tasks_dataset.csv')

# Assume the dataset has columns: urgency, importance, deadline_hours_left, task_length_hours, priority
# Preview the dataset to understand its structure
print(df.head())

# Features and labels (adjust based on actual column names from the dataset)
X = df[['urgency', 'importance', 'deadline_hours_left', 'task_length_hours']] # Features
y = df['priority'] # Priority labels (1 for high priority, 0 for low)

# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Initialize the Random Forest Classifier
clf = RandomForestClassifier()

# Train the model
clf.fit(X_train, y_train)

# Predict priorities for the test set
y_pred = clf.predict(X_test)

# Calculate and print the accuracy of the model
accuracy = accuracy_score(y_test, y_pred)
print(f'Accuracy: {accuracy * 100:.2f}%')

# Test the model with a new task (provide actual values for urgency, importance, etc.)
new_task = [[4, 5, 8, 2]] # Example: [urgency, importance, deadline_hours_left, task_length_hours]
predicted_priority = clf.predict(new_task)
print(f'Predicted priority for the new task: {"High" if predicted_priority[0] == 1 else "Low"}')

# Feature importance to understand how the model prioritizes tasks
feature_importances = clf.feature_importances_
for feature, importance in zip(X.columns, feature_importances):
print(f'Feature: {feature}, Importance: {importance}')