-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathblender.h
83 lines (55 loc) · 2.55 KB
/
blender.h
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
74
75
76
77
78
79
80
81
82
83
/* blender.h -*- C++ -*-
Jeremy Barnes, 30 September 2009
Copyright (c) 2009 Jeremy Barnes. All rights reserved.
Abstract class for a blender.
*/
#ifndef __ausdm__blender_h__
#define __ausdm__blender_h__
#include <boost/shared_ptr.hpp>
#include "data.h"
#include "jml/utils/configuration.h"
#include "jml/stats/distribution.h"
extern __thread float correct_prediction;
/*****************************************************************************/
/* BLENDER */
/*****************************************************************************/
struct Blender {
Blender();
virtual ~Blender();
virtual void configure(const ML::Configuration & config,
const std::string & name,
int random_seed,
Target target) = 0;
virtual void init(const Data & training_data,
const ML::distribution<float> & example_weights) = 0;
virtual float predict(const ML::distribution<float> & models) const = 0;
virtual std::string explain(const ML::distribution<float> & models) const;
};
/*****************************************************************************/
/* LINEAR_BLENDER */
/*****************************************************************************/
struct Linear_Blender : public Blender {
Linear_Blender();
virtual ~Linear_Blender();
virtual void configure(const ML::Configuration & config,
const std::string & name,
int random_seed,
Target target);
virtual void init(const Data & training_data,
const ML::distribution<float> & example_weights);
virtual float predict(const ML::distribution<float> & models) const;
std::string mode;
int num_models;
ML::distribution<float> model_weights;
};
/*****************************************************************************/
/* UTILITY FUNCTIONS */
/*****************************************************************************/
boost::shared_ptr<Blender>
get_blender(const ML::Configuration & config,
const std::string & name,
const Data & data,
const ML::distribution<float> & example_weights,
int random_seed,
Target target);
#endif /* __ausdm__blender_h__ */