Defining a custom metric for classification