API updates in Logistic Regression example #5770

Open
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+3 −3
Split
@@ -73,12 +73,12 @@
")\n",
"\n",
"# Split into train and test\n",
- "X, Xt, y, yt = sklearn.cross_validation.train_test_split(X, y)\n",
+ "X, Xt, y, yt = sklearn.model_selection.train_test_split(X, y)\n",
"\n",
"# Visualize sample of the data\n",
"ind = np.random.permutation(X.shape[0])[:1000]\n",
"df = pd.DataFrame(X[ind])\n",
- "_ = pd.scatter_matrix(df, figsize=(9, 9), diagonal='kde', marker='o', s=40, alpha=.4, c=y[ind])"
+ "_ = pd.plotting.scatter_matrix(df, figsize=(9, 9), diagonal='kde', marker='o', s=40, alpha=.4, c=y[ind])"
]
},
{
@@ -111,7 +111,7 @@
"%%timeit\n",
"# Train and test the scikit-learn SGD logistic regression.\n",
"clf = sklearn.linear_model.SGDClassifier(\n",
- " loss='log', n_iter=1000, penalty='l2', alpha=5e-4, class_weight='auto')\n",
+ " loss='log', n_iter=1000, penalty='l2', alpha=5e-4, class_weight='balanced')\n",
"\n",
"clf.fit(X, y)\n",
"yt_pred = clf.predict(Xt)\n",