推荐算法修改

This commit is contained in:
tarzan
2021-05-13 11:45:32 +08:00
parent 9a987fa95b
commit 160c43046c
4 changed files with 13 additions and 15 deletions

View File

@@ -18,27 +18,22 @@ import java.util.stream.Collectors;
*/
public class Recommend{
/**
* 方法描述: 猜你喜欢
*
* @param
* @Return {@link List< ItemDTO>}
* @Return {@link List<ItemDTO>}
* @throws
* @author tarzan
* @date 2020年07月31日 17:28:06
*/
public static List<ItemDTO> guessYouLike(){
public static List<ItemDTO> guessUserLike(int userId){
CoreMath coreMath = new CoreMath();
List<RelateDTO> data= FileDataSource.getData();
List<Integer> recommendations = coreMath.recommend(2, data);
List<Integer> recommendations = coreMath.recommend(userId, data);
List<ItemDTO> itemList= FileDataSource.getItemData().stream().filter(e->recommendations.contains(e.getId())).collect(Collectors.toList());
return itemList;
}
public static void main(String[] args) {
List<ItemDTO> itemList= Recommend.guessYouLike();
System.out.println("------猜你可能喜欢---------------下列电影="+itemList.stream().map(e->e.getName()).collect(Collectors.toList()));
}
}