I'm practicing testing multiple models on the iris dataset with python and I have the following code:
for name, model in models:
# kfold
kfold = KFold(n_splits=10, random_state=7, shuffle=True)
# score
score = cross_val_score(model, X_test, y_test, cv=kfold, scoring='accuracy')
# Add results
results.append(score)
names.append(name)
msg = "%s: %f" % (name,score.mean())
print(msg)
Every time I run this I get slightly different results for the score.mean()
can anyone explain to me why this happens and how to reduce the variability of the results.
I'm new to machine learning so any help would be great. Thanks.