MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / svm_svr_probability

Function svm_svr_probability

ml/src/svm.cpp:2288–2325  ·  view source on GitHub ↗

Return parameter of a Laplace distribution

Source from the content-addressed store, hash-verified

2286
2287// Return parameter of a Laplace distribution
2288static double
2289svm_svr_probability(const svm_problem* prob, const svm_parameter* param)
2290{
2291 int nr_fold = 5;
2292 double* ymv = Malloc(double, prob->l);
2293 double mae = 0;
2294
2295 svm_parameter newparam = *param;
2296 newparam.probability = 0;
2297 svm_cross_validation(prob, &newparam, nr_fold, ymv);
2298
2299 for (int i = 0; i < prob->l; i++) {
2300 ymv[i] = prob->y[i] - ymv[i];
2301 mae += std::abs(ymv[i]);
2302 }
2303
2304 mae /= prob->l;
2305
2306 double std = sqrt(2 * mae * mae);
2307 int count = 0;
2308 mae = 0;
2309
2310 for (int i = 0; i < prob->l; i++)
2311 if (std::abs(ymv[i]) > 5 * std)
2312 count += 1;
2313 else
2314 mae += std::abs(ymv[i]);
2315
2316 mae /= (prob->l - count);
2317
2318 info("Prob. model for test data: target value = predicted value + z,\nz: Laplace "
2319 "distribution e^(-|z|/sigma)/(2sigma),sigma= %g\n",
2320 mae);
2321
2322 free(ymv);
2323
2324 return mae;
2325}
2326
2327// label: label name, start: begin of each class, count: #data of classes, perm: indices
2328// to the original data perm, length l, must be allocated before calling this subroutine

Callers 1

svm_trainFunction · 0.85

Calls 3

svm_cross_validationFunction · 0.85
absFunction · 0.85
infoFunction · 0.85

Tested by

no test coverage detected