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 關注
- 127 瀏覽
添加回答
舉報