This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib.colors import ListedColormap | |
import matplotlib.pyplot as plt | |
import numpy as np | |
def plot_decision_regions(X, y, classifier=None, test_idx=None, resolution=0.02): | |
markers = ("s", "x", "o", "^", "v") | |
colors = ("red", "blue", "lightgreen", "gray", "cyan") | |
cmap = ListedColormap(colors[:len(np.unique(y))]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.tree import DecisionTreeClassifier | |
from sklearn.tree import export_graphviz | |
from sklearn.cross_validation import train_test_split | |
from sklearn import datasets | |
import matplotlib.pyplot as plt | |
import myplot as plt2 | |
def main(): | |
#datasets | |
iris = datasets.load_iris() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Perceptron(object): | |
def __init__(self, eta=0.01, n_iter=10): | |
self.eta = eta | |
self.n_iter = n_iter | |
def fit(self, X, y): | |
self.w_ = np.zeros(1 + X.shape[1]) | |
self.errors_ = [] | |
for _ in range(self.n_iter): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding=utf-8 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.colors import ListedColormap | |
from sklearn import datasets | |
class Perceptron(object): | |
def __init__(self, eta=0.01, n_iter=10): | |
self.eta = eta |