Giter VIP home page Giter VIP logo

rfm's Introduction





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

rfm's People

Contributors

sonwanesuresh95 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.