12 #define DEFAULT_PARAM "-t 2 -c 100" 46 gdk_colormap_alloc_colors(
47 gdk_colormap_get_system(),
56 gdk_gc_set_foreground(
gc,&
colors[0]);
63 gdk_draw_pixmap(widget->window,
85 gdk_gc_set_foreground(
gc,&
colors[0]);
126 const char *p = gtk_entry_get_text(GTK_ENTRY(
entry_option));
129 while (*p && *p !=
'-')
147 param.
gamma = atof(p);
150 param.
coef0 = atof(p);
178 while(*p && !isspace(*p)) ++p;
188 prob.
y =
new double[prob.
l];
203 x_space[2 * i].
index = 1;
204 x_space[2 * i].
value = q->x;
205 x_space[2 * i + 1].
index = -1;
206 prob.
x[i] = &x_space[2 * i];
215 int *j =
new int[
XLEN];
217 for (i = 0; i <
XLEN; i++)
219 x[0].
value = (double) i / XLEN;
223 gdk_gc_set_foreground(
gc,&
colors[0]);
227 int p = (int)(param.
p *
YLEN);
228 for(i = 1; i <
XLEN; i++)
230 gdk_gc_set_foreground(
gc,&
colors[0]);
234 gdk_gc_set_foreground(
gc,&
colors[5]);
235 gdk_draw_line(
pixmap,
gc,i-1,j[i-1],i,j[i]);
236 gdk_draw_line(
draw_main->window,
gc,i-1,j[i-1],i,j[i]);
240 gdk_gc_set_foreground(
gc,&
colors[2]);
241 gdk_draw_line(
pixmap,
gc,i-1,j[i-1]+p,i,j[i]+p);
242 gdk_draw_line(
draw_main->window,
gc,i-1,j[i-1]+p,i,j[i]+p);
244 gdk_gc_set_foreground(
gc,&
colors[2]);
245 gdk_draw_line(
pixmap,
gc,i-1,j[i-1]-p,i,j[i]-p);
246 gdk_draw_line(
draw_main->window,
gc,i-1,j[i-1]-p,i,j[i]-p);
265 x_space[3 * i].
index = 1;
266 x_space[3 * i].
value = q->x;
267 x_space[3 * i + 1].
index = 2;
268 x_space[3 * i + 1].
value = q->y;
269 x_space[3 * i + 2].
index = -1;
270 prob.
x[i] = &x_space[3 * i];
271 prob.
y[i] = q->value;
281 for (i = 0; i <
XLEN; i++)
282 for (j = 0; j <
YLEN; j++) {
283 x[0].
value = (double) i / XLEN;
284 x[1].
value = (double) j / YLEN;
287 gdk_gc_set_foreground(
gc,&
colors[(
int)d]);
318 GdkEventButton *event,
329 GdkEventExpose *event,
333 event->area.x, event->area.y,
334 event->area.width, event->area.height);
344 gtk_signal_connect_object(
346 "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy),
349 gtk_signal_connect_object (GTK_OBJECT
351 "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy),
383 FILE *fp = fopen(filename,
"w");
385 const char *p = gtk_entry_get_text(GTK_ENTRY(
entry_option));
386 const char* svm_type_str = strstr(p,
"-s ");
387 int svm_type =
C_SVC;
388 if(svm_type_str != NULL)
389 sscanf(svm_type_str,
"-s %d", &svm_type);
396 fprintf(fp,
"%f 1:%f\n", p->y, p->x);
401 fprintf(fp,
"%d 1:%f 2:%f\n", p->value, p->x, p->y);
409 FILE *fp = fopen(filename,
"r");
414 while(fgets(buf,
sizeof(buf),fp))
418 if(sscanf(buf,
"%d%*d:%lf%*d:%lf",&v,&x,&y)==3)
423 else if(sscanf(buf,
"%lf%*d:%lf",&y,&x)==2)
GtkWidget * fileselection
void svm_toy_initialize()
void show_fileselection()
struct svm_parameter param
gboolean on_draw_main_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
def svm_train(arg1, arg2=None, arg3=None)
void on_button_load_clicked(GtkButton *button, gpointer user_data)
void on_fileselection_destroy(GtkObject *object, gpointer user_data)
TFSIMD_FORCE_INLINE const tfScalar & y() const
void on_button_clear_clicked(GtkButton *button, gpointer user_data)
void on_filesel_ok_clicked(GtkButton *button, gpointer user_data)
static enum @0 fileselection_flag
def svm_predict(y, x, m, options="")
void on_button_change_clicked(GtkButton *button, gpointer user_data)
void redraw_area(GtkWidget *widget, int x, int y, int w, int h)
void svm_free_and_destroy_model(svm_model **model_ptr_ptr)
GtkWidget * create_fileselection(void)
void draw_point(const point &p)
void on_button_run_clicked(GtkButton *button, gpointer user_data)
void on_button_save_clicked(GtkButton *button, gpointer user_data)
void on_filesel_cancel_clicked(GtkButton *button, gpointer user_data)
gboolean on_draw_main_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
struct svm_node * x_space
void on_window1_destroy(GtkObject *object, gpointer user_data)