Welcome to mirror list, hosted at ThFree Co, Russian Federation.

csoaa.h « vowpalwabbit - github.com/moses-smt/vowpal_wabbit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fa1fcb34d78473f3baf2a8268c15ea1863040799 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
Copyright (c) by respective owners including Yahoo!, Microsoft, and
individual contributors. All rights reserved.  Released under a BSD
license as described in the file LICENSE.
 */
#ifndef CSOAA_H
#define CSOAA_H

#include "io.h"
#include "parse_primitives.h"
#include "global_data.h"
#include "example.h"
#include "oaa.h"
#include "parser.h"
#include "parse_args.h"

namespace CSOAA {
  struct wclass {
    float x;
    uint32_t weight_index;
    float partial_prediction;  // a partial prediction: new!
    float wap_value;  // used for wap to store values derived from costs
    bool operator==(wclass j){return weight_index == j.weight_index;}
  };

  
  struct label {
    v_array<wclass> costs;
  };
  
  void parse_flags(vw& all, std::vector<std::string>&, po::variables_map& vm, po::variables_map& vm_file);

  void output_example(vw& all, example* ec);
  size_t read_cached_label(shared_data* sd, void* v, io_buf& cache);
  void cache_label(void* v, io_buf& cache);
  void default_label(void* v);
  void parse_label(parser* p, shared_data* sd, void* v, v_array<substring>& words);
  void delete_label(void* v);
  void copy_label(void*&dst,void*src);
  float weight(void* v);
  float initial(void* v);
  const label_parser cs_label_parser = {default_label, parse_label, 
					cache_label, read_cached_label, 
					delete_label, weight, initial, 
                                        copy_label,
					sizeof(label)};

  bool example_is_test(example* ec);
}

namespace CSOAA_AND_WAP_LDF {
  typedef CSOAA::label label;

  void parse_flags(vw& all, std::vector<std::string>&, po::variables_map& vm, po::variables_map& vm_file);
  void global_print_newline(vw& all);
  void output_example(vw& all, example* ec, bool&hit_loss);

  const label_parser cs_label_parser = CSOAA::cs_label_parser;
}

namespace LabelDict {
  bool ec_is_label_definition(example*ec);
  bool ec_is_example_header(example*ec);
  bool ec_seq_is_label_definition(v_array<example*>ec_seq);
  void add_example_namespaces_from_example(example*target, example*source);
  void del_example_namespaces_from_example(example*target, example*source);
  void add_example_namespace_from_memory(example*ec, size_t lab);
  void del_example_namespace_from_memory(example* ec, size_t lab);
  void set_label_features(size_t lab, v_array<feature>features);
  void free_label_features();
}

#endif