albahnsen / CostSensitiveClassification

CostSensitiveClassification Library in Python
BSD 3-Clause "New" or "Revised" License
207 stars 83 forks source link

Calculation of cost saving #24

Open andremarco opened 4 years ago

andremarco commented 4 years ago

Hello, thank you very much for the project. I am trying to apply a cost-sensitive learning approach to a marketing problem, where a False Negative (the record is predicted as no-customer, whereas he currently is a customer) is much worse than the opposite. As you can see, the cost-matrix is not example dependent, but class-dependent. I create the example-dependent cost-matrix such the following (it is an example for the first 4 records):

FP FN TP TN
1 2 60 0 0
2 2 60 0 0
3 2 60 0 0
4 2 60 0 0

When I calculate the savings_score() function I get a negative score. Which is the meaning of the 1-cost at the numerator?

I am referring to the following piece of code:

cost = cost_loss(y_true, y_pred, cost_mat)
    return 1.0 - cost / cost_base

The cost value is not normalized, so I really don't understand the meaning of doing 1-. Thank you very much!

albahnsen commented 4 years ago

that is a fair question. Allow me to check it and get back to you.

andremarco commented 4 years ago

ok, thank you very much!