1 回答

TA贡献1963条经验 获得超6个赞
正如我们已经讨论过的,您的模型的问题在于它依赖于产品的数量。但我们需要的是造型师所使用的风格的指标。换句话说,我们消除了计数并将其替换为相对加权的指标(在本例中为百分比)。例如,一位造型师的产品组合包括:
[
style1 => 30,
style2 => 10,
style3 => 5
]
产品数量45 = 30 + 10 + 5将产生如下的样式配置文件:
[
style1 => 0.66,
style2 => 0.22,
style3 => 0.11
]
为了将 stylist-style-profile 与 client-style-profile 相匹配,我们需要对 client-stylebook 执行相同的操作[15, 10, 0]:
[
style1 => 0.60
style2 => 0.40
style3 => 0.00
]
其背后的想法是,我们评估设计师如何受到某种风格的影响,并且对于我们想要找到最合适的设计师的产品来说,结果可能非常相似。
如果造型师制作的产品风格并非我们真正需要的搭配,我们会使用加权相对因子(例如 0.11)来评价这一事实。这并不重要,但我们仍然承认设计可能有些偏差。
因此,如果设计师有很多我们不寻找的某种风格的产品,它不会对结果产生太大的改变。
如果这有帮助并且您想更改任何内容,请告诉我。从这里我们还可以实施其他选项和规则。
您可以在下面找到我的评级模型。
<?php
class RatingModel {
private $name;
private $preferences;
private $preferencesWeighted;
public function RatingModel($name, array $preferences) {
$this->name = $name;
$this->preferences = $preferences;
$this->init();
}
private function init() {
$total = 0;
foreach ($this->preferences as $value) {
$total += $value;
}
if ($total > 0) {
foreach ($this->preferences as $value) {
$this->preferencesWeighted[] = $value / $total;
}
} else {
$this->preferencesWeighted = array_fill(0, sizeof($this->preferences), 0);
}
}
public function getName() {
return $this->name;
}
public function getPreferences() {
return $this->preferences;
}
public function getPreferencesWeighted() {
return $this->preferencesWeighted;
}
public function distanceToModel($ratingModel) {
$delta = [];
for ($i = 0; $i < sizeof($this->preferencesWeighted); $i++) {
$delta[] = abs($this->preferencesWeighted[$i] - $ratingModel->getPreferencesWeighted()[$i]);
}
return $delta;
}
public function scoreToModel($ratingModel) {
$distanceToModel = $this->distanceToModel($ratingModel);
$score = [];
foreach ($distanceToModel as $value) {
$score[] = $value * $value;
}
return sqrt(array_sum($score));
}
}
$customer = new RatingModel('Customer', [15, 10, 0]);
$nanda = new RatingModel('Nanda', [20, 0, 0]);
$angelique = new RatingModel('Angelique', [0, 20, 0]);
$lissy = new RatingModel('Lissy', [10, 0, 0]);
$mary = new RatingModel('Mary', [0, 0, 0]);
$max = new RatingModel('Max', [12, 0, 5]);
$simon = new RatingModel('Simon', [17, 2, 5]);
$manuel = new RatingModel('Manuel', [17, 8, 10]);
$betty = new RatingModel('Betty', [16, 9, 5]);
$sally = new RatingModel('Sally', [15, 10, 4]);
$peter = new RatingModel('Peter', [16, 9, 1]);
$stylists = [$nanda, $angelique, $lissy, $mary, $max, $simon, $manuel, $betty, $peter, $sally];
$relativeToClient = [];
foreach ($stylists as $stylist) {
$relativeToClient[] = [
'stylist' => $stylist->getName(),
'distance' => $stylist->distanceToModel($customer),
'score' => $stylist->scoreToModel($customer)
];
}
echo '<pre>';
print_r($stylists);
echo '<hr>';
print_r($customer);
echo '<hr>';
print_r($relativeToClient);
echo '<hr>from best fit to worst (low score means low delta)<hr>';
$results = array_column($relativeToClient, 'score', 'stylist');
asort($results);
print_r($results);
echo '</pre>';
下面是结果(值越低越好):
Array
(
[Peter] => 0.067936622048676
[Sally] => 0.1700528000819
[Betty] => 0.20548046676563
[Manuel] => 0.35225222874108
[Simon] => 0.3942292057505
[Max] => 0.50765762377392
[Nanda] => 0.56568542494924
[Lissy] => 0.56568542494924
[Mary] => 0.7211102550928
[Angelique] => 0.84852813742386
)
如果我们看看两个最合身的造型师,我们会发现彼得胜过莎莉,因为莎莉有更多不同风格的产品。
Sally: [15, 10, 4]
Peter: [16, 9, 1]
您可能还注意到,Nanda 和 Lissy 的得分相同:
Nanda: [20, 0, 0]
Lissy: [10, 0, 0]
// relatively, for both => [1.00, 0.00, 0.00]
他们都被认为同样合适。与第一种款式相比,Nanda 多了 5 个产品,Lissy 少了 5 个产品,但这并不重要,因为他们都只提供一种款式,重要的是:他们距离理想的客户风格有多远。
您还可以实现逻辑,以便在比较时没有偏差因素并且更加严格。在这种情况下,您可能想要排除一些参数。
例如,只是比较[15, 10]-[16, 9]在这种情况下,莎莉实际上会获胜,因为在偏好方面,她与客户没有差异:
莎莉:
[
style1 => 0.60,
style2 => 0.40
]
彼得:
[
style1 => 0.64,
style2 => 0.36
]
- 1 回答
- 0 关注
- 137 浏览
添加回答
举报