We can evaluate the performance of an algorithm of a classification problem using the logistic loss function. The logistic loss of a classification algorithm is given by the following formula:
We can use the following Python code to calculate log loss for a classification problem.
from sklearn.model_selection import KFold
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import cross_val_score
import pandas
data = pandas.read_csv("diabetes.csv")
D = data.values
X = D[:, :-1]
y = D[:, -1]
k_fold = KFold(n_splits=10, shuffle=True, random_state=1)
classifier = LogisticRegression(solver="liblinear")
results = cross_val_score(classifier, X, y, cv=k_fold, scoring="neg_log_loss")
mean_score = results.mean()
print("Negative Log Loss: ", mean_score)
Here, we are first using the pandas Python library to read the Pima Indians Diabetes dataset. The dataset contains various …








































0 Comments