00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00040
#include "ManualBinner.h"
00041
00042
namespace PLearn {
00043
using namespace std;
00044
00045 ManualBinner::ManualBinner()
00046 :
Binner(), the_mapping(0), bin_positions()
00047 {
00048
00049
00050
00051
00052 }
00053
00054 ManualBinner::ManualBinner(
Vec bin_positions_)
00055 :
Binner(), the_mapping(0), bin_positions(bin_positions_.
copy())
00056 {
00057
build_();
00058 }
00059
00060
00061
PLEARN_IMPLEMENT_OBJECT(
ManualBinner,
"Binner with predefined cut-points.",
00062
"ManualBinner implements a Binner for which cutpoints are predefined. "
00063
"It's getBinning function doesn't have to look at the data; it simply "
00064
"builds a RealMapping from the supplied bin_positions.");
00065
00066 void ManualBinner::declareOptions(
OptionList& ol)
00067 {
00068
declareOption(ol,
"bin_positions", &ManualBinner::bin_positions, OptionBase::buildoption,
00069
"The supplied cut points; should be sorted in ascending order.");
00070
00071
declareOption(ol,
"the_mapping", &ManualBinner::the_mapping, OptionBase::learntoption,
00072
"Pre-calculated RealMapping object that is returned by getBinning");
00073
00074
00075 inherited::declareOptions(ol);
00076 }
00077
00078 void ManualBinner::build_()
00079 {
00080
00081
if(
the_mapping == 0)
00082
the_mapping=
new RealMapping();
00083
the_mapping->clear();
00084
for(
int i= 1; i <
bin_positions.
length(); ++i)
00085
the_mapping->addMapping(
RealRange(
']',
bin_positions[i-1],
bin_positions[i],
']'), i-1);
00086 }
00087
00088
00089 void ManualBinner::build()
00090 {
00091 inherited::build();
00092
build_();
00093 }
00094
00095
00096 void ManualBinner::makeDeepCopyFromShallowCopy(map<const void*, void*>& copies)
00097 {
00098 Object::makeDeepCopyFromShallowCopy(copies);
00099
00100
00101
00102
00103
00104
00105
00106
00107
PLERROR(
"ManualBinner::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
00108 }
00109
00110
00112 PP<RealMapping> ManualBinner::getBinning(
VMat v)
const
00113
{
return the_mapping; }
00114
00115 PP<RealMapping> ManualBinner::getBinning()
const
00116
{
return the_mapping; }
00117
00118
00119 }