小编nik*_*kn8的帖子

如何建立 RF(随机森林)和 PSO(粒子群优化器)的混合模型以找到产品的最佳折扣?

我需要为每种产品(例如 A、B、C)找到最佳折扣,以便我可以最大限度地提高总销售额。我有每个产品的现有随机森林模型,将折扣和季节映射到销售。我如何组合这些模型并将它们提供给优化器以找到每个产品的最佳折扣?

选型理由:

  1. RF:它能够在预测变量和响应(sales_uplift_norm)之间提供更好的(wrt 线性模型)关系。
  2. PSO:在许多白皮书中建议(可在 researchgate/IEEE 获得),还有这里这里的python 包的可用性。

输入数据:用于在产品级别构建模型的示例数据。数据一览如下: 在此处输入图片说明

我遵循的想法/步骤:

  1. 为每个产品建立射频模型
    # pre-processed data
    products_pre_processed_data = {key:pre_process_data(df, key) for key, df in df_basepack_dict.items()}
    # rf models
    products_rf_model = {key:rf_fit(df) for key, df in products_pre_processed_data .items()}
Run Code Online (Sandbox Code Playgroud)
  • 将模型传递给优化器
    • 目标函数:最大化sales_uplift_norm(RF模型的响应变量)
    • 约束:
      • 总支出(A + B + C <= 20 的支出),支出 = total_units_sold_of_products * discount_percentage * mrp_of_products
      • 产品下限(A, B, C): [0.0, 0.0, 0.0] # 折扣百分比下限
      • 产品上限(A, B, C): [0.3, 0.4, 0.4] # 折扣百分比上限

sudo/示例代码# …

python optimization machine-learning mathematical-optimization particle-swarm

12
推荐指数
1
解决办法
478
查看次数

pycaret.time_series.TSForecastingExperiment ImportError:无法从“sklearn.model_selection._search”导入名称“_check_param_grid”

在 databricks 中导入Pycaret time-series(beta)模块时,我收到以下错误(我们之前运行成功)。请求您帮助解决问题。

\n

使用中的 pycaret 版本:

\n
import pycaret\npycaret.__version__  # Out[1]: '3.0.0'\n
Run Code Online (Sandbox Code Playgroud)\n

使用的python版本:

\n
import sys\nsys.version #Out[9]: '3.8.10 (default, Mar 15 2022, 12:22:08) \\n[GCC 9.4.0]'\n
Run Code Online (Sandbox Code Playgroud)\n

以下是该问题的堆栈跟踪。

\n
from pycaret.time_series import TSForecastingExperiment\n\n/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)\n    160             # Import the desired module. If you\xe2\x80\x99re seeing this while debugging a failed import,\n    161             # look at preceding stack frames for relevant error information.\n--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)\n    163 \n    164             is_root_import …
Run Code Online (Sandbox Code Playgroud)

python azure-databricks pycaret sktime

5
推荐指数
1
解决办法
2703
查看次数