MCPcopy Index your code
hub / github.com/ujjwalkarn/DataSciencePython / cv_loop

Function cv_loop

Logistic-Regression/logistic_regression_updated.py:67–78  ·  view source on GitHub ↗
(X, y, model, N)

Source from the content-addressed store, hash-verified

65
66# This loop essentially from Paul's starter code
67def cv_loop(X, y, model, N):
68 mean_auc = 0.
69 for i in range(N):
70 X_train, X_cv, y_train, y_cv = cross_validation.train_test_split(
71 X, y, test_size=.20,
72 random_state = i*SEED)
73 model.fit(X_train, y_train)
74 preds = model.predict_proba(X_cv)[:,1]
75 auc = metrics.auc_score(y_cv, preds)
76 print "AUC (fold %d/%d): %f" % (i + 1, N, auc)
77 mean_auc += auc
78 return mean_auc/N
79
80def main(train='train.csv', test='test.csv', submit='logistic_pred.csv'):
81 print "Reading dataset..."

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected