forked from VowpalWabbit/vowpal_wabbit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobal_data.cc
55 lines (48 loc) · 1.16 KB
/
global_data.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <pthread.h>
#include <stdio.h>
#include "global_data.h"
#include "multisource.h"
#include "message_relay.h"
global_data global;
string version = "4.1";
void binary_print_result(int f, float res, float weight, v_array<char> tag)
{
if (f >= 0)
{
global_prediction ps = {res, weight};
send_global_prediction(f, ps);
}
}
void print_result(int f, float res, float weight, v_array<char> tag)
{
if (f >= 0)
{
char temp[30];
int num = sprintf(temp, "%f", res);
ssize_t t;
t = write(f, temp, num);
if (t != num)
cerr << "write error" << endl;
if (tag.begin != tag.end){
temp[0] = ' ';
t = write(f, temp, 1);
if (t != 1)
cerr << "write error" << endl;
t = write(f, tag.begin, sizeof(char)*tag.index());
if (t != (ssize_t) (sizeof(char)*tag.index()))
cerr << "write error" << endl;
}
temp[0] = '\n';
t = write(f, temp, 1);
if (t != 1)
cerr << "write error" << endl;
}
}
void set_mm(double label)
{
global.min_label = min(global.min_label, label);
global.max_label = max(global.max_label, label);
}
void noop_mm(double label)
{}
void (*set_minmax)(double label) = set_mm;