def payment_prob(a, b):
  """
  ppt[due_day] = [(delay, prob), ...]
  due_day is day of week (0=monday), delay is in days after due date, prob is from 0 to 1.0
  based on statistics for on time payments in my account
  """
  if not usfedhol.contains_holiday(a, b):
    ppt = {0: [(7, 0.99)],
           1: [(6, 0.99)],
           2: [(6, 0.99)],
           3: [(6, 0.99)],
           4: [(6, 0.99)],
           5: [(5, 0.99)],
           6: [(5, 0.99)]}
  else:
    ppt = {0: [(4, 0.8077), (7, 0.1827)],
           1: [(6, 0.0120), (7, 0.9880)],
           2: [(6, 0.0275), (7, 0.9725)],
           3: [(6, 0.1638), (7, 0.8362)],
           4: [(6, 0.2143), (7, 0.7857)],
           5: [(6, 0.99)],
           6: [(5, 0.99)]}
  delta = (b - a).days
  return sum(map(lambda x: x[1],
                 filter(lambda x: x[0] < delta, ppt[a.weekday()])))
示例#2
0
def payment_prob(a, b):
    """
  ppt[due_day] = [(delay, prob), ...]
  due_day is day of week (0=monday), delay is in days after due date, prob is from 0 to 1.0
  based on statistics for on time payments in my account
  """
    if not usfedhol.contains_holiday(a, b):
        ppt = {
            0: [(7, 0.99)],
            1: [(6, 0.99)],
            2: [(6, 0.99)],
            3: [(6, 0.99)],
            4: [(6, 0.99)],
            5: [(5, 0.99)],
            6: [(5, 0.99)]
        }
    else:
        ppt = {
            0: [(4, 0.8077), (7, 0.1827)],
            1: [(6, 0.0120), (7, 0.9880)],
            2: [(6, 0.0275), (7, 0.9725)],
            3: [(6, 0.1638), (7, 0.8362)],
            4: [(6, 0.2143), (7, 0.7857)],
            5: [(6, 0.99)],
            6: [(5, 0.99)]
        }
    delta = (b - a).days
    return sum(
        map(lambda x: x[1], filter(lambda x: x[0] < delta, ppt[a.weekday()])))
 def paytime_stats(self, stats):
   for p in filter(PaymentHistoryItem.is_complete, self.payment_history):
     if usfedhol.contains_holiday(p.due, p.complete):
       stats[p.due.weekday()][(p.complete - p.due).days] += 1
示例#4
0
 def paytime_stats(self, stats):
     for p in filter(PaymentHistoryItem.is_complete, self.payment_history):
         if usfedhol.contains_holiday(p.due, p.complete):
             stats[p.due.weekday()][(p.complete - p.due).days] += 1