Online Scikit-Learn Compiler

Code, compile, and run Scikit-Learn programs online

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier

# Load the iris dataset
iris = load_iris()

# Split the data into training and test sets
X_train, X_test, y_train, y_test = train_test_split(,, test_size=0.2)

# Create a KNeighborsClassifier object
knn = KNeighborsClassifier(n_neighbors=5)

# Fit the model to the training data, y_train)

# Make predictions on the test data
y_pred = knn.predict(X_test)

# Evaluate the model's accuracy
print("Accuracy:", knn.score(X_test, y_test))
AI Prompt