Documentation
¶
Overview ¶
`mkt` package provides marketing-related data analysis functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CAI = CustomerActivityIndex
CAI is an alias for CustomerActivityIndex.
Functions ¶
func CustomerActivityIndex ¶ added in v0.2.5
func CustomerActivityIndex(dt insyra.IDataTable, caiConfig CAIConfig) insyra.IDataTable
CustomerActivityIndex calculates the Customer Activity Index (CAI) for each customer based on their transaction history. It returns a DataTable containing CustomerID, MLE, WMLE, and CAI for each customer.
Parameters:
- dt: Input DataTable containing transaction records.
- caiConfig: Configuration for CAI calculation, including column indices/names and date format.
CAI ¶
CAI (Customer Activity Index) is a metric used to evaluate customer activity based on their transaction history. It tells the change in customer activity level over time. A positive CAI indicates a customer whose activity is increasing, while a negative CAI indicates a customer whose activity is decreasing.
**Only customers with at least 4 transactions are considered for CAI calculation.**
func RFM ¶
func RFM(dt insyra.IDataTable, rfmConfig RFMConfig) insyra.IDataTable
RFM performs RFM analysis on the given data table based on the provided configuration. It returns a new data table containing the R, F, M scores and the combined RFM score for each customer.
Types ¶
type CAIConfig ¶ added in v0.2.5
type CAIConfig struct {
CustomerIDColIndex string // The column index(A, B, C, ...) of customer ID in the data table
CustomerIDColName string // The column name of customer ID in the data table (if both index and name are provided, index takes precedence)
TradingDayColIndex string // The column index(A, B, C, ...) of trading day in the data table
TradingDayColName string // The column name of trading day in the data table (if both index and name are provided, index takes precedence)
DateFormat string // The format of the date string (e.g., "YYYY-MM-DD", "DD/MM/YYYY", "yyyy-mm-dd")
TimeScale TimeScale // The time scale for analysis (e.g., hourly, daily, weekly, monthly, yearly)
}
type RFMConfig ¶
type RFMConfig struct {
CustomerIDColIndex string // The column index(A, B, C, ...) of customer ID in the data table
CustomerIDColName string // The column name of customer ID in the data table (if both index and name are provided, index takes precedence)
TradingDayColIndex string // The column index(A, B, C, ...) of trading day in the data table
TradingDayColName string // The column name of trading day in the data table (if both index and name are provided, index takes precedence)
AmountColIndex string // The column index(A, B, C, ...) of amount in the data table
AmountColName string // The column name of amount in the data table (if both index and name are provided, index takes precedence)
NumGroups uint // The number of groups to divide the customers into
DateFormat string // The format of the date string (e.g., "YYYY-MM-DD", "DD/MM/YYYY", "yyyy-mm-dd")
TimeScale TimeScale // The time scale for analysis (e.g., hourly, daily, weekly, monthly, yearly)
}