This commit is contained in:
Dennis Eichhorn 2022-04-23 16:30:55 +02:00
parent edd4693111
commit 4027a9159f
6 changed files with 19 additions and 8 deletions

View File

@ -193,7 +193,7 @@ jobs:
- name: Setup Composer
run: composer install
- name: phpcs
run: vendor/bin/phpcs ./ --standard="Build/Config/phpcs.xml" -s --report=full
run: vendor/bin/phpcs --severity=1 ./ --standard="Build/Config/phpcs.xml" -s --report=full
linting:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'NO_CI')"

View File

@ -145,7 +145,8 @@ final class Metrics
* @param array $purchaseProbability Purchase probabilities for different periods
* @param array $payoffs Payoff vector (first element = payoff - cost, other elements = -cost, last element = 0)
*
* @return Matrix A vector which shows in row i the return of the customer if he didn't buy i - 1 times before (=recency of the customer = how many periods has it been since he bought the last time)
* @return Matrix A vector which shows in row i the return of the customer if he didn't buy i - 1 times before
* (=recency of the customer = how many periods has it been since he bought the last time)
*
* @since 1.0.0
*/

View File

@ -31,7 +31,7 @@ In rare cases errors, failures or warnings during the automatic inspection are
Automated checks which are run during the review process:
```sh
php ./vendor/bin/phpcs ./ --standard="Build/Config/phpcs.xml"
php ./vendor/bin/phpcs --severity=1 ./ --standard="Build/Config/phpcs.xml"
npx eslint ./ -c ./Build/Config/.eslintrc.json
```

View File

@ -149,7 +149,10 @@ final class NaiveBayesClassifier
}
} else {
$p = (1 / \sqrt(2 * \M_PI * $this->probabilities['criteria'][$criteria]['attr'][$attr]['variance'])
* \exp(-($value - $this->probabilities['criteria'][$criteria]['attr'][$attr]['mean']) ** 2 / (2 * $this->probabilities['criteria'][$criteria]['attr'][$attr]['variance'])))
* \exp(-($value - $this->probabilities['criteria'][$criteria]['attr'][$attr]['mean']) ** 2
/ (2 * $this->probabilities['criteria'][$criteria]['attr'][$attr]['variance'])
)
)
* ($this->probabilities['criteria'][$criteria]['count'] / $this->probabilities['count'])
/ $this->probabilities['attr'][$attr]['data'];
@ -177,14 +180,20 @@ final class NaiveBayesClassifier
foreach ($subDict as $attr => $valueArray) {
if ($valueArray['type'] === 2) {
$this->probabilities['criteria'][$criteria]['attr'][$attr]['mean'] = Average::arithmeticMean($this->dict[$criteria][$attr]['data']);
$this->probabilities['criteria'][$criteria]['attr'][$attr]['variance'] = MeasureOfDispersion::sampleVariance($this->dict[$criteria][$attr]['data'], $this->probabilities['criteria'][$criteria]['attr'][$attr]['mean']);
$this->probabilities['criteria'][$criteria]['attr'][$attr]['variance'] = MeasureOfDispersion::sampleVariance(
$this->dict[$criteria][$attr]['data'],
$this->probabilities['criteria'][$criteria]['attr'][$attr]['mean']
);
if (!isset($this->probabilities['attr'][$attr])) {
$this->probabilities['attr'][$attr] = ['data' => 0.0];
}
$this->probabilities['attr'][$attr]['data'] += (1 / \sqrt(2 * \M_PI * $this->probabilities['criteria'][$criteria]['attr'][$attr]['variance'])
* \exp(-($toMatch[$attr] - $this->probabilities['criteria'][$criteria]['attr'][$attr]['mean']) ** 2 / (2 * $this->probabilities['criteria'][$criteria]['attr'][$attr]['variance'])))
* \exp(-($toMatch[$attr] - $this->probabilities['criteria'][$criteria]['attr'][$attr]['mean']) ** 2
/ (2 * $this->probabilities['criteria'][$criteria]['attr'][$attr]['variance'])
)
)
* ($this->probabilities['criteria'][$criteria]['count'] / $this->probabilities['count']);
} else {
if (!isset($this->probabilities['attr'][$attr])) {

View File

@ -138,7 +138,7 @@ final class ConsoleResponse extends ResponseAbstract implements RenderableInterf
$render .= StringUtils::stringify($response);
}
return $render;
return $optimize ? \trim($render) : $render;
}
/**

View File

@ -89,7 +89,8 @@ final class Rest
$boundary = '----' . \uniqid();
$data = self::createMultipartData($boundary, $request->getData());
// @todo: replace boundary/ with the correct boundary= in the future. Currently this cannot be done due to a bug. If we do it now the server cannot correclty populate php://input
// @todo: replace boundary/ with the correct boundary= in the future.
// Currently this cannot be done due to a bug. If we do it now the server cannot correclty populate php://input
$headers['content-type'] = 'Content-Type: multipart/form-data; boundary/' . $boundary;
$headers['content-length'] = 'Content-Length: ' . \strlen($data);