Skip to content

Instantly share code, notes, and snippets.

View TetsuyaYoshimoto's full-sized avatar

yt TetsuyaYoshimoto

View GitHub Profile
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))])
@TetsuyaYoshimoto
TetsuyaYoshimoto / 3-6.py
Last active February 13, 2017 07:04
3-6.py
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()
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):
#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