/** * Akce pro vykreslení detailů úlohy ve formátu PMML * @param int $id - id of the rule set * @throws \Exception * @throws \Nette\Application\ForbiddenRequestException */ public function renderDRL($id) { $ruleSet = $this->ruleSetsFacade->findRuleSet($id); $this->ruleSetsFacade->checkRuleSetAccess($ruleSet, $this->user->id); //vygenerování a zobrazení DRL $associationRulesXmlSerializer = new AssociationRulesXmlSerializer($ruleSet->findRules()); $xml = $associationRulesXmlSerializer->getXml(); $this->sendTextResponse($this->xmlTransformator->transformToDrl($xml, $this->template->basePath)); }
/** * @param Task $task * @param Datasource $testingDatasource * @return ScoringResult */ public function evaluateTask(Task $task, Datasource $testingDatasource) { $rulesXmlFileName = $task->taskId . '.xml'; /** @var string $rulesXmlFilePath - cesta souboru s pravidly v XML */ $rulesXmlFilePath = @$this->params['tempDirectory'] . '/' . $rulesXmlFileName; $associationRulesXmlSerializer = new AssociationRulesXmlSerializer($task->rules); $rulesXml = $associationRulesXmlSerializer->getXml()->asXML(); file_put_contents($rulesXmlFilePath, $rulesXml); $database = $this->databaseFactory->getDatabaseInstance($testingDatasource->getDbConnection(), $task->miner->user); $dbDatasource = $database->getDbDatasource($testingDatasource->dbDatasourceId > 0 ? $testingDatasource->dbDatasourceId : $testingDatasource->dbTable); $dbRowsCount = $dbDatasource->size; $testedRowsCount = 0; /** @var ScoringResult[] $partialResults */ $partialResults = []; //export jednotlivých řádků z DB a jejich otestování while ($testedRowsCount < $dbRowsCount) { $csv = CsvSerializer::prepareCsvFromDatabase($database, $dbDatasource, $testedRowsCount, self::ROWS_PER_TEST, ';', '"'); $csvFileName = $testingDatasource->datasourceId . '-' . $testedRowsCount . '-' . self::ROWS_PER_TEST . '.csv'; /** @var string $csvFilePath - cesta k CSV souboru s částí dat */ $csvFilePath = @$this->params['tempDirectory'] . '/' . $csvFileName; file_put_contents($csvFilePath, $csv); $url = $this->serverUrl . '?rulesXml=' . $this->getTempFileUrl($rulesXmlFileName) . '&dataCsv=' . $this->getTempFileUrl($csvFileName); //try{ $response = self::curlRequestResponse($url); $xml = simplexml_load_string($response); $partialResult = new ScoringResult(); $partialResult->truePositive = (string) $xml->truePositive; $partialResult->falsePositive = (string) $xml->falsePositive; $partialResult->rowsCount = (string) $xml->rowsCount; $partialResults[] = $partialResult; unset($xml); //}catch (\Exception $e){ // /*ignore error...*/ //} unlink($csvFilePath); $testedRowsCount += self::ROWS_PER_TEST; } //XXX unlink($rulesXmlFilePath); //sestavení celkového výsledku return ScoringResult::merge($partialResults); }
/** * Akce pro vykreslení detailů úlohy ve formátu PMML * @param int $id * @throws \Exception * @throws BadRequestException * @throws ForbiddenRequestException */ public function renderTaskDRL($id) { $task = $this->tasksFacade->findTask($id); $miner = $task->miner; $this->checkMinerAccess($miner); //vygenerování a odeslání PMML $associationRulesXmlSerializer = new AssociationRulesXmlSerializer($task->rules); $xml = $associationRulesXmlSerializer->getXml(); $this->sendTextResponse($this->xmlTransformator->transformToDrl($xml)); }