Metric Forge
Metric Forge is your ultimate toolkit for measuring and evaluating performance across various business domains.
Disclaimer
Metric Forge provides a collection of calculations across various domains, including finance, mortgage, marketing, and more. While every effort has been made to ensure the accuracy and reliability of the calculations and methods provided, Metric Forge is intended for informational and educational purposes only.
Important Notice:
No Warranty: The calculations and methods provided in this package are offered "as-is" without any guarantees or warranties of any kind, either express or implied. The package's creators do not assume any responsibility for errors or omissions or for any damages resulting from the use of the package.
Not Professional Advice: The results produced by the package should not be considered as professional financial, investment, legal, or any other type of advice. Users should consult with qualified professionals before making any decisions based on the outputs generated by this package.
Use at Your Own Risk: Users of Metric Forge assume full responsibility for the use of the package and its results. The creators of the package shall not be held liable for any decisions made based on the information provided or for any consequences arising from the use of the package.
By using this package, you acknowledge and agree to this disclaimer. If you do not agree, please refrain from using the Metric Forge package.
Getting Started
install the package via pip
pip install metric-forge
Ecommerce
You can use Ecommerce Metrics in two different ways:
- With Polars
- As a Single Value Function (SVF)
Metric Forge extends the Polars expression library; making it possible to perform row-wise-calculations for various metrics. In addition to mass calculations, you can also perform single value calculations that return just one value.
from metric_forge.ecommerce import *
import polars as pl
data = pl.read_csv('datasets/ecommerce_metrics.csv')
data.head()
| month | total_revenue | number_of_orders | cost_of_acquisition | new_customers | carts_created | completed_purchases | revenue_from_ads | advertising_spend | num_conversions | num_visitors | revenue_per_customer | average_customer_lifetime | num_customers_lost | total_customers_beginning |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| str | f64 | i64 | f64 | i64 | i64 | i64 | f64 | f64 | i64 | i64 | f64 | f64 | i64 | i64 |
| "2023-01" | 87454.011885 | 991 | 22958.350559 | 406 | 1969 | 1425 | 81339.957696 | 5390.910169 | 300 | 13154 | 202.427329 | 3.159364 | 239 | 3306 |
| "2023-02" | 145071.430641 | 913 | 18736.874206 | 234 | 1506 | 1421 | 76875.083402 | 15585.037018 | 427 | 14762 | 116.173436 | 1.812245 | 124 | 4680 |
| "2023-03" | 123199.394181 | 1305 | 28355.586842 | 120 | 1497 | 965 | 116505.482191 | 14872.037954 | 367 | 10056 | 384.265156 | 4.771414 | 177 | 4675 |
| "2023-04" | 109865.84842 | 885 | 14184.81582 | 428 | 1963 | 1102 | 106008.046381 | 12337.204368 | 132 | 19948 | 144.356328 | 3.395462 | 299 | 2972 |
| "2023-05" | 65601.864044 | 691 | 18764.339456 | 266 | 1009 | 801 | 97258.809912 | 5351.995568 | 147 | 13110 | 275.734601 | 3.77914 | 296 | 3768 |
Customer Acquisition Cost
data.select(pl.col('cost_of_acquisition'),
pl.col('new_customers'),
pl.col('*').forge_ecommerce.customer_acquisition_cost('cost_of_acquisition', 'new_customers'))
Average Order Value
data.select(pl.col('total_revenue'),
pl.col('new_customers'),
pl.col('*').forge_ecommerce.average_order_value('total_revenue', 'number_of_orders'))
Cart Abandonment Rate
data.select(pl.col('carts_created'),
pl.col('completed_purchases'),
pl.col('*').forge_ecommerce.cart_abandonment_rate('carts_created', 'completed_purchases'))
Return on Advertising Spend
data.select(pl.col('revenue_from_ads'),
pl.col('advertising_spend'),
pl.col('*').forge_ecommerce.return_on_advertising_spend('revenue_from_ads', 'advertising_spend'))
Conversion Rate
data.select(pl.col('num_conversions'),
pl.col('num_visitors'),
pl.col('*').forge_ecommerce.conversion_rate('num_conversions', 'num_visitors'))
Customer Lifetime Value
data.select(pl.col('revenue_per_customer'),
pl.col('average_customer_lifetime'),
pl.col('*').forge_ecommerce.customer_lifetime_value(revenue_per_customer_column='revenue_per_customer',average_customer_lifetime_column='average_customer_lifetime',method='basic'))
| revenue_per_customer | average_customer_lifetime | customer_lifetime_value |
|---|---|---|
| f64 | f64 | f64 |
| 202.427329 | 3.159364 | 639.54169 |
| 116.173436 | 1.812245 | 210.534716 |
| 384.265156 | 4.771414 | 1833.488253 |
| 144.356328 | 3.395462 | 490.156408 |
| 275.734601 | 3.77914 | 1042.039585 |
| … | … | … |
| 290.148089 | 2.182535 | 633.258286 |
| 325.310229 | 1.421977 | 462.583676 |
| 378.206435 | 2.826138 | 1068.863683 |
| 155.732582 | 1.873762 | 291.805755 |
| 341.766952 | 2.66604 | 911.164293 |
Metadata
Release files for metric-forge 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| metric_forge-0.4.1.tar.gz | 21.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| metric_forge-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 46.6 kB
Release files / metric_forge-0.4.1.tar.gz
| Download URL | metric_forge-0.4.1.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5bd2625a0e6a531dd7241b2cf5844e0dc6f6803d5406bfd5bb8ff4d9b491131
|
|
BLAKE2b-256 checksum How to use checksums |
929f28dcee74259aa719096a0242ec5b04600d88a67db42606d65c79b74c265a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.7
|
Release files / metric_forge-0.4.1-py3-none-any.whl
| Download URL | metric_forge-0.4.1-py3-none-any.whl |
|---|---|
| Size | 25.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41b6b51c3f9707d69c5d409626307c545b10034361816396101d05eaaf8c7083
|
|
BLAKE2b-256 checksum How to use checksums |
09e92d2fa51796a55f653d5301bc7287453ef2ab0bc9b79dd9e1c3586dcc407e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.7
|