Skip to main content

A Python package for sales forecasting, statistical analysis, and data-driven insights

Project description

salesanalyzer_mds

Documentation Status ci-cd

A python package that helps with the analysis on a sales data. The packagage will contain functions to be used as tools for identifying market segment, predicting future sales and analyzing seasonal revenue trends.

The sales_analyzer package will be an addition to the Python ecosystem as a specialized tool for analyzing retail sales data, targeting small to medium-sized businesses that may not have the resources for an in-house data analytics team and who could benefit from ready-to-use functions for common sales-related tasks. While existing packages such as Pandas and Scikit-learn provide general tools for data manipulation and machine learning predictions, salesanalyzer_mds aims to streamline the process by offering a suite of pre-built, retail-specific analytical functions.

Installation

$ pip install salesanalyzer_mds

Functions

  • segment_revenue_share: Segments products into three categories: cheap, medium, expensive, based on price, and calculates their respective share in total revenue.
  • predictSales: Predicts future sales based on the provided historical data and the target.
  • sales_summary_statistics: Calculates a variety of summary statistics that provide insights into overall sales performance, customer behavior, and product performance.

Usage

salesanalyzer_mds can be used to extract sales data insights from available data.

  1. Set up imports
from salesanalyzer_mds.sales_summary_statistics import sales_summary_statistics
from salesanalyzer_mds.segment_revenue_share import segment_revenue_share
from salesanalyzer_mds.predict_sales import predict_sales
import pandas as pd     # additional import to handle your sales data
  1. Load your sales data as pandas DataFrame

  2. Retrieve the insights:

Summary statistics

sales_summary_statistics(your_sales_data)

The sales_summary_statistics() function returns a pandas DataFrame with:

  • 'total_revenue': The total revenue generated by all sales.
  • 'unique_customers': The number of unique customers.
  • 'average_order_value': The average value of an order (sum of revenue per invoice).
  • 'top_selling_product_quantity': The product with the highest quantity sold.
  • 'top_selling_product_revenue': The product with the highest total revenue.
  • 'average_revenue_per_customer': The average revenue generated by each customer.

Segment revenue share

segment_revenue_share(your_sales_data, 
                      price_col='UnitPrice', 
                      quantity_col='Quantity',
                      price_thresholds=None)      # replace column names with your data column names

The segment_revenue_share() funtion returns a pandas DataFrame showing the total revenue share for each price segment: 'cheap', 'medium', 'expensive'. Custom price thresholds can be set by the user other set automatically.

  • Custom price thresholds can be set using the price_thresholds parameter.
  • If not specified, thresholds are automatically determined based on the data.

Predict sales

predict_sales(your_sales_data, 
              new_data,     # new sales data to base the predictions on
              numeric_features = ['UnitPrice'],
              categorical_features = ['Description', 'Country'], 
              target = 'Quantity', 
              date_feature = 'InvoiceDate')

The predict_sales() function returns a DataFrame with prediction values, and a printed out MSE score.

Developer notes:

Running The Tests

Run the following command in the terminal from the project's root directory to execute the tests:

pytest tests/

To assess the branch coverage for this package:

pytest --cov=salesanalyzer_mds --cov-branch

Dependencies

This package relies on the following dependencies as outlined in pyproject.toml:

  • python = ">=3.10"
  • scikit-learn = ">=1.6.1"
  • pandas = ">=2.2.3"
  • pytest = ">=8.3.4"
  • jupyter = ">=1.1.1"
  • myst-nb = ">=1.1.2"
  • sphinx-autoapi = ">=3.4.0"
  • sphinx-rtd-theme = ">=3.0.2"

Contributors

  • Yeji Sohn
  • Daria Khon
  • Franklin Aryee

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

salesanalyzer_mds was created by Yeji Sohn, Daria Khon, Franklin Aryee. It is licensed under the terms of the MIT license.

Credits

salesanalyzer_mds was created with cookiecutter and the py-pkgs-cookiecutter template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

salesanalyzer_mds-2.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

salesanalyzer_mds-2.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file salesanalyzer_mds-2.1.0.tar.gz.

File metadata

  • Download URL: salesanalyzer_mds-2.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for salesanalyzer_mds-2.1.0.tar.gz
Algorithm Hash digest
SHA256 b731def8c94998ee7b47ed1a936f1884cf020dec37447b4369067892f1cf3580
MD5 541e066930e48e8ebd2d2a2690c48473
BLAKE2b-256 d78439a04aa078cd87b8071aaa44aa801b9f282d64eeabd85a888645166ccff6

See more details on using hashes here.

File details

Details for the file salesanalyzer_mds-2.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for salesanalyzer_mds-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d95cdd1c6e8b719b37c59269e1d0752369985e8ba47f6cbeffc8aeb00a13b957
MD5 be7ed29425055a908a4cf9bf7a947578
BLAKE2b-256 a13ae913174bc1b47cad28eec6ce2b465937e5325a6b47d54047c661e7775a56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page