81f2324c9196ccc143ec967d91139708456395bf
3 # -*- coding: utf-8 -*-
5 from numpy
.random
import rand
11 Generates a 2D linearly separable dataset with 2n samples.
12 The third element of the sample is the label
14 xb
= (rand(n
) * 2 - 1) / 2 - 0.6
15 yb
= (rand(n
) * 2 - 1) / 2 + 0.6
16 xr
= (rand(n
) * 2 - 1) / 2 + 0.6
17 yr
= (rand(n
) * 2 - 1) / 2 - 0.6
20 inputs
.append([xb
[i
], yb
[i
], -1])
21 inputs
.append([xr
[i
], yr
[i
], 1])
25 training_set
= generateData(100)
26 data
= np
.array(training_set
)
30 pl
.scatter(X
[:, 0], X
[:, 1], c
=Y
, s
=100)