Visualizing Tolerance Values Against Specific Error Metrics in Python
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# Create a DataFrame with the same data
df = pd.DataFrame({
    'C': [100, 100, 1000000],
    'tol': [0.1, 0.05, 0.00001],
    'SPE': [0.90976, 0.91860, 0.92570],
    'SEN': [0.90714, 0.92572, 0.93216]
})

# Group by the index created by floor division with agg, first, and mean
df = df.groupby(np.arange(len(df.index)) // 5) \
       .agg({'C':'first', 'tol':'first', 'SPE':'mean','SEN':'mean'}) \
       .reindex_axis(['C','tol','SPE','SEN'], axis=1) \
       .rename(columns = {'SPE':'mean of SPE','SEN':'mean of SEN'})

# Plot the variables SPE and tol
df1 = df.pivot(index='mean of SPE', columns='tol', values='C')
df1.plot()

# Plot the variables SEN and tol
df2 = df.pivot(index='mean of SEN', columns='tol', values='C')
df2.plot()

This code will create two plots, one for SPE vs tol and one for SEN vs tol, each with a different curve for each value of C. The x-axis represents the mean value of SPE or SEN, and the y-axis represents the corresponding tolerance values.


Last modified on 2023-05-25