import random
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
# Sample data: each task has features and the best tool label
# Features: [task_type_encoded, task_difficulty]
# Labels: tool_id
# Example dataset
X = [
[0, 1], [0, 2], [1, 1], [1, 3], [2, 2], [2, 3], [0, 1], [1, 2], [2, 1], [0, 3]
]
y = [0, 0, 1, 1, 2, 2, 0, 1, 2, 0] # best tool for each task
# Split data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
# Train decision tree to predict best tool
model = DecisionTreeClassifier(random_state=42)
model.fit(X_train, y_train)
# Predict on test set
y_pred = model.predict(X_test)
# Calculate tool selection accuracy
tool_selection_accuracy = accuracy_score(y_test, y_pred) * 100
# Simulate task success rate assuming correct tool leads to success
# and incorrect tool leads to failure
success_rate = tool_selection_accuracy # Simplified assumption
print(f"Tool selection accuracy: {tool_selection_accuracy:.2f}%")
print(f"Task success rate: {success_rate:.2f}%")