Paradiseo-eo sources added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@40 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
bc1f453978
commit
c3aec878e5
3609 changed files with 342772 additions and 0 deletions
153
trunk/paradiseo-eo/doc/html/_target_info_8cpp-source.html
Normal file
153
trunk/paradiseo-eo/doc/html/_target_info_8cpp-source.html
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>EO: TargetInfo.cpp Source File</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head><body>
|
||||
<!-- Generated by Doxygen 1.3.9.1 -->
|
||||
<div class="qindex"> <form class="search" action="search.php" method="get">
|
||||
<a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
|
||||
<div class="nav">
|
||||
<a class="el" href="dir_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000012.html">regression</a></div>
|
||||
<h1>TargetInfo.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#include "TargetInfo.h"</span>
|
||||
00019
|
||||
00020 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00021
|
||||
00022 TargetInfo::TargetInfo(<span class="keyword">const</span> TargetInfo& org) { operator=(org); }
|
||||
00023
|
||||
00024 TargetInfo& TargetInfo::operator=(<span class="keyword">const</span> TargetInfo& org) {
|
||||
00025 _targets.resize(org._targets.size());
|
||||
00026 _weights.resize(org._weights.size());
|
||||
00027 _tcov_part.resize(org._tcov_part.size());
|
||||
00028
|
||||
00029 _targets = org._targets;
|
||||
00030 _weights = org._weights;
|
||||
00031 _tcov_part = org._tcov_part;
|
||||
00032
|
||||
00033 _tmean = org._tmean;
|
||||
00034 _tvar = org._tvar;
|
||||
00035 _tstd = org._tstd;
|
||||
00036 _tmed = org._tmed;
|
||||
00037 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
|
||||
00038 }
|
||||
00039
|
||||
00040
|
||||
00041 TargetInfo::TargetInfo(<span class="keyword">const</span> std::valarray<double>& t) {
|
||||
00042 _weights.resize(0);
|
||||
00043 _targets.resize(t.size());
|
||||
00044 _targets = t;
|
||||
00045
|
||||
00046 _tmean = _targets.sum()/_targets.size();
|
||||
00047
|
||||
00048 _tcov_part.resize(_targets.size());
|
||||
00049 _tcov_part = _targets;
|
||||
00050 _tcov_part -= _tmean;
|
||||
00051
|
||||
00052 std::valarray<double> tmp = _tcov_part;
|
||||
00053 tmp = _tcov_part;
|
||||
00054 tmp *= tmp;
|
||||
00055
|
||||
00056 _tvar = tmp.sum() / (tmp.size()-1);
|
||||
00057 _tstd = sqrt(_tvar);
|
||||
00058 _tmed = 0;
|
||||
00059 }
|
||||
00060
|
||||
00061 TargetInfo::TargetInfo(<span class="keyword">const</span> std::valarray<double>& t, <span class="keyword">const</span> std::valarray<double>& w) {
|
||||
00062
|
||||
00063 _targets.resize(t.size());
|
||||
00064 _weights.resize(w.size());
|
||||
00065
|
||||
00066 _targets = t;
|
||||
00067 _weights = w;
|
||||
00068
|
||||
00069 <span class="keywordtype">double</span> sumw = _weights.sum();
|
||||
00070 <span class="comment">// scale weights so that they'll add up to 1</span>
|
||||
00071 _weights /= sumw;
|
||||
00072
|
||||
00073 _tmean = (_targets * _weights).sum();
|
||||
00074 _tcov_part.resize(_targets.size());
|
||||
00075 _tcov_part = _targets;
|
||||
00076 _tcov_part -= _tmean;
|
||||
00077
|
||||
00078 _tvar = (pow(_targets - _tmean, 2.0) * _weights).sum();
|
||||
00079 _tstd = sqrt(_tvar);
|
||||
00080 _tmed = 0.;
|
||||
00081 }
|
||||
00082
|
||||
00083 <span class="comment">// calculate the members, now in the context of a mask</span>
|
||||
00084 <span class="keywordtype">void</span> TargetInfo::set_training_mask(<span class="keyword">const</span> std::valarray<bool>& tmask) {
|
||||
00085
|
||||
00086 TargetInfo tmp;
|
||||
00087
|
||||
00088 <span class="keywordflow">if</span> (has_weights() ) {
|
||||
00089 tmp = TargetInfo( _targets[tmask], _weights[tmask]);
|
||||
00090 } <span class="keywordflow">else</span> {
|
||||
00091 tmp = TargetInfo( _targets[tmask] );
|
||||
00092 }
|
||||
00093
|
||||
00094 _tcov_part.resize(tmp._tcov_part.size());
|
||||
00095 _tcov_part = tmp._tcov_part;
|
||||
00096
|
||||
00097 _tmean = tmp._tmean;
|
||||
00098 _tvar = tmp._tvar;
|
||||
00099 _tstd = tmp._tstd;
|
||||
00100 _tmed = tmp._tmed;
|
||||
00101
|
||||
00102 _training_mask.resize(tmask.size());
|
||||
00103 _training_mask = tmask;
|
||||
00104 }
|
||||
00105
|
||||
00106 <span class="keyword">struct </span>SortOnTargets
|
||||
00107 {
|
||||
00108 <span class="keyword">const</span> valarray<double>& t;
|
||||
00109 SortOnTargets(<span class="keyword">const</span> valarray<double>& v) : t(v) {}
|
||||
00110
|
||||
00111 <span class="keywordtype">bool</span> operator()(<span class="keywordtype">int</span> i, <span class="keywordtype">int</span> j)<span class="keyword"> const </span>{
|
||||
00112 <span class="keywordflow">return</span> fabs(t[i]) < fabs(t[j]);
|
||||
00113 }
|
||||
00114 };
|
||||
00115
|
||||
00116 vector<int> TargetInfo::sort() {
|
||||
00117
|
||||
00118 vector<int> ind(_targets.size());
|
||||
00119 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < ind.size(); ++i) { ind[i] = i; }
|
||||
00120
|
||||
00121 std::sort(ind.begin(), ind.end(), SortOnTargets(_targets));
|
||||
00122
|
||||
00123 valarray<double> tmptargets = _targets;
|
||||
00124 valarray<double> tmpweights = _weights;
|
||||
00125 valarray<double> tmpcov = _tcov_part;
|
||||
00126
|
||||
00127 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < ind.size(); ++i)
|
||||
00128 {
|
||||
00129 _targets[i] = tmptargets[ ind[i] ];
|
||||
00130 _tcov_part[i] = tmpcov[ ind[i] ];
|
||||
00131 <span class="keywordflow">if</span> (_weights.size()) _weights[i] = tmpweights[ ind[i] ];
|
||||
00132 }
|
||||
00133
|
||||
00134 <span class="keywordflow">return</span> ind;
|
||||
00135 }
|
||||
00136
|
||||
00137
|
||||
00138
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:44 2006 for EO by
|
||||
<a href="http://www.doxygen.org/index.html">
|
||||
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue