mahout连接mysql 内容推荐 得不到推荐数据 10C

代码片段如下

 String driver = "com.mysql.jdbc.Driver";
            MysqlDataSource mysqlDataSource = new MysqlDataSource();
            mysqlDataSource.setServerName("");
            mysqlDataSource.setUser("");
            mysqlDataSource.setPassword("");
            mysqlDataSource.setDatabaseName("");

            Class.forName(driver);
            JDBCDataModel jdbcDataModel = new MySQLJDBCDataModel(mysqlDataSource,
                    preferenceTable,
                    userIDColumn,
                    itemIDColumn,
                    preferenceColumn,
                    timestampColumn);

            ReloadFromJDBCDataModel dataModel = new ReloadFromJDBCDataModel(jdbcDataModel);
            // 构造数据模型,计算内容相似度
            ItemSimilarity itemSimilarity = new PearsonCorrelationSimilarity(dataModel);
            // 构造推荐引擎
            Recommender recommender = new GenericItemBasedRecommender(dataModel, itemSimilarity);
            // 得到推荐的结果
            List<RecommendedItem> recommendedItemList = recommender.recommend(userId, recommendNum);

            for (RecommendedItem recommendedItem : recommendedItemList) {
                long itemID = recommendedItem.getItemID();
                float value = recommendedItem.getValue();
                System.out.println("itemID:" + itemID + "  --------------  " +  "value:" + value);
            }

数据库数据如下:
图片说明

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问