One more question! Its easy to see how we can classify obs in 2d graph, but if we have five variables (5d), we cant paint it. Then how can i see how classify my model? for future obs? I know qe can solve this problem with this code but i dont know how translate it. %let n = 5;
data indata;
input x1 x2 x3 x4 x5 y @@;
datalines;
3.435937542 1.910389226 0.276850846 0.364419827 0.140722091 1
1.752885649 1.190057355 0.599295002 0.227447953 0.815532861 1
1.621776734 1.179003553 0.760496315 0.624320514 0.230451018 1
2.575575289 2.999259474 0.620989763 0.828880959 0.034141306 1
1.568690442 1.864722267 0.410446021 0.977573713 0.837272457 1
2.008282532 2.035882912 0.967093924 0.725730786 0.528795923 1
3.150476337 -0.211155573 0.633565936 0.767706516 0.274370632 1
2.412125188 2.459121555 0.40247943 0.205630191 0.303806821 1
2.886648426 1.458100781 0.661861202 0.822914202 0.314037231 1
2.832672695 3.166103391 0.635750146 0.415985331 0.518241769 1
5.435937542 3.910389226 0.220233529 0.909811353 0.611028911 -1
3.752885649 3.190057355 0.090459485 0.686435643 0.218221874 -1
3.621776734 3.179003553 0.797479778 0.201698903 0.062966533 -1
4.575575289 4.999259474 0.344128219 0.054420354 0.009042683 -1
3.568690442 3.864722267 0.748489181 0.989565182 0.4580315 -1
4.008282532 4.035882912 0.460437955 0.287010879 0.200715865 -1
5.150476337 1.788844427 0.155870021 0.000179874 0.993454689 -1
4.412125188 4.459121555 0.543481598 0.639162032 0.571248807 -1
4.886648426 3.458100781 0.400991393 0.274163115 0.118862113 -1
4.832672695 5.166103391 0.333071111 0.391013648 0.446375253 -1
;
run;
proc optmodel;
/* read input */
set OBS;
num n = &n;
num x {OBS, 1..n}, y {OBS};
read data indata into OBS=[_N_] {j in 1..n} <x[_N_,j]=col('x'||j)> y;
/* declare optimization model */
var W {1..n};
var B;
min Z = 0.5 * sum {j in 1..n} W[j]^2;
con Separate {i in OBS}:
y[i] * (sum {j in 1..n} x[i,j]*W[j] - B) >= 1;
/* call QP solver */
solve;
quit;
... View more