Decision tree:
import pandas as pd
from sklearn.model_selection import train_test_split
from [Link] import DecisionTreeClassifier
from [Link] import accuracy_score, classification_report
# Load and preprocess data
data = pd.read_csv('[Link]')
# Convert date column to datetime with explicit format or dayfirst
data['date'] = pd.to_datetime(data['date'], format='%d-%m-%Y')
# Extract features
data['Month'] = data['date'].[Link]
data['Year'] = data['date'].[Link]
# Create target variable based on threshold
threshold = 5
data['Rainy Day'] = (data['value'] >= threshold).astype(int)
# Prepare features (X) and target (y)
X = data[['Month', 'Year']]
y = data['Rainy Day']
# Split data into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Train Decision Tree model
model = DecisionTreeClassifier()
[Link](X_train, y_train)
# Evaluate model
y_pred = [Link](X_test)
accuracy = accuracy_score(y_test, y_pred)
report = classification_report(y_test, y_pred)
print('Accuracy:', accuracy)
print(report)
# Predict for a future date
future_date = pd.to_datetime('2025-02-03')
future_features = [Link]({'Month': [future_date.month], 'Year': [future_date.year]})
future_prediction = [Link](future_features)
print('Predicted class for', future_date.date(), ':', future_prediction[0])