print(" _score of random forest{ }formatf _score(y_testrf predict(x_test)))print(" _score of svc{ }format( _score(y_testsvc predict(x_test)))out[ ] _score of random forest _score of svc comparing two precision-recall curves provides lot of detailed insightbut is fairly manual process for automatic model comparisonwe might want to summarize the information contained in the curvewithout limiting ourselves to particular threshold or operating point one particular way to summarize the precision-recall curve is by computing the integral or area under the curve of the precision-recall curvealso known as the average precision you can use the average_precision_score function to compute the average precision because we need to compute the roc curve and consider multiple thresholdsthe result of decision_function or predict_proba needs to be passed to average_precision_scorenot the result of predictin[ ]from sklearn metrics import average_precision_score ap_rf average_precision_score(y_testrf predict_proba(x_test)[: ]ap_svc average_precision_score(y_testsvc decision_function(x_test)print("average precision of random forest{ }format(ap_rf)print("average precision of svc{ }format(ap_svc)out[ ]average precision of random forest average precision of svc when averaging over all possible thresholdswe see that the random forest and svc perform similarly wellwith the random forest even slightly ahead this is quite different from the result we got from _score earlier because average precision is the area under curve that goes from to average precision always returns value between (worstand (bestthe average precision of classifier that assigns decision_function at random is the fraction of positive samples in the dataset receiver operating characteristics (rocand auc there is another tool that is commonly used to analyze the behavior of classifiers at different thresholdsthe receiver operating characteristics curveor roc curve for short similar to the precision-recall curvethe roc curve considers all possible there are some minor technical differences between the area under the precision-recall curve and average precision howeverthis explanation conveys the general idea model evaluation and improvement