3 ms·
why do people do this: def compute_score(clf, X, y,scoring='accuracy'): xval = cross_val_score(clf, X, y, cv = 5,scoring=scoring) ret
by in9 9y ago
why do people do this:
def compute_score(clf, X, y,scoring='accuracy'):
xval = cross_val_score(clf, X, y, cv = 5,scoring=scoring)
return np.mean(xval)
when they could have done:
np.mean(cross_val_score(clf, X, y, cv = 5,scoring='accuracy'))
- 88e282102ae2e5b 9y agoIt conveys intent better. The function name is effectively a way of documenting what the result of np.mean should be interpreted as. xval is a terrible name, but it does make it easier to see what's being passed into np.mean.
- mmierz 9y agoA) they find it more readable to have less stuff on each line B) they think they might want to look at the intermediate results, or compute additional statistics