Skip to main content




PyPI Latest Release PyPI Package Status License Downloads Per Month

rfm

rfm: Python Package for RFM Analysis and Customer Segmentation

Info

rfm is a Python package that provides recency, frequency, monetary analysis results for a certain transactional dataset within a snap. Its flexible structure and multiple automated functionalities provide easy and intuitive approach to RFM Analysis in an automated fashion. It aims to be a ready-made python package with high-level and quick prototyping. On practical hand, real world data is easily suited and adapted by the package. Additionally, it can make colorful, intuitive graphs using a matplotlib backend without breaking a sweat.

Installation

Dependencies

  • Python (>=3.7)
  • Pandas (>=1.2.4)
  • NumPy (>=1.20.1)
  • matplotlib (>=3.3.4)

To install the current release (Ubuntu and Windows):

$ pip install rfm

Usage

# predefine a transaction dataset as df

>>> from rfm import RFM

>>> r = RFM(df, customer_id='CustomerID', transaction_date='InvoiceDate', amount='Amount')

>>> r.plot_segment_distribution()

License

MIT

Documentation

<-- Temporarily Hosted Here -->

Initialization

Read required dataframe

>>> df = pd.read_csv('~./data.csv')

Import RFM package and start rfm analysis automatically:

>>> from rfm import RFM

>>> r = RFM(df, customer_id='CustomerID', transaction_date='InvoiceDate', amount='Amount') 

>>> r.rfm_table

If you want to do rfm analysis manually:

>>> r = RFM(df, customer_id='CustomerID', transaction_date='InvoiceDate', amount='Amount', automated=False)

Attributes

RFM.rfm_table

returns resultant rfm table df generated with recency, frequency & monetary values and scores along with segments

>>> r.rfm_table

RFM.segment_table

returns segment table df with 10 unique categories i.e. Champions, Loyal Accounts etc.

>>> r.segment_table

Methods

RFM.plot_rfm_histograms()

Plots recency, frequency and monetary histograms in a single row

>>> r.plot_rfm_histograms()

RFM.plot_rfm_order_distribution()

Plots orders by customer number

>>> r.plot_rfm_order_distribution()

RFM.plot_versace_plot(column1, column2)

Plots scatterplot of two input columns

>>> r.plot_versace_plot(column1='recency',column2='monetary_value')

>>> r.plot_versace_plot(column1='recency',column2='frequency')

>>> r.plot_versace_plot(column1='frequency',column2='monetary_value')

RFM.plot_distribution_by_segment(column, take)

Plots Distribution of input column by segment

>>> r.plot_distribution_by_segment(column='recency',take='median')

>>> r.plot_distribution_by_segment(column='frequency',take='median')

>>> r.plot_distribution_by_segment(column='monetary_value',take='median')

RFM.plot_column_distribution(column)

Plots column distribution of input column

>>> r.plot_column_distribution(column='recency')

>>> r.plot_column_distribution(column='frequency')

>>> r.plot_column_distribution(column='monetary_value')

RFM.plot_segment_distribution()

>>> r.plot_segment_distribution()

Plots Segment Distribution, i.e. Segments vs no. of customers


RFM.find_customers(segment)

returns rfm results df with input category

>>> r.find_customers('Champions')

Metadata

Release files for rfm 1.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rfm 1.0.9
File Size Uploaded
rfm-1.0.9.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rfm 1.0.9
File Interpreter ABI Platform
rfm-1.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / rfm-1.0.9.tar.gz

Download URL rfm-1.0.9.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8fdf94c9be11e8506abd647449713bb224a5e48b606ad2c92c26506d6ea72b00
BLAKE2b-256 checksum
How to use checksums
f4be3b4328843b492f5160271c0f35634fc0a72c03c7436817047e10a67c2794
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.4 tqdm/4.59.0 importlib-metadata/4.11.0 keyring/22.3.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.8

Release files / rfm-1.0.9-py3-none-any.whl

Download URL rfm-1.0.9-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d3e4890de4da3d933a8a3e1a4d09d27aa2b915126c3034712cb206bcd0c0f15
BLAKE2b-256 checksum
How to use checksums
6ace007d3dba0d0db657dc1641336674deb62cb33b5a68514a56897da67d7132
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.4 tqdm/4.59.0 importlib-metadata/4.11.0 keyring/22.3.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.8

Release history Release notifications | RSS feed

This release

1.0.9 This release

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page