当前位置: 首页>>代码示例>>Python>>正文


Python Utils.get_linear_estimate方法代码示例

本文整理汇总了Python中utils.utils.Utils.get_linear_estimate方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.get_linear_estimate方法的具体用法?Python Utils.get_linear_estimate怎么用?Python Utils.get_linear_estimate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.utils.Utils的用法示例。


在下文中一共展示了Utils.get_linear_estimate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: estimate

# 需要导入模块: from utils.utils import Utils [as 别名]
# 或者: from utils.utils.Utils import get_linear_estimate [as 别名]
    def estimate(self, deal, current_date, history_length):
        """ 使用当天deal历史销量拟合直线估计当天销量
        """
        daily_volumes = filter(lambda x:x[1] >= 0, deal['all_daily_volumes'].items())
        daily_volumes.sort(key = lambda x:x[0])
        earlist_date = current_date - datetime.timedelta(days = history_length)
        history_records = [item for item in daily_volumes if str(earlist_date) <= item[0] < str(current_date)]
        #logging.debug("DAILY_VOLUMES: %s; EARLY: %s; RECORD: %s" % (daily_volumes, earlist_date, history_records))
        if len(history_records) < 2:
            # 想画条线至少需要两个点
            return None

        xs = [(datetime.datetime.strptime(item[0], '%Y-%m-%d').date() - earlist_date).days for item in history_records]
        ys = [item[1] for item in history_records]
        x = (current_date - earlist_date).days
        linear_fit_volume = max(Utils.get_linear_estimate(xs, ys, x), 1)
        #logging.debug("X: %s, Y: %s, x: %s, fit: %s" % (xs, ys, x, linear_fit_volume))

        return linear_fit_volume
开发者ID:yantingxu,项目名称:mt_compdeal,代码行数:21,代码来源:DailyVolumeDetector.py


注:本文中的utils.utils.Utils.get_linear_estimate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。