mkt

package
v0.2.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

`mkt` package provides marketing-related data analysis functions.

Index

Constants

This section is empty.

Variables

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)
}

type TimeScale added in v0.2.5

type TimeScale string
const (
	TimeScaleHourly  TimeScale = "hourly"
	TimeScaleDaily   TimeScale = "daily"
	TimeScaleWeekly  TimeScale = "weekly"
	TimeScaleMonthly TimeScale = "monthly"
	TimeScaleYearly  TimeScale = "yearly"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL