5 #include <xercesc/dom/DOM.hpp>
16 XERCES_CPP_NAMESPACE_USE
18 using namespace PhysicsTools;
28 virtual ~ProcLinear();
30 virtual void configure(DOMElement *
elem);
33 virtual void trainBegin();
34 virtual void trainData(
const std::vector<double> *
values,
36 virtual void trainEnd();
42 virtual void *requestObject(
const std::string &
name)
const;
50 std::auto_ptr<LeastSquares>
ls;
51 std::vector<double> vars;
56 ProcLinear::ProcLinear(
const char *
name,
const AtomicId *
id,
63 ProcLinear::~ProcLinear()
67 void ProcLinear::configure(DOMElement *
elem)
82 void ProcLinear::trainBegin()
85 vars.resize(
ls->getSize());
88 void ProcLinear::trainData(
const std::vector<double> *
values,
94 for(
unsigned int i = 0;
i <
ls->getSize();
i++, values++)
95 vars[
i] = values->front();
97 ls->add(vars, target, weight);
100 void ProcLinear::trainEnd()
115 void *ProcLinear::requestObject(
const std::string &
name)
const
117 if (name ==
"linearAnalyzer")
118 return static_cast<void*
>(
ls.get());
125 std::string
filename = trainer->trainFileName(
this,
"xml");
126 if (!exists(filename))
130 DOMElement *elem = xml.getRootNode();
131 if (std::strcmp(
XMLSimpleStr(elem->getNodeName()),
"ProcLinear") != 0)
133 <<
"XML training data file has bad root node."
136 DOMNode *
node = elem->getFirstChild();
137 while(node && node->getNodeType() != DOMNode::ELEMENT_NODE)
138 node = node->getNextSibling();
142 <<
"Train data file empty." << std::endl;
144 ls->load(static_cast<DOMElement*>(node));
146 node = elem->getNextSibling();
147 while(node && node->getNodeType() != DOMNode::ELEMENT_NODE)
148 node = node->getNextSibling();
152 <<
"Train data file contains superfluous tags."
160 void ProcLinear::save()
162 XMLDocument xml(trainer->trainFileName(
this,
"xml"),
true);
163 DOMDocument *
doc = xml.createDocument(
"ProcLinear");
165 xml.getRootNode()->appendChild(
ls->save(doc));
detail::ThreadSafeRegistry< ParameterSetID, ParameterSet, ProcessParameterSetIDCache > Registry
MVATrainerComputer * calib
tuple size
Write out results.