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 ML.NET to realize customer value Analysis based on RFM Model

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article shows you how to use ML.NET to achieve customer value analysis based on the RFM model, the content is concise and easy to understand, can definitely make your eyes bright, through the detailed introduction of this article, I hope you can get something.

RFM model

Among many customer value analysis models, RFM model is widely used, especially in the field of retail and enterprise services. Its core definition comes from the basic transaction data and reflects more intuitive classification instructions for customers with the help of appropriate clustering algorithms. For startups without the support of data analysis and machine learning technology, it is one of the simple and easy-to-use ways of customer analysis.

There are three main indicators in the RFM model:

Recency: recent consumption interval

Frequency: consumption frequency

Monetary: consumption amount

If we score customers on these three indicators, there will be a total of 27 combinations. Using the K-Means algorithm, we can reduce to a specified limited number of boxes (usually 5 categories), and calculate the value of each customer at the location of the box.

Of course, there are more derivative versions of the RFM model, which can be found in WiKi:RFM (customer value).

ML.NET and K-Means

ML.NET has provided the implementation of Kmure Meanswatch + clustering since v0.2. It is also the most common training for unsupervised learning, and is just suitable for performing machine learning for the classification of RFM models.

Basic requirements of hands-on practice

Visual Studio 2017 or Visual Studio Code

DotNet Core 2.0 +

ML.NET v0.3

Data source

This case data is from UCI:Online Retail, a multinational data set that contains all transactions in non-store online retail businesses registered in the UK between December 1, 2010 and December 9, 2011. The company mainly sells unique full-time gifts. Many of the company's customers are wholesalers.

Attribute information:

InvoiceNo: invoice number. A nominal value, a 6-digit integer uniquely assigned to each transaction. If this code starts with the letter'c', it means cancel.

StockCode: product (project) code. Nominal value, a 5-digit integer uniquely assigned to each different product.

Description: product (project) name. Title.

Quantity: the quantity of each product (project) per transaction. Numbers.

InvoiceDate: invoice date and time. A number that generates the date and time of each transaction.

UnitPrice: unit price. Figures, pound sterling unit product price.

CustomerID: customer number. Nominal value, a 5-digit integer uniquely assigned to each customer.

Country: name of the country. The name of each customer's country.

Data processing.

Using Excel, add four fields to the original data, namely Amount (amount, the result of multiplying the unit price by the quantity), Date (the integer value of InvoiceDate), Today (the integer value of the current day), and DateDiff (the difference between the current day and Date).

Establish a perspective view, get the sum of each customer on Amount, the maximum and minimum values of DateDiff, and calculate the frequency value by calculating the formula Amount/ (maximum of DateDiff-minimum of DateDiff + 1).

Calculate the RFM score according to the following rules

The difference of R: (maximum value of DateDiff-minimum value of DateDiff-2000) is 3 points less than 480,2 points between 480,750,1 point between 570,750,0 points respectively.

F: the frequency value is 5 points greater than 1000, 4 points between 1000 and 1000, 3 points between 50 and 1000, 2 points between 50 and 100, 1 point between 0 and 50, 0 points less than 0.

The total value of M:Amount was 5 points greater than 10000, 4 points between 5000 and 10000, 3 points between 2000 and 5000, 2 points between 1000 and 2000, 1 point between 0 and 1000, and 0 points less than 0.

Some partners may wonder why they should be divided in this way. in fact, this is an idea of reasonable segmentation of data distribution. in order to reduce the impact of the imbalance of data sources on machine learning, we try to make the distribution of data natural. Coding part

Still familiar, create a DotNet Core console application and add a reference to ML.NET through Nuget.

Create data structures for learning

Training part

Evaluation part

Prediction part

Calling part

Running result

As you can see, the customers I used for testing were assigned to Category 2.

Although the clustering work has been completed, the five categories still need to be traversed and predicted according to the original data set, and the meaning of each category can be effectively explained according to the corresponding relationship between the customer's RFM score and classification.

This simple example shows the machine learning of clustering using ML.NET. For the business that wants to start for their own company, do some customer analysis with lower barriers, using ML.NET will be a good choice. Of course, ML.NET is still iterating, and I hope you will continue to pay attention to the release of new features.

The above content is how to use ML.NET to implement customer value analysis based on RFM model. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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