Import librairies


In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline

In [5]:
data = pd.read_csv('ex2data2.txt', header=None, names=['microship1', 'microship2', 'y'])
data.head()


Out[5]:
microship1 microship2 y
0 0.051267 0.69956 1
1 -0.092742 0.68494 1
2 -0.213710 0.69225 1
3 -0.375000 0.50219 1
4 -0.513250 0.46564 1

In [7]:
def visualize(x, y, color):
    fig = plt.figure()
    ax = plt.axes()
    ax.scatter(x, y, c=color)
    plt.xlabel('microship1')
    plt.ylabel('microship2')
    plt.show()
visualize(data.microship1, data.microship2, data.y)