You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

呼叫日志FTR7%计算异常:L2列值差异导致数值波动排查

关于呼叫日志FTR计算结果异常的问题

我用Python的pandas和numpy库基于呼叫日志数据集计算首次解决率(First Time Resolution,FTR)百分比。处理calls_logs_cleaned_2025-05-02.csv时,FTR7%约为63.8%;但处理另一个仅填充了L2列有效值(原文件L2列全为空)的CSV文件时,FTR7%骤降至约39.8%。

我的FTR计算逻辑完全没用到l1_intent和l2_intent列,所以对结果差异感到困惑。CSV文件包含列:customer_account_no、agent_id、agent_name、start_time、l1_intent、l2_intent。

计算代码

import pandas as pd
import numpy as np

# Loading data
df = pd.read_csv('calls_logs_cleaned_2025-05-02.csv')

# Converting start_time to datetime
df['start_time'] = pd.to_datetime(df['start_time'], format='mixed', dayfirst=True)

# Sorting data by customer and time
df = df.sort_values(by=['customer_account_no', 'start_time']).reset_index(drop=True)

# Function to calculate FTR7 and FTR14
def calculate_ftr(group):
    times = group['start_time'].values.astype('datetime64[ns]')
    n = len(times)
    ftr7, ftr14 = np.ones(n, dtype=int), np.ones(n, dtype=int)
    
    for i in range(1, n):
        current_time = times[i]
        
        # Check if there is a previous call within 7 days
        left_bound_7 = current_time - np.timedelta64(7, 'D')
        idx_7 = np.searchsorted(times[:i], left_bound_7, side='right')
        ftr7[i] = 0 if idx_7 < i else 1
        
        # Check if there is a previous call within 14 days
        left_bound_14 = current_time - np.timedelta64(14, 'D')
        idx_14 = np.searchsorted(times[:i], left_bound_14, side='right')
        ftr14[i] = 0 if idx_14 < i else 1
    
    return pd.DataFrame({'FTR7': ftr7, 'FTR14': ftr14}, index=group.index)

# Applying function per customer group
df[['FTR7', 'FTR14']] = df.groupby('customer_account_no', group_keys=False).apply(calculate_ftr)

# Calculate overall percentages
ftr7_percent = df['FTR7'].mean() * 100
ftr14_percent = df['FTR14'].mean() * 100

print(f"FTR7%: {ftr7_percent:.1f}%")
print(f"FTR14%: {ftr14_percent:.1f}%")

问题

  1. 为何填充了有效L2值的文件会让FTR7%从63.8%降到39.8%?
  2. 代码里没显式用到的L2列值会不会影响计算结果?
  3. 需要检查或调试哪些内容才能弄明白这个差异?

样本数据

idcustomer_account_noagent_idstart_timel1_vall2_valcall_time
bq1001794238811002-01-2025l1_cat1l2_cat1120
bq1003884456456602-01-2025l1_cat1l2_cat2143
bq1005993458811002-01-2025l1_cat1l2_cat3234
bq1009667543423302-01-2025l1_cat1l2_cat2112
bq1011494239234303-01-2025l1_cat1l2_cat399
bq1012484456456603-01-2025l1_cat1l2_cat2187
bq1013794239234304-01-2025l1_cat1l2_cat155
bq1014993456456605-01-2025l1_cat1l2_cat3342
bq1015794233423307-01-2025l1_cat1l2_cat287
bq1016993453423307-01-2025l1_cat1l2_cat4132

内容的提问来源于stack exchange,提问作者IAIMT2024

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 04:52:14