In [65]:
from sklearn import datasets
X, y = datasets.make_classification(n_samples=10000, n_features=2, n_informative=2,n_repeated=0,n_redundant=0, n_classes=2)

In [66]:
print X.shape, y.shape


(10000, 2) (10000,)

In [67]:
import numpy as np
import matplotlib.pyplot as plt
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.05)

In [68]:
print X_train.shape, y_train.shape


(9500, 2) (9500,)

In [69]:
from sklearn.svm import SVC
clf = SVC(kernel='linear')

In [70]:
clf = clf.fit(X_train, y_train)

In [71]:
clf


Out[71]:
SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,
  decision_function_shape=None, degree=3, gamma='auto', kernel='linear',
  max_iter=-1, probability=False, random_state=None, shrinking=True,
  tol=0.001, verbose=False)

In [77]:
clf.coef_
fxy = X_test.T[0] * 0.05390999 + X_test.T[1]*1.44377091

In [74]:
y_pred = clf.predict(X_test)

In [75]:
print y_test


[0 0 0 0 1 1 1 1 0 1 0 1 1 0 0 0 1 1 1 0 1 0 1 1 0 0 0 0 1 0 0 1 0 0 0 1 1
 1 1 0 0 0 1 1 0 0 1 0 1 1 1 0 1 0 1 0 1 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 1 0
 1 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 1 0 1
 0 0 1 1 1 1 1 0 1 0 1 1 0 1 0 0 0 1 1 1 0 1 0 1 0 1 0 0 1 1 0 0 0 0 0 0 1
 1 0 1 0 0 0 0 1 1 0 0 0 1 0 1 0 0 1 0 1 0 1 1 1 0 0 1 0 0 0 1 1 0 1 1 0 1
 1 1 0 0 1 1 0 0 1 1 0 1 0 1 1 1 1 0 1 1 0 1 1 0 1 1 1 0 1 1 1 0 1 1 0 0 0
 0 0 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 0 0 0 1 1 0 1 0 1 1 0 1 1 0 1 1 0 1 1 0
 0 0 1 1 0 1 1 1 0 1 1 1 1 0 1 0 0 1 1 1 1 0 1 0 1 1 0 1 1 1 1 1 0 1 1 1 1
 1 0 0 1 1 1 1 1 0 1 0 0 0 1 1 1 0 0 1 1 1 0 1 0 0 0 1 0 1 1 0 0 1 1 1 1 1
 0 1 0 0 1 1 0 1 0 1 1 1 0 0 0 0 0 0 1 0 0 1 1 0 0 0 1 1 1 1 0 1 0 0 1 1 1
 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 0 1 0 1 0 0 1 1 1 0 0 1 1 1 0 0 0 1 0 0 0
 1 1 0 1 1 1 0 0 1 1 0 0 1 0 1 0 1 1 0 0 0 0 0 0 1 1 0 1 0 0 1 1 1 0 0 0 0
 1 1 1 1 1 0 0 0 1 1 0 0 0 1 0 1 0 1 1 1 0 1 1 0 0 1 1 0 1 1 0 1 1 0 0 0 0
 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0 0 0 1 0]

In [83]:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(figsize=(20,20))
ax = fig.add_subplot(111, projection='3d')
ax.scatter(X_test.T[0][y_test == 1],X_test.T[1][y_test == 1],y_test[y_test == 1], c='b')
ax.scatter(X_test.T[0][y_test == 0],X_test.T[1][y_test == 0],y_test[y_test == 0], c='r')


Out[83]:
<mpl_toolkits.mplot3d.art3d.Patch3DCollection at 0x7f818762c5d0>

In [79]:
fxy


Out[79]:
array([-1.85772484, -2.03713246, -1.73799167, -0.56599725,  3.10887447,
        0.09149489,  1.44314323,  0.93566345, -1.70386602,  2.34891265,
        1.04193115,  1.99925874,  1.56944465, -1.68166295, -3.58463468,
       -0.22337617,  0.22977519,  2.25597716,  2.75933594, -1.49768848,
        0.74868966, -1.16893567,  2.74590296,  4.02776905, -2.69222678,
       -1.4723831 , -1.53413688, -2.10740474,  1.25765434, -1.42720993,
       -0.88944446,  0.49761041, -1.98676171, -1.22299303, -2.86276199,
       -0.10933267,  0.32424519, -1.00350864,  1.07815676, -1.55925241,
       -1.09402194, -1.68445853,  0.53614289,  0.73628945, -1.00540325,
        0.34914406, -1.45183734, -0.54475339,  0.12284056,  4.57601638,
        5.04772587, -0.79502459, -0.43429223, -1.25223572,  2.3182777 ,
       -2.6650258 , -0.93265312, -0.59899664, -1.61421621, -2.63449163,
       -0.59808679, -0.74773957,  2.33795638, -0.87253117, -1.12802294,
       -2.4595588 ,  0.47484859, -1.58404545, -1.8881585 , -0.96542695,
       -3.43951715,  0.45031694,  1.12996918, -2.25028025,  0.78676403,
       -0.1521939 ,  1.88761104, -0.93994878,  4.82707926, -1.58455994,
       -1.47657497, -1.15351077, -1.07949264, -1.20473363,  2.87635306,
        0.58155145,  1.02550226, -1.12473924, -2.06890276, -1.42545756,
       -2.60353552,  1.53641514, -1.66146634,  1.37612882, -0.55530881,
        3.40936725, -2.00652775,  3.42554883, -3.31797447,  0.47276628,
       -1.97164571, -1.38592399, -1.19483907,  0.57952876, -1.74543787,
        4.20414045, -2.31202568,  1.57316514,  1.31585646, -1.42839893,
        2.82851915, -3.03713577, -1.64445726,  2.85401749, -0.2775073 ,
       -1.89145124,  1.2992946 ,  2.33607954, -1.18047593,  1.89564494,
       -0.24636645,  4.40089836,  1.72617222, -1.87628783,  2.06185552,
       -2.11168199,  0.53868581, -1.72492903, -1.44331931,  6.39120209,
        0.62602149, -2.83614623,  3.11863773, -0.40443537,  0.06668322,
       -1.21606371,  3.21523675, -0.22642744, -3.26562739,  3.05842815,
        2.05547442, -0.58301627, -2.97759046, -1.21868905, -1.31449501,
       -1.24447557, -1.39940831,  5.0204982 ,  0.20858931, -1.61637243,
        2.74467806, -1.21875028, -1.76422151, -0.67834323, -0.69613575,
       -0.15562467,  2.86000216, -0.89383732, -1.8083195 , -2.4262491 ,
        3.02030919, -1.58064472,  1.84882623, -1.49855569,  0.61145745,
        1.27204883, -3.37529387, -0.2678598 , -1.10960648,  0.92410289,
        2.09970544,  0.97915512, -0.22381797, -1.49579081,  1.06391968,
       -2.57753093, -2.26150939, -0.25288734,  0.70183796,  1.670442  ,
       -1.52782613,  1.76862967,  0.09646208, -2.63722739,  4.45541492,
        0.82012787,  1.70407894, -1.60239762, -2.73017179, -1.31375103,
       -2.88474476, -2.17063409, -0.23295872,  2.39558976, -0.16865225,
        0.80507531,  0.19275393, -0.76137982, -5.21002415, -0.76934167,
        1.7533606 ,  0.58986527, -1.31790178,  2.80569164,  2.94864516,
       -1.29308568, -0.8501434 ,  0.25973608, -1.2370245 ,  2.76582265,
        0.2227845 ,  0.7749762 , -2.34312691,  1.62022582, -0.73840987,
        3.77754034, -1.8407381 ,  1.28685566, -0.95772179, -0.08485133,
       -1.24091482, -2.02053682, -0.61312761, -0.93802982,  1.27123709,
        2.29359119,  1.37489575, -1.79160285,  0.54039744, -4.91889271,
        1.49633883, -0.86348839, -1.21306386,  1.54275095, -1.95148648,
        2.15745844,  1.11623574,  0.88507354,  2.95949746, -0.44647268,
       -1.96005068, -0.93943816,  1.92107649,  3.62370687, -0.85532619,
        0.65759629, -1.42602353,  2.6464037 ,  1.92669762, -0.73849774,
       -1.41071403,  2.29293581, -1.89355067, -0.1115986 ,  2.77240614,
       -3.32554007, -0.21371662, -0.39294308, -2.93254602, -0.25861252,
       -0.32663506,  2.02276512,  0.69158404, -0.6864624 , -0.90508742,
        2.95338446, -2.37397939, -1.05873094,  2.8068621 ,  3.64397589,
        0.47063088,  0.97882645, -2.14633472,  3.83945983, -0.53551677,
       -0.85286642,  0.3457059 ,  2.25735317, -0.48831907,  0.30079398,
       -1.30843036, -0.94167553, -1.86676346, -0.02862307,  1.47313307,
       -0.78621902,  1.56593206, -0.03377011, -1.13222443, -0.1318761 ,
        3.21506725, -2.31042064, -2.61603028,  0.97945539,  1.55636999,
        0.46589031,  2.38947997, -1.25376223, -2.23896699,  2.62674634,
        4.19954415,  4.49760973,  3.21228381, -1.17085031, -0.51144268,
        3.39349146,  1.76813596, -2.31391672, -0.34232039,  3.33122398,
       -0.09886334,  0.39707806, -0.47581757, -0.98714956,  0.91237716,
        2.32919302,  6.01322563, -1.14565412,  1.53372861, -1.55879044,
       -3.93797478, -2.24367166, -0.03066717, -0.69589382,  3.46962572,
        0.72101249,  0.46691175, -1.61180143, -3.12098672,  0.29778506,
        2.31416043,  1.64281611,  1.88496202, -1.8026261 ,  2.12676533,
       -1.0694828 ,  0.27751427,  0.71515606,  1.04780665, -2.64990971,
        1.84813697, -2.21932261,  0.43339759, -2.63090899, -1.29350394,
       -1.43114921, -0.78173038, -2.14303199, -1.64645785,  0.24904247,
       -2.4248746 ,  2.33262519, -1.34688634, -1.69939559,  3.31147793,
       -1.36369582, -1.11798945, -0.9048655 ,  0.76954512, -1.16761336,
        1.67959289, -0.16306159,  1.82307797, -1.48594496,  2.61357661,
       -0.58000957, -0.57960492,  6.42357477,  3.28833769,  2.06292065,
        1.77221102, -1.42693154, -3.0729614 , -0.28936754, -2.14997408,
       -1.97792842,  1.92359895,  0.04467625,  3.75891919, -1.75494531,
       -1.15201557, -1.5108533 , -2.37321671,  0.85974086,  3.84372976,
        1.33557361, -1.05066731, -1.28150454, -1.55800651,  1.79418431,
       -1.07777829, -4.08470455,  0.50160843,  6.45689304, -1.24512086,
       -1.26554071, -1.14151767,  3.37442597,  1.44098385,  0.86187106,
       -1.96187534, -1.91455802, -0.37273998,  1.91355974, -0.80787749,
       -2.95091124,  0.05054755,  0.91791209, -1.9359218 , -0.85861161,
        0.4509615 ,  1.83682795,  2.92384962, -0.84270308, -1.94285545,
        2.62879542, -1.65076018, -0.79267282, -1.24629263,  0.68027092,
       -3.06025831,  0.55567321, -3.56006253, -1.34027435,  1.29537026,
       -1.74828098, -0.09455522, -2.4379866 , -1.26257814, -1.3402734 ,
       -1.41392547,  2.37944899,  1.79943738, -0.57089872,  3.66886207,
        0.47959041, -2.87184999,  2.71137446,  2.64913204,  3.15649799,
       -4.69919197, -1.99218698, -0.30695872, -1.38554218,  0.222889  ,
        1.9780409 ,  2.98326426,  4.61864188,  3.00200989, -0.11381509,
        0.16653171, -1.6281692 , -1.8103118 ,  4.71697609, -1.83975745,
       -0.32228099, -1.57131459,  1.23865188, -2.21248596,  2.62240799,
       -1.21282965,  3.44377869,  2.96748761,  2.23098606, -1.56840026,
       -1.0819231 , -1.31299778, -0.82306442,  0.23527903,  2.2357239 ,
        3.87059688, -2.67284265,  0.86074926,  4.03997315, -1.8308677 ,
        4.38261951,  0.7872619 , -2.15517288, -2.0856926 ,  1.42045692,
       -0.85904114, -0.54618229,  2.59064947, -0.41331548, -1.76865851,
       -0.2659286 , -0.6395213 , -2.83233188, -1.01937742, -1.90964638,
        0.35094178, -1.2905772 , -0.16194998, -1.18416797, -2.09521854,
       -2.54989741, -1.06646015, -0.58638132,  1.64808504, -1.86296994])

In [ ]: