12 #define DEFAULT_PARAM "-t 2 -c 100" 19 {0, 0, 120 << 8, 120 << 8},
20 {0, 120 << 8, 120 << 8, 0},
21 {0, 120 << 8, 0, 120 << 8},
22 {0, 0, 200 << 8, 200 << 8},
23 {0, 200 << 8, 200 << 8, 0},
24 {0, 200 << 8, 0, 200 << 8},
47 gdk_colormap_alloc_colors(
48 gdk_colormap_get_system(),
57 gdk_gc_set_foreground(
gc, &
colors[0]);
64 gdk_draw_pixmap(widget->window,
86 gdk_gc_set_foreground(
gc, &
colors[0]);
127 const char *p = gtk_entry_get_text(GTK_ENTRY(
entry_option));
131 while (*p && *p !=
'-')
150 param.
gamma = atof(p);
153 param.
coef0 = atof(p);
181 while (*p && !isspace(*p)) ++p;
191 prob.
y =
new double[prob.
l];
206 x_space[2 * i].
index = 1;
207 x_space[2 * i].
value = q->x;
208 x_space[2 * i + 1].
index = -1;
209 prob.
x[i] = &x_space[2 * i];
218 int *j =
new int[
XLEN];
220 for (i = 0; i <
XLEN; i++)
222 x[0].
value = (double) i / XLEN;
226 gdk_gc_set_foreground(
gc, &
colors[0]);
230 int p = (int)(param.
p *
YLEN);
231 for (i = 1; i <
XLEN; i++)
233 gdk_gc_set_foreground(
gc, &
colors[0]);
237 gdk_gc_set_foreground(
gc, &
colors[5]);
238 gdk_draw_line(
pixmap,
gc, i - 1, j[i - 1], i, j[i]);
239 gdk_draw_line(
draw_main->window,
gc, i - 1, j[i - 1], i, j[i]);
243 gdk_gc_set_foreground(
gc, &
colors[2]);
244 gdk_draw_line(
pixmap,
gc, i - 1, j[i - 1] + p, i, j[i] + p);
245 gdk_draw_line(
draw_main->window,
gc, i - 1, j[i - 1] + p, i, j[i] + p);
247 gdk_gc_set_foreground(
gc, &
colors[2]);
248 gdk_draw_line(
pixmap,
gc, i - 1, j[i - 1] - p, i, j[i] - p);
249 gdk_draw_line(
draw_main->window,
gc, i - 1, j[i - 1] - p, i, j[i] - p);
268 x_space[3 * i].
index = 1;
269 x_space[3 * i].
value = q->x;
270 x_space[3 * i + 1].
index = 2;
271 x_space[3 * i + 1].
value = q->y;
272 x_space[3 * i + 2].
index = -1;
273 prob.
x[i] = &x_space[3 * i];
274 prob.
y[i] = q->value;
284 for (i = 0; i <
XLEN; i++)
285 for (j = 0; j <
YLEN; j++)
287 x[0].
value = (double) i / XLEN;
288 x[1].
value = (double) j / YLEN;
291 gdk_gc_set_foreground(
gc, &
colors[(
int)d]);
322 GdkEventButton *event,
333 GdkEventExpose *event,
337 event->area.x, event->area.y,
338 event->area.width, event->area.height);
348 gtk_signal_connect_object(
350 "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy),
353 gtk_signal_connect_object(GTK_OBJECT
354 (GTK_FILE_SELECTION(fileselection)->cancel_button),
355 "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy),
356 (GtkObject *) fileselection);
358 gtk_widget_show(fileselection);
383 const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(
fileselection));
387 FILE *fp = fopen(filename,
"w");
389 const char *p = gtk_entry_get_text(GTK_ENTRY(
entry_option));
390 const char* svm_type_str = strstr(p,
"-s ");
391 int svm_type =
C_SVC;
392 if (svm_type_str != NULL)
393 sscanf(svm_type_str,
"-s %d", &svm_type);
400 fprintf(fp,
"%f 1:%f\n", p->y, p->x);
405 fprintf(fp,
"%d 1:%f 2:%f\n", p->value, p->x, p->y);
413 FILE *fp = fopen(filename,
"r");
418 while (fgets(buf,
sizeof(buf), fp))
422 if (sscanf(buf,
"%d%*d:%lf%*d:%lf", &v, &x, &y) == 3)
427 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)
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)