Skip to content

Commit 2284d50

Browse files
committed
fixes to tree plot, remove unused function in knn plot
1 parent 9374880 commit 2284d50

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

mglearn/plot_interactive_tree.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def tree_image(tree, fout=None):
2626
dot_data = StringIO()
2727
export_graphviz(tree, out_file=dot_data, max_depth=3, impurity=False)
2828
data = dot_data.getvalue()
29-
#data = re.sub(r"gini = 0\.[0-9]+\\n", "", dot_data.getvalue())
3029
data = re.sub(r"samples = [0-9]+\\n", "", data)
3130
data = re.sub(r"\\nsamples = [0-9]+", "", data)
3231
data = re.sub(r"value", "counts", data)
@@ -43,8 +42,9 @@ def plot_tree_progressive():
4342
plt.figure()
4443
ax = plt.gca()
4544
discrete_scatter(X[:, 0], X[:, 1], y, ax=ax)
46-
ax.set_xticks(())
47-
ax.set_yticks(())
45+
ax.set_xlabel("Feature 0")
46+
ax.set_ylabel("Feature 1")
47+
plt.legend(["Class 0", "Class 1"], loc='best')
4848

4949
axes = []
5050
for i in range(3):

mglearn/plot_kneighbors_regularization.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
from sklearn.neighbors import KNeighborsRegressor
55

66

7-
8-
def plot_regression_datasets():
9-
fig, axes = plt.subplots(1, 3, figsize=(15, 5))
10-
for n_samples, ax in zip([10, 100, 1000], axes):
11-
x, y = make_dataset(n_samples)
12-
ax.plot(x, y, 'o', alpha=.6)
13-
14-
157
def plot_kneighbors_regularization():
168
rnd = np.random.RandomState(42)
179
x = np.linspace(-3, 3, 100)
@@ -32,6 +24,7 @@ def plot_kneighbors_regularization():
3224
ax.legend()
3325
ax.set_title("n_neighbors = %d" % n_neighbors)
3426

27+
3528
if __name__ == "__main__":
3629
plot_kneighbors_regularization()
3730
plt.show()

0 commit comments

Comments
 (0)