您只需要准确说明您正在从训练数据集中向一个或多个用户推荐项目,如下所示:
> as(predict(recom, 1, data = train), "list")
$`1`
[1] "Hearts and Minds (1996)" "Boys, Les (1997)" "Great Day in Harlem, A (1994)"
[4] "Dangerous Beauty (1998)" "Tough and Deadly (1995)" "Two or Three Things I Know About Her (1966)"
[7] "Santa with Muscles (1996)" "Margaret's Museum (1995)" "Brassed Off (1996)"
[10] "Thousand Acres, A (1997)"
> as(predict(recom, 1:10, data = train), "list")
$`1`
[1] "Dangerous Beauty (1998)" "Great Day in Harlem, A (1994)" "Hearts and Minds (1996)"
[4] "Boys, Les (1997)" "Santa with Muscles (1996)" "Two or Three Things I Know About Her (1966)"
[7] "Tough and Deadly (1995)" "Saint of Fort Washington, The (1993)" "Whole Wide World, The (1996)"
[10] "Margaret's Museum (1995)"
$`5`
[1] "Boys, Les (1997)" "Two or Three Things I Know About Her (1966)" "Santa with Muscles (1996)"
[4] "Dangerous Beauty (1998)" "Great Day in Harlem, A (1994)" "Whole Wide World, The (1996)"
[7] "Hearts and Minds (1996)" "Brassed Off (1996)" "Saint of Fort Washington, The (1993)"
[10] "Celestial Clockwork (1994)"
$`6`
[1] "Dangerous Beauty (1998)" "Two or Three Things I Know About Her (1966)" "Santa with Muscles (1996)"
[4] "Tough and Deadly (1995)" "Brassed Off (1996)" "Crooklyn (1994)"
[7] "Great Day in Harlem, A (1994)" "Hearts and Minds (1996)" "Saint of Fort Washington, The (1993)"
[10] "Boys, Les (1997)"
$`7`
[1] "Two or Three Things I Know About Her (1966)" "Tough and Deadly (1995)" "Santa with Muscles (1996)"
[4] "Dangerous Beauty (1998)" "Hearts and Minds (1996)" "Great Day in Harlem, A (1994)"
[7] "Boys, Les (1997)" "Brassed Off (1996)" "Margaret's Museum (1995)"
[10] "Crooklyn (1994)"
$`10`
[1] "Dangerous Beauty (1998)" "Great Day in Harlem, A (1994)" "Hearts and Minds (1996)"
[4] "Tough and Deadly (1995)" "Two or Three Things I Know About Her (1966)" "Boys, Les (1997)"
[7] "Santa with Muscles (1996)" "Brassed Off (1996)" "Margaret's Museum (1995)"
[10] "Crooklyn (1994)"
$`11`
[1] "Two or Three Things I Know About Her (1966)" "Hearts and Minds (1996)" "Great Day in Harlem, A (1994)"
[4] "Tough and Deadly (1995)" "Brassed Off (1996)" "Dangerous Beauty (1998)"
[7] "Boys, Les (1997)" "Santa with Muscles (1996)" "Thousand Acres, A (1997)"
[10] "Horse Whisperer, The (1998)"
$`13`
[1] "Santa with Muscles (1996)" "Brassed Off (1996)" "Tough and Deadly (1995)" "Boys, Les (1997)"
[5] "Thousand Acres, A (1997)" "Margaret's Museum (1995)" "Total Eclipse (1995)" "Love! Valour! Compassion! (1997)"
[9] "Withnail and I (1987)" "Prefontaine (1997)"
$`15`
[1] "Two or Three Things I Know About Her (1966)" "Boys, Les (1997)" "Great Day in Harlem, A (1994)"
[4] "Tough and Deadly (1995)" "Dangerous Beauty (1998)" "Saint of Fort Washington, The (1993)"
[7] "Santa with Muscles (1996)" "Hearts and Minds (1996)" "Celestial Clockwork (1994)"
[10] "Whole Wide World, The (1996)"
$`16`
[1] "Great Day in Harlem, A (1994)" "Dangerous Beauty (1998)" "Hearts and Minds (1996)"
[4] "Two or Three Things I Know About Her (1966)" "Boys, Les (1997)" "Santa with Muscles (1996)"
[7] "Tough and Deadly (1995)" "Brassed Off (1996)" "Crooklyn (1994)"
[10] "Thousand Acres, A (1997)"
$`18`
[1] "Great Day in Harlem, A (1994)" "Two or Three Things I Know About Her (1966)" "Dangerous Beauty (1998)"
[4] "Hearts and Minds (1996)" "Santa with Muscles (1996)" "Tough and Deadly (1995)"
[7] "Boys, Les (1997)" "Whole Wide World, The (1996)" "Margaret's Museum (1995)"
[10] "Saint of Fort Washington, The (1993)"
否则,我们不知道您指的是哪个用户的预测功能。
您还可以预测测试数据,如下所示:
> as(predict(recom, test), "list")