~ubuntu-branches/ubuntu/maverick/speech-tools/maverick

« back to all changes in this revision

Viewing changes to stats/EST_ols.cc

  • Committer: Bazaar Package Importer
  • Author(s): Kumar Appaiah, Kartik Mistry, Kumar Appaiah
  • Date: 2010-07-17 11:32:04 UTC
  • mfrom: (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100717113204-mnse3jo236j107q8
Tags: 1:2.0.95~beta-1
[ Kartik Mistry ]
* debian/control:
  + [Lintian] Added missing ${misc:Depends}
  + Updated Standards-Version to 3.8.4 (no changes needed)
* debian/patches/const_char.diff:
  + Added missing patch header
* Removed unused patch invalid_const_char_conversion_fixes.diff

[ Kumar Appaiah ]
* New upstream release.
* Standards Version is now 3.9.0 (No changes needed)
* Update debian/rules to specify version numbers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
                                  float &bscore,
51
51
                                  int &best_feat,
52
52
                                  const EST_FMatrix &Xtest,
53
 
                                  const EST_FMatrix &Ytest);
 
53
                                  const EST_FMatrix &Ytest,
 
54
                                  const EST_StrList &feat_names
 
55
                                  );
54
56
 
55
57
int ols(const EST_FMatrix &X,const EST_FMatrix &Y, EST_FMatrix &coeffs)
56
58
{
122
124
            for (s=i=0; i<singularity; i++)
123
125
            {
124
126
                s++;
125
 
                while (!included(s)) s++;
 
127
                while ((included(s) == FALSE) ||
 
128
                       (included(s) == OLS_IGNORE))
 
129
                       s++;
126
130
            }
127
 
            if (!included(s))
 
131
            if (included(s) == FALSE)
128
132
            {   // oops
129
133
                cerr << "OLS: found singularity twice, shouldn't happen" 
130
134
                    << endl;
161
165
    int i,j,k,width;
162
166
 
163
167
    for (width=i=0; i<included.length(); i++)
164
 
        if (included(i))
 
168
        if (included(i) == TRUE)
165
169
            width++;
166
170
 
167
171
    Xl.resize(X.num_rows(),width);
168
172
 
169
173
    for (i=0; i<X.num_rows(); i++)
170
174
        for (k=j=0; j < X.num_columns(); j++)
171
 
            if (included(j))
 
175
            if (included(j) == TRUE)
172
176
            {
173
177
                Xl.a_no_check(i,k) = X.a_no_check(i,j);
174
178
                k++;
196
200
                 float limit,
197
201
                 EST_FMatrix &coeffs,
198
202
                 const EST_FMatrix &Xtest,
199
 
                 const EST_FMatrix &Ytest)
 
203
                 const EST_FMatrix &Ytest,
 
204
                 EST_IVector &included)
200
205
{
201
206
    // Find the features that contribute to the correlation using a
202
207
    // a greedy algorithm
203
208
 
204
209
    EST_FMatrix coeffsl;
205
 
    EST_IVector included;
206
210
    float best_score=0.0,bscore;
207
211
    int i,best_feat;
208
212
    int nf=1;  // for nice printing of progress
209
213
 
210
 
    included.resize(X.num_columns());
211
 
    included[0] = TRUE;  // always guarantee interceptor
212
 
    for (i=1; i<included.length(); i++)
213
 
         included.a_no_check(i) = FALSE;
214
 
 
215
214
    for (i=1; i < X.num_columns(); i++)
216
215
    {
217
216
        if (!ols_stepwise_find_best(X,Y,included,coeffsl,
218
 
                                    bscore,best_feat,Xtest,Ytest))
 
217
                                    bscore,best_feat,Xtest,Ytest,
 
218
                                    feat_names))
219
219
        {
220
220
            cerr << "OLS: stepwise failed" << endl;
221
221
            return FALSE;
246
246
                                  float &bscore,
247
247
                                  int &best_feat,
248
248
                                  const EST_FMatrix &Xtest,
249
 
                                  const EST_FMatrix &Ytest)
 
249
                                  const EST_FMatrix &Ytest,
 
250
                                  const EST_StrList &feat_names
 
251
                                  )
250
252
{
251
253
    EST_FMatrix coeffsl;
252
254
    bscore = 0;
263
265
            if (!robust_ols(X,Y,included,coeffsl))
264
266
                return FALSE;  // failed for some reason
265
267
            ols_apply(Xtest,coeffsl,pred);
266
 
            ols_test(Ytest,pred,cor,rmse);
267
 
            if (cor > bscore)
 
268
            ols_test(Ytest,pred,cor,rmse);
 
269
            printf("tested %d %s %f best %f\n",
 
270
                   i,(const char *)feat_names.nth(i),cor,bscore);
 
271
            if (fabs(cor) > bscore)
268
272
            {
269
 
                bscore = cor;
 
273
                bscore = fabs(cor);
270
274
                coeffs = coeffsl;
271
275
                best_feat = i;
272
276
            }
316
320
 
317
321
    if (v3 <= 0)
318
322
    {   // happens when there's very little variation in x
319
 
        correlation = -3;
 
323
        correlation = 0;
320
324
        rmse = se.mean();
321
325
        return FALSE;
322
326
    }