The Ultimate Metric Library
Project description
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.with_columns(pl.col('*').forge_ecommerce.customer_acquisition_cost('cost_of_acquisition', 'new_customers'))
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 | customer_acquisition_cost |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
str | f64 | i64 | f64 | i64 | i64 | i64 | f64 | f64 | i64 | i64 | f64 | f64 | i64 | i64 | f64 |
"2023-01" | 87454.011885 | 991 | 22958.350559 | 406 | 1969 | 1425 | 81339.957696 | 5390.910169 | 300 | 13154 | 202.427329 | 3.159364 | 239 | 3306 | 56.547661 |
"2023-02" | 145071.430641 | 913 | 18736.874206 | 234 | 1506 | 1421 | 76875.083402 | 15585.037018 | 427 | 14762 | 116.173436 | 1.812245 | 124 | 4680 | 80.072112 |
"2023-03" | 123199.394181 | 1305 | 28355.586842 | 120 | 1497 | 965 | 116505.482191 | 14872.037954 | 367 | 10056 | 384.265156 | 4.771414 | 177 | 4675 | 236.296557 |
"2023-04" | 109865.84842 | 885 | 14184.81582 | 428 | 1963 | 1102 | 106008.046381 | 12337.204368 | 132 | 19948 | 144.356328 | 3.395462 | 299 | 2972 | 33.142093 |
"2023-05" | 65601.864044 | 691 | 18764.339456 | 266 | 1009 | 801 | 97258.809912 | 5351.995568 | 147 | 13110 | 275.734601 | 3.77914 | 296 | 3768 | 70.54263 |
… | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … |
"2023-08" | 136617.614577 | 660 | 33555.278842 | 188 | 1108 | 601 | 116872.977654 | 24754.388513 | 392 | 8840 | 290.148089 | 2.182535 | 280 | 3479 | 178.485526 |
"2023-09" | 110111.501174 | 959 | 15990.213465 | 415 | 1975 | 1395 | 84633.082292 | 20148.99937 | 198 | 6028 | 325.310229 | 1.421977 | 239 | 3434 | 38.530635 |
"2023-10" | 120807.25778 | 813 | 25427.033152 | 113 | 800 | 669 | 54839.926382 | 28157.521963 | 271 | 12385 | 378.206435 | 2.826138 | 274 | 2648 | 225.017992 |
"2023-11" | 52058.44943 | 521 | 27772.437066 | 341 | 2005 | 1215 | 56664.615513 | 21276.925638 | 459 | 5502 | 155.732582 | 1.873762 | 178 | 2317 | 81.444097 |
"2023-12" | 146990.985216 | 752 | 11393.512382 | 364 | 1704 | 855 | 44874.024516 | 27873.991889 | 313 | 11910 | 341.766952 | 2.66604 | 170 | 3257 | 31.300858 |
Average Order Value
data.with_columns(pl.col('*').forge_ecommerce.average_order_value('total_revenue', 'number_of_orders'))
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 | average_order_value |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
str | f64 | i64 | f64 | i64 | i64 | i64 | f64 | f64 | i64 | i64 | f64 | f64 | i64 | i64 | f64 |
"2023-01" | 87454.011885 | 991 | 22958.350559 | 406 | 1969 | 1425 | 81339.957696 | 5390.910169 | 300 | 13154 | 202.427329 | 3.159364 | 239 | 3306 | 88.248246 |
"2023-02" | 145071.430641 | 913 | 18736.874206 | 234 | 1506 | 1421 | 76875.083402 | 15585.037018 | 427 | 14762 | 116.173436 | 1.812245 | 124 | 4680 | 158.895324 |
"2023-03" | 123199.394181 | 1305 | 28355.586842 | 120 | 1497 | 965 | 116505.482191 | 14872.037954 | 367 | 10056 | 384.265156 | 4.771414 | 177 | 4675 | 94.405666 |
"2023-04" | 109865.84842 | 885 | 14184.81582 | 428 | 1963 | 1102 | 106008.046381 | 12337.204368 | 132 | 19948 | 144.356328 | 3.395462 | 299 | 2972 | 124.142202 |
"2023-05" | 65601.864044 | 691 | 18764.339456 | 266 | 1009 | 801 | 97258.809912 | 5351.995568 | 147 | 13110 | 275.734601 | 3.77914 | 296 | 3768 | 94.937575 |
… | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … |
"2023-08" | 136617.614577 | 660 | 33555.278842 | 188 | 1108 | 601 | 116872.977654 | 24754.388513 | 392 | 8840 | 290.148089 | 2.182535 | 280 | 3479 | 206.996386 |
"2023-09" | 110111.501174 | 959 | 15990.213465 | 415 | 1975 | 1395 | 84633.082292 | 20148.99937 | 198 | 6028 | 325.310229 | 1.421977 | 239 | 3434 | 114.819084 |
"2023-10" | 120807.25778 | 813 | 25427.033152 | 113 | 800 | 669 | 54839.926382 | 28157.521963 | 271 | 12385 | 378.206435 | 2.826138 | 274 | 2648 | 148.594413 |
"2023-11" | 52058.44943 | 521 | 27772.437066 | 341 | 2005 | 1215 | 56664.615513 | 21276.925638 | 459 | 5502 | 155.732582 | 1.873762 | 178 | 2317 | 99.920248 |
"2023-12" | 146990.985216 | 752 | 11393.512382 | 364 | 1704 | 855 | 44874.024516 | 27873.991889 | 313 | 11910 | 341.766952 | 2.66604 | 170 | 3257 | 195.466736 |
Cart Abandonment Rate
data.with_columns(pl.col('*').forge_ecommerce.cart_abandonment_rate('carts_created', 'completed_purchases'))
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 | cart_abandonment_rate |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
str | f64 | i64 | f64 | i64 | i64 | i64 | f64 | f64 | i64 | i64 | f64 | f64 | i64 | i64 | f64 |
"2023-01" | 87454.011885 | 991 | 22958.350559 | 406 | 1969 | 1425 | 81339.957696 | 5390.910169 | 300 | 13154 | 202.427329 | 3.159364 | 239 | 3306 | 27.628238 |
"2023-02" | 145071.430641 | 913 | 18736.874206 | 234 | 1506 | 1421 | 76875.083402 | 15585.037018 | 427 | 14762 | 116.173436 | 1.812245 | 124 | 4680 | 5.64409 |
"2023-03" | 123199.394181 | 1305 | 28355.586842 | 120 | 1497 | 965 | 116505.482191 | 14872.037954 | 367 | 10056 | 384.265156 | 4.771414 | 177 | 4675 | 35.537742 |
"2023-04" | 109865.84842 | 885 | 14184.81582 | 428 | 1963 | 1102 | 106008.046381 | 12337.204368 | 132 | 19948 | 144.356328 | 3.395462 | 299 | 2972 | 43.861437 |
"2023-05" | 65601.864044 | 691 | 18764.339456 | 266 | 1009 | 801 | 97258.809912 | 5351.995568 | 147 | 13110 | 275.734601 | 3.77914 | 296 | 3768 | 20.61447 |
… | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … |
"2023-08" | 136617.614577 | 660 | 33555.278842 | 188 | 1108 | 601 | 116872.977654 | 24754.388513 | 392 | 8840 | 290.148089 | 2.182535 | 280 | 3479 | 45.758123 |
"2023-09" | 110111.501174 | 959 | 15990.213465 | 415 | 1975 | 1395 | 84633.082292 | 20148.99937 | 198 | 6028 | 325.310229 | 1.421977 | 239 | 3434 | 29.367089 |
"2023-10" | 120807.25778 | 813 | 25427.033152 | 113 | 800 | 669 | 54839.926382 | 28157.521963 | 271 | 12385 | 378.206435 | 2.826138 | 274 | 2648 | 16.375 |
"2023-11" | 52058.44943 | 521 | 27772.437066 | 341 | 2005 | 1215 | 56664.615513 | 21276.925638 | 459 | 5502 | 155.732582 | 1.873762 | 178 | 2317 | 39.401496 |
"2023-12" | 146990.985216 | 752 | 11393.512382 | 364 | 1704 | 855 | 44874.024516 | 27873.991889 | 313 | 11910 | 341.766952 | 2.66604 | 170 | 3257 | 49.823944 |
Return on Advertising Spend
data.with_columns(pl.col('*').forge_ecommerce.return_on_advertising_spend('revenue_from_ads', 'advertising_spend'))
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 | return_on_advertising_spend |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
str | f64 | i64 | f64 | i64 | i64 | i64 | f64 | f64 | i64 | i64 | f64 | f64 | i64 | i64 | f64 |
"2023-01" | 87454.011885 | 991 | 22958.350559 | 406 | 1969 | 1425 | 81339.957696 | 5390.910169 | 300 | 13154 | 202.427329 | 3.159364 | 239 | 3306 | 15.088353 |
"2023-02" | 145071.430641 | 913 | 18736.874206 | 234 | 1506 | 1421 | 76875.083402 | 15585.037018 | 427 | 14762 | 116.173436 | 1.812245 | 124 | 4680 | 4.932621 |
"2023-03" | 123199.394181 | 1305 | 28355.586842 | 120 | 1497 | 965 | 116505.482191 | 14872.037954 | 367 | 10056 | 384.265156 | 4.771414 | 177 | 4675 | 7.833861 |
"2023-04" | 109865.84842 | 885 | 14184.81582 | 428 | 1963 | 1102 | 106008.046381 | 12337.204368 | 132 | 19948 | 144.356328 | 3.395462 | 299 | 2972 | 8.59255 |
"2023-05" | 65601.864044 | 691 | 18764.339456 | 266 | 1009 | 801 | 97258.809912 | 5351.995568 | 147 | 13110 | 275.734601 | 3.77914 | 296 | 3768 | 18.172438 |
… | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … |
"2023-08" | 136617.614577 | 660 | 33555.278842 | 188 | 1108 | 601 | 116872.977654 | 24754.388513 | 392 | 8840 | 290.148089 | 2.182535 | 280 | 3479 | 4.721303 |
"2023-09" | 110111.501174 | 959 | 15990.213465 | 415 | 1975 | 1395 | 84633.082292 | 20148.99937 | 198 | 6028 | 325.310229 | 1.421977 | 239 | 3434 | 4.200362 |
"2023-10" | 120807.25778 | 813 | 25427.033152 | 113 | 800 | 669 | 54839.926382 | 28157.521963 | 271 | 12385 | 378.206435 | 2.826138 | 274 | 2648 | 1.947612 |
"2023-11" | 52058.44943 | 521 | 27772.437066 | 341 | 2005 | 1215 | 56664.615513 | 21276.925638 | 459 | 5502 | 155.732582 | 1.873762 | 178 | 2317 | 2.663196 |
"2023-12" | 146990.985216 | 752 | 11393.512382 | 364 | 1704 | 855 | 44874.024516 | 27873.991889 | 313 | 11910 | 341.766952 | 2.66604 | 170 | 3257 | 1.609889 |
Conversion Rate
data.with_columns(pl.col('*').forge_ecommerce.conversion_rate('num_conversions', 'num_visitors'))
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 | conversion_rate |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
str | f64 | i64 | f64 | i64 | i64 | i64 | f64 | f64 | i64 | i64 | f64 | f64 | i64 | i64 | f64 |
"2023-01" | 87454.011885 | 991 | 22958.350559 | 406 | 1969 | 1425 | 81339.957696 | 5390.910169 | 300 | 13154 | 202.427329 | 3.159364 | 239 | 3306 | 2.280675 |
"2023-02" | 145071.430641 | 913 | 18736.874206 | 234 | 1506 | 1421 | 76875.083402 | 15585.037018 | 427 | 14762 | 116.173436 | 1.812245 | 124 | 4680 | 2.892562 |
"2023-03" | 123199.394181 | 1305 | 28355.586842 | 120 | 1497 | 965 | 116505.482191 | 14872.037954 | 367 | 10056 | 384.265156 | 4.771414 | 177 | 4675 | 3.649562 |
"2023-04" | 109865.84842 | 885 | 14184.81582 | 428 | 1963 | 1102 | 106008.046381 | 12337.204368 | 132 | 19948 | 144.356328 | 3.395462 | 299 | 2972 | 0.66172 |
"2023-05" | 65601.864044 | 691 | 18764.339456 | 266 | 1009 | 801 | 97258.809912 | 5351.995568 | 147 | 13110 | 275.734601 | 3.77914 | 296 | 3768 | 1.121281 |
… | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … |
"2023-08" | 136617.614577 | 660 | 33555.278842 | 188 | 1108 | 601 | 116872.977654 | 24754.388513 | 392 | 8840 | 290.148089 | 2.182535 | 280 | 3479 | 4.434389 |
"2023-09" | 110111.501174 | 959 | 15990.213465 | 415 | 1975 | 1395 | 84633.082292 | 20148.99937 | 198 | 6028 | 325.310229 | 1.421977 | 239 | 3434 | 3.284672 |
"2023-10" | 120807.25778 | 813 | 25427.033152 | 113 | 800 | 669 | 54839.926382 | 28157.521963 | 271 | 12385 | 378.206435 | 2.826138 | 274 | 2648 | 2.188131 |
"2023-11" | 52058.44943 | 521 | 27772.437066 | 341 | 2005 | 1215 | 56664.615513 | 21276.925638 | 459 | 5502 | 155.732582 | 1.873762 | 178 | 2317 | 8.342421 |
"2023-12" | 146990.985216 | 752 | 11393.512382 | 364 | 1704 | 855 | 44874.024516 | 27873.991889 | 313 | 11910 | 341.766952 | 2.66604 | 170 | 3257 | 2.628044 |
Customer Lifetime Value
data.with_columns(pl.col('*').forge_ecommerce.customer_lifetime_value('revenue_per_customer', 'average_customer_lifetime'))
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 | customer_lifetime_value |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
str | f64 | i64 | f64 | i64 | i64 | i64 | f64 | f64 | i64 | i64 | f64 | f64 | i64 | i64 | f64 |
"2023-01" | 87454.011885 | 991 | 22958.350559 | 406 | 1969 | 1425 | 81339.957696 | 5390.910169 | 300 | 13154 | 202.427329 | 3.159364 | 239 | 3306 | 639.54169 |
"2023-02" | 145071.430641 | 913 | 18736.874206 | 234 | 1506 | 1421 | 76875.083402 | 15585.037018 | 427 | 14762 | 116.173436 | 1.812245 | 124 | 4680 | 210.534716 |
"2023-03" | 123199.394181 | 1305 | 28355.586842 | 120 | 1497 | 965 | 116505.482191 | 14872.037954 | 367 | 10056 | 384.265156 | 4.771414 | 177 | 4675 | 1833.488253 |
"2023-04" | 109865.84842 | 885 | 14184.81582 | 428 | 1963 | 1102 | 106008.046381 | 12337.204368 | 132 | 19948 | 144.356328 | 3.395462 | 299 | 2972 | 490.156408 |
"2023-05" | 65601.864044 | 691 | 18764.339456 | 266 | 1009 | 801 | 97258.809912 | 5351.995568 | 147 | 13110 | 275.734601 | 3.77914 | 296 | 3768 | 1042.039585 |
… | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … |
"2023-08" | 136617.614577 | 660 | 33555.278842 | 188 | 1108 | 601 | 116872.977654 | 24754.388513 | 392 | 8840 | 290.148089 | 2.182535 | 280 | 3479 | 633.258286 |
"2023-09" | 110111.501174 | 959 | 15990.213465 | 415 | 1975 | 1395 | 84633.082292 | 20148.99937 | 198 | 6028 | 325.310229 | 1.421977 | 239 | 3434 | 462.583676 |
"2023-10" | 120807.25778 | 813 | 25427.033152 | 113 | 800 | 669 | 54839.926382 | 28157.521963 | 271 | 12385 | 378.206435 | 2.826138 | 274 | 2648 | 1068.863683 |
"2023-11" | 52058.44943 | 521 | 27772.437066 | 341 | 2005 | 1215 | 56664.615513 | 21276.925638 | 459 | 5502 | 155.732582 | 1.873762 | 178 | 2317 | 291.805755 |
"2023-12" | 146990.985216 | 752 | 11393.512382 | 364 | 1704 | 855 | 44874.024516 | 27873.991889 | 313 | 11910 | 341.766952 | 2.66604 | 170 | 3257 | 911.164293 |
Product Development
You can use Product Development 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.
import polars as pl
data = pl.read_csv('datasets/customer-value.csv')
data
feature_name | importance_score | satisfaction_score |
---|---|---|
str | i64 | i64 |
"Feature1" | 8 | 7 |
"Feature2" | 6 | 8 |
"Feature3" | 7 | 9 |
"Feature4" | 8 | 7 |
"Feature5" | 6 | 6 |
"Feature6" | 9 | 8 |
"Feature7" | 7 | 9 |
"Feature8" | 6 | 7 |
"Feature9" | 9 | 8 |
"Feature10" | 8 | 7 |
Underserved Customer Needs
from metric_forge.product_development import *
data.with_columns(pl.col('*').forge_product_dev.opportunity_score(importance_col='importance_score',satisfaction_col='satisfaction_score'))
feature_name | importance_score | satisfaction_score | opportunity_score |
---|---|---|---|
str | i64 | i64 | f64 |
"Feature1" | 8 | 7 | 9.0 |
"Feature2" | 6 | 8 | 4.0 |
"Feature3" | 7 | 9 | 5.0 |
"Feature4" | 8 | 7 | 9.0 |
"Feature5" | 6 | 6 | 6.0 |
"Feature6" | 9 | 8 | 10.0 |
"Feature7" | 7 | 9 | 5.0 |
"Feature8" | 6 | 7 | 5.0 |
"Feature9" | 9 | 8 | 10.0 |
"Feature10" | 8 | 7 | 9.0 |
data.with_columns(pl.col('*').forge_product_dev.customer_value_delivered(importance_col='importance_score',satisfaction_col='satisfaction_score'))
feature_name | importance_score | satisfaction_score | customer_value_delivered |
---|---|---|---|
str | i64 | i64 | f64 |
"Feature1" | 8 | 7 | 0.56 |
"Feature2" | 6 | 8 | 0.48 |
"Feature3" | 7 | 9 | 0.63 |
"Feature4" | 8 | 7 | 0.56 |
"Feature5" | 6 | 6 | 0.36 |
"Feature6" | 9 | 8 | 0.72 |
"Feature7" | 7 | 9 | 0.63 |
"Feature8" | 6 | 7 | 0.42 |
"Feature9" | 9 | 8 | 0.72 |
"Feature10" | 8 | 7 | 0.56 |
data.with_columns(pl.col('*').forge_product_dev.opportunity_to_add_value(importance_col='importance_score',satisfaction_col='satisfaction_score'))
feature_name | importance_score | satisfaction_score | opp_to_add_value |
---|---|---|---|
str | i64 | i64 | f64 |
"Feature1" | 8 | 7 | 0.24 |
"Feature2" | 6 | 8 | 0.12 |
"Feature3" | 7 | 9 | 0.07 |
"Feature4" | 8 | 7 | 0.24 |
"Feature5" | 6 | 6 | 0.24 |
"Feature6" | 9 | 8 | 0.18 |
"Feature7" | 7 | 9 | 0.07 |
"Feature8" | 6 | 7 | 0.18 |
"Feature9" | 9 | 8 | 0.18 |
"Feature10" | 8 | 7 | 0.24 |
import polars as pl
data = pl.read_csv('datasets/customer-value-added.csv')
data
feature_name | importance_score | satisfaction_score_before | satisfaction_score_after |
---|---|---|---|
str | i64 | i64 | i64 |
"Feature1" | 8 | 7 | 9 |
"Feature2" | 9 | 8 | 9 |
"Feature3" | 7 | 9 | 8 |
"Feature4" | 8 | 7 | 8 |
"Feature5" | 6 | 6 | 8 |
"Feature6" | 9 | 8 | 9 |
"Feature7" | 7 | 9 | 8 |
"Feature8" | 6 | 7 | 6 |
"Feature9" | 9 | 8 | 8 |
"Feature10" | 8 | 7 | 7 |
data.with_columns(pl.col('*').forge_product_dev.customer_value_created(importance_col='importance_score'
,satisfaction_after_col='satisfaction_score_after'
,satisfaction_before_col='satisfaction_score_before'))
feature_name | importance_score | satisfaction_score_before | satisfaction_score_after | customer_value_created |
---|---|---|---|---|
str | i64 | i64 | i64 | f64 |
"Feature1" | 8 | 7 | 9 | 0.16 |
"Feature2" | 9 | 8 | 9 | 0.09 |
"Feature3" | 7 | 9 | 8 | -0.07 |
"Feature4" | 8 | 7 | 8 | 0.08 |
"Feature5" | 6 | 6 | 8 | 0.12 |
"Feature6" | 9 | 8 | 9 | 0.09 |
"Feature7" | 7 | 9 | 8 | -0.07 |
"Feature8" | 6 | 7 | 6 | -0.06 |
"Feature9" | 9 | 8 | 8 | 0.0 |
"Feature10" | 8 | 7 | 7 | 0.0 |
Finance
The Finance module contains financial statement objects that you can call certain methods off of to get key financial metrics. You need to define these objects prior to running calcuations.
Income Statement
from metric_forge import *
income = IncomeStatement(revenue=10000,cogs=2000,expenses=3000,)
income.ebitda_margin()
0.5
income.earnings_per_share()
'Missing parameters: revenue, cogs, expenses, shares_outstanding'
income.net_profit_margin()
0.5
Balance Sheet
BalanceSheet(assets=300000,total_liabilities=150000,equity=150000).check_balance()
'The balance equation is correct: Assets - Liabilities = Equity'
Cash Flow
CashFlowStatement(operating_cash_flow=3000,capital_expenditures=4000).free_cash_flow()
-1000
Mortgage
The Mortgage module contains mortgage objects that you enable you to assess mortgage metrics. You need to define these objects prior to running calcuations.
from metric_forge.mortgage import *
mortgage = Mortgage(principal=360000,annual_interest_rate=5.75,start_date='2023-09-01',term_years=30,extra_principal_payment=200)
mortgage.calculate_monthly_payment()
2100.8622831967773
mortgage.generate_amortization_schedule()
payment_number | payment_date | payment | interest_payment | principal_payment | principal_remaining |
---|---|---|---|---|---|
i64 | str | f64 | f64 | f64 | f64 |
1 | "2023-10-01" | 2100.862283 | 1725.0 | 375.862283 | 359624.137717 |
2 | "2023-10-31" | 2100.862283 | 1723.198993 | 377.66329 | 359246.474427 |
3 | "2023-11-30" | 2100.862283 | 1721.389357 | 379.472927 | 358867.0015 |
4 | "2023-12-30" | 2100.862283 | 1719.571049 | 381.291234 | 358485.710266 |
5 | "2024-01-29" | 2100.862283 | 1717.744028 | 383.118255 | 358102.592011 |
… | … | … | … | … | … |
356 | "2052-11-27" | 2100.862283 | 49.617632 | 2051.244651 | 8303.739506 |
357 | "2052-12-27" | 2100.862283 | 39.788752 | 2061.073531 | 6242.665975 |
358 | "2053-01-26" | 2100.862283 | 29.912774 | 2070.949509 | 4171.716466 |
359 | "2053-02-25" | 2100.862283 | 19.989475 | 2080.872808 | 2090.843657 |
360 | "2053-03-27" | 2100.862283 | 10.018626 | 2090.843657 | 1.4501e-8 |
mortgage.calculate_principal_only_payment()
{'new_term_years': 24.14759462810461, 'time_saved_years': 5.85240537189539}
mortgage.refinance_assessment(RefinanceOption(new_loan_amount=350000,new_annual_interest_rate=5.25,new_term_years=30,associated_costs=5000))
{'Old Monthly Payment': 2100.8622831967773,
'New Monthly Payment': 1932.7129574966407,
'Monthly Savings': 168.14932570013661,
'Break-Even Point (months)': 29.735474579996712,
'Total Savings (over the loan term)': 55533.75725204917,
'Should Refinance': True}
Web Traffic
from metric_forge.web_traffic import *
import polars as pl
data = pl.read_csv('datasets/web_traffic.csv')
data
total_duration | total_sessions | single_page_sessions | num_clicks | num_impressions | total_cost | exits | total_page_views |
---|---|---|---|---|---|---|---|
str | i64 | i64 | i64 | i64 | i64 | i64 | i64 |
"1200" | 10 | 2 | 100 | 1000 | 50 | 5 | 50 |
"1500" | 15 | 3 | 150 | 1500 | 75 | 7 | 70 |
"0" | 0 | 1 | 0 | 0 | 0 | 2 | 20 |
"2500" | 25 | 5 | 200 | 2000 | 100 | 10 | 100 |
null | null | null | null | null | null | null | null |
data.with_columns(pl.col('*').forge_web_traffic.average_session_duration('total_duration', 'total_sessions'))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[25], line 1
----> 1 data.with_columns(pl.col('*').forge_web_traffic.average_session_duration('total_duration', 'total_sessions'))
TypeError: WebTraffic_Polars.average_session_duration() takes 2 positional arguments but 3 were given
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
Built Distribution
File details
Details for the file metric_forge-0.2.1.tar.gz
.
File metadata
- Download URL: metric_forge-0.2.1.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb29be8249c1f24e4da6a9eb3a910facb616bd06c1f46ad373e40540a20e39e5 |
|
MD5 | 3f55fab1202cd495df034c017eb2531d |
|
BLAKE2b-256 | 8ad8367e7c5a5c96fb2901068b0edb29060019def87a163899d149b10a54d363 |
File details
Details for the file metric_forge-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: metric_forge-0.2.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d964aca5e813c2a1e5bbde5b8c4cbd6fea8343861ea6e60fd44ebba86423e02 |
|
MD5 | be28da07fcff4d2f7850b4decc7a08bd |
|
BLAKE2b-256 | 2e0c79c567e5655cff9513787238dbf6adb531c4d484fd0acfdfd53e6ad44bb1 |