# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Extract the false positive rate, true positive rate and threshold values from the receiver operating characteristic (ROC) curve generated by a ClassifierMeasurementsObject

Contributed by:
Seth J. Chandler

ResourceFunction["ROCPoints3D"][ takes a ClassifierMeasurementsObject | |

ResourceFunction["ROCPoints3D"][ produces a list of the points constituting the receiver operating characteristic curve for |

Generate the ROC points for each possible positive class of the ClassifierMeasurementsObject:

In[1]:= |

Out[1]= |

Generate the ROC points for a designated positive class:

In[2]:= |

Out[2]= |

The ClassifierMeasurementsObject can also be generated by running a pre-built classifier against test data:

In[3]:= |

Out[3]= |

Create two three dimensional ROC curves showing how well a classifier performs on men and women on board the *Titanic*:

In[4]:= |

Out[4]= |

Smooth the ROC curves by inserting MovingAverage into the operator pipeline:

In[5]:= |

Out[5]= |

By viewing a three dimensional ROC curve from the top with an orthographic perspective, one gets the equivalent of a traditional, two-dimensional ROC curve:

In[6]:= |

Out[6]= |

Compare the relationship between threshold and false positive rate and threshold and true positive rate when "survived" is the positive class:

In[7]:= |

Out[7]= |

Find a formula that approximates the relationship between threshold and false positive rate:

In[8]:= |

Out[8]= |

Compare ROC curves for classifiers examining the *Titanic* data when each gender gets its own classifier, to ROC curves created when a classifier built on all the data is then applied to each gender. Notice that the false positive rates and true positive rates when the threshold equals 0.5 differ depending on which approach is taken.

Build the unified classifier' s ROC curves for each gender:

In[9]:= |

Out[9]= |

Generate separate training datasets for each gender and build a classifier for each:

Generate the three dimensional ROC curve for each gender when the gender-specific classifiers are applied:

In[10]:= |

Out[10]= |

Compare the unified and gender-specific classifiers' ROC curves in three dimensions and show where they intersect a plane with a threshold value of 0.5:

In[11]:= |

Out[11]= |

- 1.0.0 – 19 April 2021

This work is licensed under a Creative Commons Attribution 4.0 International License