mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-21 12:35:10 +00:00
Fixed ${var} string interpolation deprecations in PHP 8.1
This commit is contained in:
parent
67f2c30ad4
commit
c91a5b730e
@ -386,9 +386,9 @@ class DecisionTree implements Classifier
|
|||||||
$median = Mean::median($values);
|
$median = Mean::median($values);
|
||||||
foreach ($values as &$value) {
|
foreach ($values as &$value) {
|
||||||
if ($value <= $median) {
|
if ($value <= $median) {
|
||||||
$value = "<= ${median}";
|
$value = "<= {$median}";
|
||||||
} else {
|
} else {
|
||||||
$value = "> ${median}";
|
$value = "> {$median}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ class DecisionTreeLeaf
|
|||||||
public function getHTML(?array $columnNames = null): string
|
public function getHTML(?array $columnNames = null): string
|
||||||
{
|
{
|
||||||
if ($this->isTerminal) {
|
if ($this->isTerminal) {
|
||||||
$value = "<b>${this}->classValue</b>";
|
$value = "<b>{$this}->classValue</b>";
|
||||||
} else {
|
} else {
|
||||||
$value = $this->value;
|
$value = $this->value;
|
||||||
if ($columnNames !== null) {
|
if ($columnNames !== null) {
|
||||||
@ -132,13 +132,13 @@ class DecisionTreeLeaf
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((bool) preg_match('/^[<>=]{1,2}/', (string) $value) === false) {
|
if ((bool) preg_match('/^[<>=]{1,2}/', (string) $value) === false) {
|
||||||
$value = "=${value}";
|
$value = "={$value}";
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = "<b>${col} ${value}</b><br>Gini: ".number_format($this->giniIndex, 2);
|
$value = "<b>{$col} {$value}</b><br>Gini: ".number_format($this->giniIndex, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
$str = "<table ><tr><td colspan=3 align=center style='border:1px solid;'>${value}</td></tr>";
|
$str = "<table ><tr><td colspan=3 align=center style='border:1px solid;'>{$value}</td></tr>";
|
||||||
|
|
||||||
if ($this->leftLeaf !== null || $this->rightLeaf !== null) {
|
if ($this->leftLeaf !== null || $this->rightLeaf !== null) {
|
||||||
$str .= '<tr>';
|
$str .= '<tr>';
|
||||||
|
@ -87,7 +87,7 @@ class DecisionStump extends WeightedClassifier
|
|||||||
|
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return "IF ${this}->column ${this}->operator ${this}->value ".
|
return "IF {$this->column} {$this->operator} {$this->value} ".
|
||||||
'THEN '.$this->binaryLabels[0].' '.
|
'THEN '.$this->binaryLabels[0].' '.
|
||||||
'ELSE '.$this->binaryLabels[1];
|
'ELSE '.$this->binaryLabels[1];
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ class StopWords
|
|||||||
|
|
||||||
public static function factory(string $language = 'English'): self
|
public static function factory(string $language = 'English'): self
|
||||||
{
|
{
|
||||||
$className = __NAMESPACE__."\\StopWords\\${language}";
|
$className = __NAMESPACE__."\\StopWords\\{$language}";
|
||||||
|
|
||||||
if (!class_exists($className)) {
|
if (!class_exists($className)) {
|
||||||
throw new InvalidArgumentException(sprintf('Can\'t find "%s" language for StopWords', $language));
|
throw new InvalidArgumentException(sprintf('Can\'t find "%s" language for StopWords', $language));
|
||||||
|
@ -157,7 +157,7 @@ trait OneVsRest
|
|||||||
*/
|
*/
|
||||||
private function binarizeTargets(array $targets, $label): array
|
private function binarizeTargets(array $targets, $label): array
|
||||||
{
|
{
|
||||||
$notLabel = "not_${label}";
|
$notLabel = "not_{$label}";
|
||||||
foreach ($targets as $key => $target) {
|
foreach ($targets as $key => $target) {
|
||||||
$targets[$key] = $target == $label ? $label : $notLabel;
|
$targets[$key] = $target == $label ? $label : $notLabel;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user