1 回答

TA貢獻(xiàn)1963條經(jīng)驗(yàn) 獲得超6個(gè)贊
正如我們已經(jīng)討論過的,您的模型的問題在于它依賴于產(chǎn)品的數(shù)量。但我們需要的是造型師所使用的風(fēng)格的指標(biāo)。換句話說,我們消除了計(jì)數(shù)并將其替換為相對(duì)加權(quán)的指標(biāo)(在本例中為百分比)。例如,一位造型師的產(chǎn)品組合包括:
[
style1 => 30,
style2 => 10,
style3 => 5
]
產(chǎn)品數(shù)量45 = 30 + 10 + 5將產(chǎn)生如下的樣式配置文件:
[
style1 => 0.66,
style2 => 0.22,
style3 => 0.11
]
為了將 stylist-style-profile 與 client-style-profile 相匹配,我們需要對(duì) client-stylebook 執(zhí)行相同的操作[15, 10, 0]:
[
style1 => 0.60
style2 => 0.40
style3 => 0.00
]
其背后的想法是,我們?cè)u(píng)估設(shè)計(jì)師如何受到某種風(fēng)格的影響,并且對(duì)于我們想要找到最合適的設(shè)計(jì)師的產(chǎn)品來說,結(jié)果可能非常相似。
如果造型師制作的產(chǎn)品風(fēng)格并非我們真正需要的搭配,我們會(huì)使用加權(quán)相對(duì)因子(例如 0.11)來評(píng)價(jià)這一事實(shí)。這并不重要,但我們?nèi)匀怀姓J(rèn)設(shè)計(jì)可能有些偏差。
因此,如果設(shè)計(jì)師有很多我們不尋找的某種風(fēng)格的產(chǎn)品,它不會(huì)對(duì)結(jié)果產(chǎn)生太大的改變。
如果這有幫助并且您想更改任何內(nèi)容,請(qǐng)告訴我。從這里我們還可以實(shí)施其他選項(xiàng)和規(guī)則。
您可以在下面找到我的評(píng)級(jí)模型。
<?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>';
下面是結(jié)果(值越低越好):
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
)
如果我們看看兩個(gè)最合身的造型師,我們會(huì)發(fā)現(xiàn)彼得勝過莎莉,因?yàn)樯蛴懈嗖煌L(fēng)格的產(chǎn)品。
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]
他們都被認(rèn)為同樣合適。與第一種款式相比,Nanda 多了 5 個(gè)產(chǎn)品,Lissy 少了 5 個(gè)產(chǎn)品,但這并不重要,因?yàn)樗麄兌贾惶峁┮环N款式,重要的是:他們距離理想的客戶風(fēng)格有多遠(yuǎn)。
您還可以實(shí)現(xiàn)邏輯,以便在比較時(shí)沒有偏差因素并且更加嚴(yán)格。在這種情況下,您可能想要排除一些參數(shù)。
例如,只是比較[15, 10]-[16, 9]在這種情況下,莎莉?qū)嶋H上會(huì)獲勝,因?yàn)樵谄梅矫?,她與客戶沒有差異:
莎莉:
[
style1 => 0.60,
style2 => 0.40
]
彼得:
[
style1 => 0.64,
style2 => 0.36
]
- 1 回答
- 0 關(guān)注
- 123 瀏覽
添加回答
舉報(bào)