How to get a Ranking Tile with Sorbetto?

[1]:
import matplotlib.pyplot as plt
[2]:
from sorbetto.performance.two_class_classification_performance import (
    TwoClassClassificationPerformance,
)
from sorbetto.core.entity import Entity
from sorbetto.tile.ranking_tile import RankingTile
from sorbetto.flavor.ranking_flavor import RankingFlavor
from sorbetto.parameterization.parameterization_default import ParameterizationDefault

Define entity 1

[3]:
# Define the performance
proba_tn = 0.4
proba_fp = 0.045
proba_fn = 0.055
proba_tp = 0.5

# Create a performance object
performance1 = TwoClassClassificationPerformance(
    ptn=proba_tn, pfp=proba_fp, pfn=proba_fn, ptp=proba_tp
)

# Create an entity object
entity1 = Entity(performance1)

Define entity 2

[4]:
# Define the performance
proba_tn = 0.3
proba_fp = 0.055
proba_fn = 0.045
proba_tp = 0.6

# Create a performance object
performance2 = TwoClassClassificationPerformance(
    ptn=proba_tn, pfp=proba_fp, pfn=proba_fn, ptp=proba_tp
)

# Create an entity object
entity2 = Entity(performance2)

Define entity 3

[5]:
# Define the performance
proba_tn = 0.3
proba_fp = 0.16
proba_fn = 0.14
proba_tp = 0.4

# Create a performance object
performance3 = TwoClassClassificationPerformance(
    ptn=proba_tn, pfp=proba_fp, pfn=proba_fn, ptp=proba_tp
)

# Create an entity object
entity3 = Entity(performance3)

Get Ranking Tile for entity 1

[6]:
# Create the flavor object
flavor = RankingFlavor(entity=entity1, entity_list=[entity1, entity2, entity3])

# Create the tile object
tile = RankingTile(
    parameterization=ParameterizationDefault(),
    flavor=flavor,
    name="Ranking Tile for entity 1",
)

# Draw the entity tile
fig, ax = tile.draw()
plt.show()
../../_images/src_examples_ranking_tile_10_0.png