Professional Documents
Culture Documents
creating a dataset with six features, three classes, and 800 samples using the
make_classification function.
In [1]:
from sklearn.datasets import make_classification
X, y = make_classification(
n_features=6,
n_classes=3,
n_samples=800,
n_informative=2,
random_state=1,
n_clusters_per_class=1,
)
In [2]:
import matplotlib.pyplot as plt
split the dataset into training and testing for model evaluation.
In [9]:
# Predict Output
predicted = model.predict([X_test[6]])
Actual Value: 1
Predicted Value: 1
Predict the values for the test dataset and use them to calculate accuracy and F1 score.
In [10]:
from sklearn.metrics import (
accuracy_score,
confusion_matrix,
ConfusionMatrixDisplay,
f1_score,
classification_report,
)
y_pred = model.predict(X_test)
print("Accuracy:", accuracy)
print("F1 Score:", f1)
Accuracy: 0.8625
F1 Score: 0.862075892857143