【问题标题】:Calculate how early the correct prediction was made计算做出正确预测的时间有多早
【发布时间】:2019-02-18 02:20:44
【问题描述】:

我有一个数据集,其中每一行都是客户生命周期的一个时间点。我使用目标变量对数据进行逻辑回归,以确定客户是否“流失”。我捕获预测并添加到数据框中。以下是带有预测的示例数据集:

我现在想计算每个客户在他/她的生命周期中的早期预测是正确的吗?然后聚合整个客户集,为分类模型构建自定义指标。

【问题讨论】:

    标签: python pandas classification


    【解决方案1】:

    嗯,这就是我计算指标的方式。如果有人知道更好的解决方案,请告诉我:

    total_count = 0
    true_pred = 0
    tenure= validation_data['tenure'].unique()
    for i in range(len(tenure)):
        running_tenure = i+1
        for index, row in validation_data.iterrows():    
            if row['tenure'] == running_tenure :
                total_count += 1
                if row['churn'] == row['pred_churn']:
                    true_pred += 1
        Accuracy = float(float(true_pred)/total_count)))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-18
      • 2017-03-05
      • 2012-03-13
      • 2021-12-10
      • 2021-11-18
      • 1970-01-01
      • 1970-01-01
      • 2017-01-25
      相关资源
      最近更新 更多