1. 评估函数
  • Classification metrics

    1
    2
    3
    4
    5
    6
    from sklearn import metrics

    metrics.roc_auc_score(y_true,y_pre)

    # F1 = 2 * (precision * recall) / (precision + recall)
    metrics.f1_score(y_true,y_pre)
  • Regression metrics

    1
    2
    metrics.mean_absolute_error(y_true,y_pre)
    metrics.mean_squared_error(y_true,y_pre)
  1. 标准化和归一化
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    from sklearn.preprocessing import StandardScaler
    from sklearn.preprocessing import MinMaxScaler

    # 标准化
    ss = StandardScaler()
    std_data = ss.fit_transform(data)
    origin_data = ss.inverse_transform(std_data) # 还原

    # 归一化
    mm = MinMaxScaler()
    mm_data = mm.fit_transform(data)
    origin_data = mm.inverse_transform(mm_data)