cost funtion for logical regression