Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use ALS algorithm to realize the Forecast of user's Music score

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

How to use ALS algorithm to achieve user music score prediction, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Introduction of ALS algorithm

ALS algorithm is a model-based recommendation algorithm, the basic idea is to decompose the sparse matrix and evaluate the value of the missing term, so as to get a basic training model. Then the new user and item data can be evaluated according to this model. ALS uses the alternating least square method to calculate the missing term, and the alternating least square method is developed on the basis of the least square method.

From the classification of collaborative filtering, ALS algorithm belongs to User-Item CF, also known as hybrid CF, which considers both User and Item.

We introduce the principle of the alternating least square method through the case of music scoring. The first raw data is the rating matrix An of each song for each listener, which may be very sparse, because not every user has heard all the songs. Not every user will rate every song.

ALS matrix decomposition decomposes the matrix An into the multiplication of two matrices, the X matrix and the Y matrix.

The product of matrix A = matrix X and matrix Y

The column representation of x and the horizontal representation of Y can be called factors in ALS. This factor is implicitly defined. It is assumed that there are three factors, namely, personality, education, and hobbies. The X and Y matrices of A matrix decomposed by ALS can be expressed as:

(the image above is an x matrix)

(the picture above is a Y matrix)

After being disassembled in this way, the data can easily be used to predict the score of the music. For example, there is listener 6, who has never heard of the song "Red Bean", but we can get the vector M of the X matrix of listener 6 in the matrix factorization. At this time, we can only multiply the vector M and the corresponding vector N of "Red Bean" in the Y matrix. We can predict the audience 6's rating for the song "Red Bean".

ALS experiment in PAI

Now we are experimenting with the case of ALS algorithm on PAI. The overall process only needs to include input data sources and ALS matrix decomposition components. This case has been integrated into the PAI-STUDIO home page template:

After creation, as shown in the figure:

1. Data source

The input data source contains 4 fields

User: user ID

Item: music ID

Score:user 's rating of item

2.ALS matrix decomposition

Three corresponding fields need to be set.

Parameter name parameter description value range is required, default value userColNameuser column column type must be bigint, discontinuous numbering required itemColNameitem column column type must be bigint, discontinuous numbering required rateColName column type must be numeric type must be numFactors factor number positive integer optional, default value 100numIter iteration number positive integer optional, default value 10lambda regularization coefficient floating point number optional Whether the default value 0.1implicitPref uses the implicit preference model Boolean is optional, the default value falsealpha implicit preference coefficient floating point, > 0 optional, the default value 403. Result analysis

In this case, two tables will be output, corresponding to the X matrix and Y matrix mentioned in the introduction to the ALS algorithm.

The X matrix table is shown in the figure:

The Y matrix table is shown in the figure:

For example, to predict user1's rating of music item994556636, you can simply multiply the two vectors below

User1: [- 0.14220297, 0.8327106, 0.5352268, 0.6336995, 1.2326205, 0.7112976, 0.9794858, 0.8489773, 0.330319, 0.7426911]

Item994556636: [0.71699333,0.5847747,0.96564907,0.36637592,0.77271074,0.52454436,0.69028413,0.2341857,0.73444265,0.8352135]

After reading the above, have you mastered how to use the ALS algorithm to realize the prediction of users' music scores? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report