(prob *SVM_Problem, param *SVM_Parameter, Cp, Cn float64)
| 1471 | } |
| 1472 | |
| 1473 | func (this *SVM) SVM_train_one(prob *SVM_Problem, param *SVM_Parameter, Cp, Cn float64) *decision_function { |
| 1474 | alpha := make([]float64, prob.l) |
| 1475 | si := new(SolutionInfo) |
| 1476 | switch param.svm_type { |
| 1477 | case C_SVC: |
| 1478 | this.Solve_c_svc(prob, param, alpha, si, Cp, Cn) |
| 1479 | case NU_SVC: |
| 1480 | this.Solve_nu_svc(prob, param, alpha, si) |
| 1481 | case ONE_CLASS: |
| 1482 | this.Solve_one_class(prob, param, alpha, si) |
| 1483 | case EPSILON_SVR: |
| 1484 | this.Solve_epsilon_svr(prob, param, alpha, si) |
| 1485 | case NU_SVR: |
| 1486 | this.Solve_nu_svr(prob, param, alpha, si) |
| 1487 | } |
| 1488 | |
| 1489 | log.Println("obj = ", si.obj, ", rho = ", si.rho) |
| 1490 | |
| 1491 | // output SVs |
| 1492 | |
| 1493 | nSV := 0 |
| 1494 | nBSV := 0 |
| 1495 | for i := 0; i < prob.l; i++ { |
| 1496 | if math.Abs(alpha[i]) > 0 { |
| 1497 | nSV++ |
| 1498 | if prob.y[i] > 0 { |
| 1499 | if math.Abs(alpha[i]) >= si.upper_bound_p { |
| 1500 | nBSV++ |
| 1501 | } |
| 1502 | } else { |
| 1503 | if math.Abs(alpha[i]) >= si.upper_bound_n { |
| 1504 | nBSV++ |
| 1505 | } |
| 1506 | } |
| 1507 | } |
| 1508 | } |
| 1509 | |
| 1510 | log.Println("nSV = ", nSV, ", nBSV = ", nBSV) |
| 1511 | |
| 1512 | f := new(decision_function) |
| 1513 | f.alpha = alpha |
| 1514 | f.rho = si.rho |
| 1515 | return f |
| 1516 | } |
| 1517 | |
| 1518 | func (this *SVM) sigmoid_train(l int, dec_values, labels, probAB []float64) { |
| 1519 | var A, B float64 |
no test coverage detected