// wygeneruj wyniki testowe i zapisz je $str = "Wyniki cz±stkowe (dla ka¿dej 50-ki) i ³±czne dla klasyfikatora {$k}, pakiet komentarzy {$idc}, test {$sub}\n\n"; $str .= "PoNk | TP | TN | FP | FN | UC | Precis | Recall | F1 | accurP | accurN | accura | errorP | errorN | error | unclas\n"; $template = "%4s | %3d | %3d | %3d | %3d | %3d | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f\n"; foreach ($partialResults["{$sub}_{$idc}"] as $kk => &$vv) { $t =& $vv[$k]; $str .= sprintf($template, $kk, $t['TP'], $t['TN'], $t['FP'], $t['FN'], $t['UC'], 100 * $t['precision'], 100 * $t['recall'], 100 * $t['F1'], 100 * $t['accuracyP'], 100 * $t['accuracyN'], 100 * $t['accuracy'], 100 * $t['errorP'], 100 * $t['errorN'], 100 * $t['error'], 100 * $t['unclassified']); } $t =& $summedResults["{$sub}_{$idc}"][$k]; $str .= sprintf("\nSUMA | %3d | %3d | %3d | %3d | %3d | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f\n", $t['TP'], $t['TN'], $t['FP'], $t['FN'], $t['UC'], 100 * $t['precision'], 100 * $t['recall'], 100 * $t['F1'], 100 * $t['accuracyP'], 100 * $t['accuracyN'], 100 * $t['accuracy'], 100 * $t['errorP'], 100 * $t['errorN'], 100 * $t['error'], 100 * $t['unclassified']); file_put_contents($directory . '/' . sprintf($resultsFileTemp, $idc, $k, $sub), $str); } } } // zapisz wyniki czasowe do odpowiednich plików for ($idc = 1; $idc <= 3; ++$idc) { $str = "¦rednia suma czasów wykonania poszczególnych metod dla pakietu komentarzy {$idc}\n\n"; $str .= "Metoda "; foreach ($times["{$idc}"]['Winnow'] as $k => $v) { $str .= sprintf("| %-15s ", $k); } $str .= "\n"; foreach ($times["{$idc}"] as $k => &$v) { $str .= sprintf("%-7s ", $k); foreach ($v as $kk => $vv) { $str .= sprintf("| %-15s ", Timer::format($vv / $subTests)); } $str .= "\n"; } file_put_contents($directory . '/' . sprintf($timeFileTemp, $idc), $str); }
$classifiers[$k] = $v[$_POST['set']]; if ($suppressThreshold) { $classifiers[$k]['threshold'] = 0.0; } } } // utwórz obiekty klasyfikatorów, obiekty czasomierzy a nastêpnie klasyfikuj foreach ($classifiers as $k => $v) { $tmpc = new ReflectionClass($k); $classObj[$k] = $tmpc->newInstance($db, $dictionaries, $_POST['set'], false, $v); $time = new Timer(); if (is_null($prepText)) { $time->set('start'); $prepText = $classObj[$k]->doPreparation($_POST['comment']); $time->set('doPreparation'); $prepResult['time'] = '<b>' . $time->format($time->get('doPreparation')) . '</b>'; if ($prepText === false) { break; } } $time->set('start'); $results[$k] = $classObj[$k]->doClassify($prepText, true); $time->set('doClassify'); $times[$k] = $time->format($time->get('doClassify')); } unset($classObj); $prepResult['org'] = $_POST['comment']; ?> <!--<h4>Testowany komentarz</h4> <textarea readonly="true" cols="60" rows="15" name="comment" id="comment" title="Tre¶æ komentarza"> <?php