November 2019
Intermediate to advanced
346 pages
9h 36m
English
In the following steps, we will build an example-dependent, cost-sensitive classifier using the costcla library on credit card transaction data:
import pandas as pdfraud_df = pd.read_csv("FinancialFraudDB.csv", index_col=None)
card_replacement_cost = 5customer_freeze_cost = 3
import numpy as npcost_matrix = np.zeros((len(fraud_df.index), 4))cost_matrix[:, 0] = customer_freeze_cost * np.ones(len(fraud_df.index))cost_matrix[:, 1] = fraud_df["Amount"].valuescost_matrix[:, 2] = card_replacement_cost * np.ones(len(fraud_df.index))