LoslegenKostenlos loslegen

Evaluating precision and ROI

In this exercise, you build upon the previous exercise and run an MLPClassifier and compare it to three of the other classifiers run earlier. For each classifier, you will compute the precision and implied ROI on ad spend. As before, we have training and testing splits for X and y as X_train, X_test for X and y_train, y_test for y respectively and the features have already been standardized.

Diese Übung ist Teil des Kurses

Predicting CTR with Machine Learning in Python

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Create list of classifiers
names = ['Logistic Regression',  'Decision Tree',
         'Random Forest', 'Multi-Layer Perceptron']
clfs = [LogisticRegression(), 
        DecisionTreeClassifier(), RandomForestClassifier(), 
        MLPClassifier(hidden_layer_sizes = (5, ), max_iter = 40)]

# Fit each classifier and evaluate AUC of ROC curve 
for name, classifier in zip(names, clfs):
  classifier.____(____, ____)
  y_score = classifier.____(X_test)
  y_pred = classifier.____(X_test) 
  prec = ____(____, y_pred, average = 'weighted')
  print("Precision for %s: %s " %(name, prec))
Code bearbeiten und ausführen