BaşlayınÜcretsiz başlayın

Predicting mushroom edibility

Now that you have explored the data, it's time to build a first model to predict mushroom edibility.

The dataset is available to you as mushrooms. As both the features and the target are categorical, these have been transformed into "dummy" binary variables for you.

Let's begin with Naive Bayes (using scikit-learn's GaussianNB) and see how this algorithm performs on this problem.

Bu egzersiz, kursun bir parçasıdır

Ensemble Methods in Python

Kursa Göz Atın

Egzersiz talimatları

  • Instantiate a GaussianNB classifier called clf_nb.
  • Fit clf_nb to the training data X_train and y_train.
  • Calculate the predictions on the test set. These predictions will be used to evaluate the performance using the accuracy score.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

# Instantiate a Naive Bayes classifier
clf_nb = ____

# Fit the model to the training set
____

# Calculate the predictions on the test set
pred = ____

# Evaluate the performance using the accuracy score
print("Accuracy: {:0.4f}".format(accuracy_score(y_test, pred)))
Kodu Düzenle ve Çalıştır