Pyspark.ml.Recommendation.als是否在引擎盖下创建一个枢轴表?

发布于 2025-02-03 00:21:21 字数 2336 浏览 2 评论 0 原文

ALS建议模型执行矩阵分解,其中将用户与潜在因素的项目分配。

A matrix of 3 users and 3 items would look like this:

users item_1 item_2 item_3
user_1 NA 4 1
user_2 4 3 0
user_3 NA 1 NA

My dataframe starts such as:

users items rating
user_1 item_2 4
user_1 item_3 1
user_2 item_1 4
user_2 item_2 3
user_2 item_3 0
User_3 item_2 1

我的问题是,在将我的数据框架插入ALS模块之前,我是否需要以这样的方式进行转换,最后我将具有一个结构,例如

用户 item ittem corting等级
user_1 item_1 na
user_1 item_2 4
user_1 item_3 1
user_2 item_2 4
user_2 item_2 3
user_2 user_2 item_3 0
user_3 user_3 item_1 na
user_3 item_3 euser_3
na item_3 item_3 na

will,在引擎盖下, ml.recommendation.als.als 函数函数创建与地方相关的观察值?例如:

用户 项目 评级
用户_1 item_1 na

如果不这样做,一种产生预期表的方法将是旋转它的,然后将其删除,但是它将产生非常巨大的用户矩阵与项目。但是,从中,似乎没有必要这个过程(枢轴,然后,undivot)。

An ALS recommendation model performs a matrix factorization where it factorizes a matrix of users vs items in latent factors.

A matrix of 3 users and 3 items would look like this:

users item_1 item_2 item_3
user_1 NA 4 1
user_2 4 3 0
user_3 NA 1 NA

My dataframe starts such as:

users items rating
user_1 item_2 4
user_1 item_3 1
user_2 item_1 4
user_2 item_2 3
user_2 item_3 0
user_3 item_2 1

My question is, before inserting my dataframe in ALS module, do I need to transform it in way where, at the end, I will have a structure such as:

users items rating
user_1 item_1 NA
user_1 item_2 4
user_1 item_3 1
user_2 item_1 4
user_2 item_2 3
user_2 item_3 0
user_3 item_1 NA
user_3 item_2 1
user_3 item_3 NA

Or, will, under the hood, ml.recommendation.ALS function create those observations related to the places without interactions? Such as:

users items rating
user_1 item_1 NA

If it does not, a way to produce the expected table, would be pivot it and then unpivot it, but it would produce a very huge matrix of users vs items. However, from the examples presented in the documentation, it seems that this process (pivot and then, unpivot) is not necessary.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

屌丝范 2025-02-10 00:21:21

是的。它不是必需的。

训练您的ALS模型后,拟合的模型应用于预测“丢失的交互”。

因此,术语“填充”(在您的句子中“ ml.recommendation.als”模块填充那些丢失的交互”)是不合适的,您应使用术语“预测”。

Yes. It is not necessary.

After you train you the ALS model, the fitted model should be used to predict the "missing interactions".

Thus, the term "fill" (in your sentence " ml.recommendation.ALS module fill those missing interactions") is not appropriate, you should uses the term "predict".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文