优化 回归

应用数据科学 (Applied data science)

Price and quantity are two fundamental measures that determine the bottom line of every business, and setting the right price is one of the most important decisions a company can make. Under-pricing hurts the company’s revenue if consumers are willing to pay more and, on the other hand, over-pricing can hurt in a similar fashion if consumers are less inclined to buy the product at a higher price.

价格和数量是确定每项业务底线的两个基本指标,而设定正确的价格是公司可以做出的最重要决定之一。 如果消费者愿意支付更高的价格,定价过低会损害公司的收入;另一方面,如果消费者不太愿意以更高的价格购买产品,那么定价过高也会以类似的方式受到损害。

So given the tricky relationship between price and sales, where is the sweet spot — the optimum price — that maximizes product sales and earns most profit?

因此,考虑到价格与销售之间的棘手关系,最佳产品的最佳销售点在哪里?这可以最大化产品的销售并获得最大的利润?

The purpose of this article is to answer this question by implementing a combination of the economic theory and a regression algorithm in Python environment.

本文的目的是通过在Python环境中实现经济理论和回归算法的结合来回答这个问题。

1.资料 (1. Data)

We are optimizing a future price based on the relationship between historical price and sales, so the first thing we need is the past data on these two indicators. For this exercise, I’m using a time series data on historical beef sales and corresponding unit prices.

我们正在根据历史价格和销售量之间的关系来优化未来价格,因此我们需要的第一件事是这两个指标的过去数据。 在本练习中,我使用有关历史牛肉销售量和相应单价的时间序列数据。

# load dataimport pandas as pdbeef = pd# view first few rowsbeef.tail(5

The dataset contains a total of 91 observations of quantity-price pairs reported on a quarterly basis.

该数据集包含每季度报告的91个数量-价格对的观察值。

It is customary in data science to do exploratory data analysis (EDA), but I’m skipping that part to focus on modeling. Nevertheless, I strongly encourage taking this extra step to make sure you understand the data before building models.

数据科学中通常进行探索性数据分析(EDA),但我跳过了这一部分,而只关注建模。 不过,我强烈建议您采取额外的步骤,以确保您在构建模型之前了解数据。

2.图书馆 (2. Libraries)

We need to import libraries for three reasons: manipulating data, building the model, and visualizing the functions.

我们需要导入库的原因有三个:处理数据,构建模型和可视化功能。

We are importing numpy and pandas for creating and manipulating table, mtplotlib and seaborn for visualization and statsmodels API to build and run the regression model.

我们将导入numpypandas用于创建和操作表格, mtplotlibseaborn用于可视化和statsmodels API以构建和运行回归模型。

import numpy as npfrom pandas import DataFrameimport matplotlib.pyplot as pltimport seaborn as snsfrom statsmodels.formula.api import ols%matplotlib inline

2.定义利润函数 (2. Defining the profit function)

We know that revenue depends on the quantity sold and the unit price of products.

我们知道,收入取决于出售的数量和产品的单价。

We also know that profit is calculated by netting out costs from revenue.

我们也知道,利润是通过从收入中扣除成本来计算的。

Putting these two together we get the following equations:

将这两个放在一起,我们得到以下方程式:

# revenuerevenue = quantity * price # eq (1)# profitprofit = revenue - cost # eq (2)

We can rewrite the profit function by combining eq. #1 and 2 as follows:

我们可以结合等式来重写利润函数。 #1和2如下:

# revised profit functionprofit = quantity * price - cost # eq (3)

Eq #3 tells us that we need three pieces of information to calculate profit: quantity, price and cost.

方程3告诉我们,我们需要三项信息来计算利润:数量,价格和成本。

3.定义需求函数 (3. Defining the demand function)

We first need to establish the relationship between quantity and price — the demand function. This demand function is estimated from a “demand curve” based on the linear relationship between price and quantity.

我们首先需要建立数量和价格之间的关系-需求函数。 根据价格和数量之间的线性关系,根据“需求曲线”估算此需求函数。

# demand curvesns.lmplot(x = "Price", y = "Quantity", data = beef, fig_reg = True, size = 4)

To find that demand curve we will fit an Ordinary Least Square (OLS) regression model.

为了找到需求曲线,我们将拟合普通最小二乘(OLS)回归模型。

# fit OLS modelmodel = ols("Quantity ~ Price", data = beef).fit()# print model summaryprint(model.summary())

The following are the regression results with the necessary coefficients needed for further analysis.

以下是回归结果以及进一步分析所需的必要系数。

5.找到利润最大化的价格 (5. Finding the profit-maximizing price)

The coefficient we are looking for is coming from the regression model above — the intercept and the price coefficient — to measure the corresponding sales quantity. We can now plug these values into equation 3.

我们正在寻找的系数来自上面的回归模型(截距和价格系数),用于测量相应的销售量。 现在,我们可以将这些值插入方程式3。

# plugging regression coefficientsquantity = 30.05 - 0.0465 * price # eq (5)# the profit function in eq (3) becomesprofit = (30.05 - 0.0465 * price) * price - cost # eq (6)

The next step is to find the price we are looking for from a range of options. The codes below should be intuitive, but basically what we are doing here is calculating revenue for each price and the corresponding quantity sold.

下一步是从一系列选项中找到我们要寻找的价格。 下面的代码应该很直观,但是基本上我们在这里要做的是计算每个价格和相应销售数量的收入。

# a range of diffferent prices to find the optimum onePrice = [320, 330, 340, 350, 360, 370, 380, 390]# assuming a fixed costcost = 80Revenue = []for i in Price:   quantity_demanded = 30.05 - 0.0465 * i

   # profit function   Revenue.append((i-cost) * quantity_demanded)# create data frame of price and revenueprofit = pd.DataFrame({"Price": Price, "Revenue": Revenue})#plot revenue against priceplt.plot(profit["Price"], profit["Revenue"])

If price and revenue are plotted, we can visually identify the peak of the revenue and find the price that makes the revenue at the highest point on the curve.

如果绘制了价格和收入,我们可以直观地识别收入的峰值,并找到使收入处于曲线最高点的价格。

So we find that the maximum revenue at different price levels is reached at $3,726 when the price is set at $360.

因此,我们发现,当价格设为360美元时,在不同价格水平下的最高收入达到3,726美元。

# price at which revenue is maximumprofit[profit['Revenue'] == profit[['Revenue'].max()]

总结和结论 (Summary and conclusions)

The purpose of this article was to demonstrate how to find the price at which the revenue or profit is maximized using a combination of economic theory and statistical modeling. In the initial steps we defined the demand and profit functions, and then ran a regression to find the parameter values needed to feed into the profit/revenue function. And finally, we checked revenues under different price levels to get the price for the corresponding maximum revenue.

本文的目的是演示如何结合经济理论和统计模型找到使收益或利润最大化的价格。 在最初的步骤中,我们定义了需求和利润函数,然后进行回归以找到输入利润/收益函数所需的参数值。 最后,我们检查了不同价格水平下的收入,以获得对应的最大收入的价格。

翻译自: https://towardsdatascience.com/optimizing-product-price-using-regression-2c17688e65ea

优化 回归


http://www.taodudu.cc/news/show-995068.html

相关文章:

  • 大数据数据科学家常用面试题_进行数据科学工作面试
  • vue.js python_使用Python和Vue.js自动化报告过程
  • 计算机科学必读书籍_5篇关于数据科学家的产品分类必读文章
  • python 网页编程_通过Python编程检索网页
  • data studio_面向营销人员的Data Studio —报表指南
  • 乐高ev3 读取外部数据_数据就是新乐高
  • java 分裂数字_分裂的补充:超越数字,打印物理可视化
  • 比赛,幸福度_幸福与生活满意度
  • 5分钟内完成胸部CT扫描机器学习
  • openai-gpt_为什么到处都看到GPT-3?
  • 数据可视化及其重要性:Python
  • ai驱动数据安全治理_AI驱动的Web数据收集解决方案的新起点
  • 使用K-Means对美因河畔法兰克福的社区进行聚类
  • 因果关系和相关关系 大数据_数据科学中的相关性与因果关系
  • 分类结果可视化python_可视化分类结果的另一种方法
  • rstudio 管道符号_R中的管道指南
  • 时间序列因果关系_分析具有因果关系的时间序列干预:货币波动
  • 无法从套接字中获取更多数据_数据科学中应引起更多关注的一个组成部分
  • 深度学习数据更换背景_开始学习数据科学的最佳方法是了解其背景
  • 数据中台是下一代大数据_全栈数据科学:下一代数据科学家群体
  • 泰坦尼克数据集预测分析_探索性数据分析-泰坦尼克号数据集案例研究(第二部分)
  • 大数据技术 学习之旅_如何开始您的数据科学之旅?
  • 搜索引擎优化学习原理_如何使用数据科学原理来改善您的搜索引擎优化工作
  • 一件登录facebook_我从Facebook的R教学中学到的6件事
  • python 图表_使用Streamlit-Python将动画图表添加到仪表板
  • Lockdown Wheelie项目
  • 实现klib_使用klib加速数据清理和预处理
  • 简明易懂的c#入门指南_统计假设检验的简明指南
  • python 工具箱_Python交易工具箱:通过指标子图增强图表
  • python交互式和文件式_使用Python创建和自动化交互式仪表盘

优化 回归_使用回归优化产品价格相关推荐

  1. lasso回归和岭回归_如何计划新产品和服务机会的回归

    lasso回归和岭回归 Marketers sometimes have to be creative to offer customers something new without the lux ...

  2. python逻辑回归优化参数_逻辑回归模型怎么调整超参?

    题主标签有sklearn,就先默认你用得sklearn做逻辑回归. 调参 主要是防止过拟合,所以假定题主的目的防止过拟合为前提: 这里我简单提两个参数,penalty 惩罚项 sklearn 默认'l ...

  3. 逻辑斯蒂回归 逻辑回归_逻辑回归简介

    逻辑斯蒂回归 逻辑回归 Logistic regression is a classification algorithm, which is pretty popular in some commu ...

  4. 奇奇seo优化软件_信阳seo优化排名软件

    信阳seope4c65优化排名软件,5g时代的到来,使得很多企业对移动互联网的推广预算再次增加.究其原因,是移动互联网用户数量的增加,使得行业竞争对手增多,网络推广成本提高.如果预算不增加,企业网站的 ...

  5. 点石关键词排名优化软件_福建关键词优化软件有哪些

    关键词优化odb7a9福建软件有哪些目前,许多企业在互联网上进行营销网站建设和商务活动.但通常在互联网之后,大多数网站的关键词排名效果并不理想.这时,企业会问为什么我的关键词排名不好,不像其他同行网站 ...

  6. 百度搜索引擎优化指南_百度SEO优化和其他搜索引擎优化用什么不同的地方

    百度seo 一直是seo优化工作人员的核心研究对象,但是随着 360.搜狗.神马等搜索引擎不断的发展,这些搜索引擎的 seo 工作也开始越来越被重视,那么百度seo和 360 等平台seo的区别是什么 ...

  7. python网页优化公司_使用python优化scipy.optimize.minimize公司

    我将逐行检查您的代码,并强调一些问题:from scipy.optimize import minimize import numpy as np prices=np.array([[1.5,50,3 ...

  8. 点石关键词排名优化软件_重庆关键词优化排名

    关键词优化odb7a9排名重庆在做网络推广的时候,大家都知道外部链接对网站排名的重要性,不要忽略了站内链接的作用.外部链接大部分情况下是不好控制的,而且要经过很长时间的积累,内部链接却完全在自己的控制 ...

  9. spark java 逻辑回归_逻辑回归分类技术分享,使用Java和Spark区分垃圾邮件

    原标题:逻辑回归分类技术分享,使用Java和Spark区分垃圾邮件 由于最近的工作原因,小鸟很久没给大家分享技术了.今天小鸟就给大家介绍一种比较火的机器学习算法,逻辑回归分类算法. 回归是一种监督式学 ...

最新文章

  1. Linux常用系统管理命令(top、free、kill、df)
  2. OpenCASCADE:Inspector简介
  3. 如何使用BAdI ORDER_SAVE创建客户自定义的error message
  4. 浅谈大前端的代表技术及其影响,值得我们思考
  5. 2019五个最棒的机器学习课程
  6. c++ idea 插件_推荐 33 个 IDEA 最牛配置,写代码太爽了
  7. 【概率论】期望、方差、协方差、相关系数、相关与独立、样本估计量、点估计、区间估计
  8. 直播开篇——直播场景和技术分析
  9. H5网站模板——前台和后台
  10. putty连接linux设置文件夹,【整理】Windows用ssh连接Linux,想要从Linux上面上传/下载文件 - putty的子工具psftp...
  11. TFS2010中文版下载
  12. GPS 入门 5 —— 定位误差产生的原因和差分定位原理 (转)
  13. Code Review 有感
  14. Zotero使用指南03:扩充空间
  15. 7个靠谱的Windows软件下载网站,个个「纯净、安全、无捆绑」!
  16. java list stream avg_使用jdk8的Stream来获取list集合的最小值、最大值、总和、平均数...
  17. 107-周跳探测之MW
  18. 学计算机头发变白了,掉头发,头发变白可不是小事!该如何调理?
  19. java 获取复选框值
  20. 海康威视的综合安防管理平台部署

热门文章

  1. 【C++学习笔记一】C++类和对象详解
  2. 10-排序6 Sort with Swap(0, i) (25 分)
  3. 23. 合并K个排序链表
  4. 耗时两个礼拜,8000字安卓面试长文,建议收藏
  5. 判断IE版本与各浏览器的语句
  6. Django Rest Framework(一)
  7. SpringBoot返回json和xml
  8. docker在Centos上的安装
  9. Asp.net WebForm中应用Jquery EasyUI Layout
  10. kubeadm安装kubernetes 1.13.2多master高可用集群