代码之家  ›  专栏  ›  技术社区  ›  Bad Coder

如何在Pyte中使用SMOTE?

  •  0
  • Bad Coder  · 技术社区  · 2 年前

    我目前正在通过这个链接进行生存分析 https://square.github.io/pysurvival/tutorials/credit_risk.html .我试着做一些建模,问题出现了。如果我们有不平衡的分类,我们想用SMOTE来平衡数据集,那么我们该怎么做呢?

    # Building training and testing sets
    
    from sklearn.model_selection import train_test_split
    index_train, index_test = train_test_split( range(N), test_size = 0.4)
    data_train = dataset.loc[index_train].reset_index( drop = True )
    data_test  = dataset.loc[index_test].reset_index( drop = True )
    
    # Creating the X, T and E inputs
    X_train, X_test = data_train[features], data_test[features]
    T_train, T_test = data_train[time_column], data_test[time_column]
    E_train, E_test = data_train[event_column], data_test[event_column]
    

    完整的说明可以在这里找到 https://square.github.io/pysurvival/tutorials/credit_risk.html .我不能像其他分类那样执行SMOTE,因为有两个输出列(即事件和时间)。在其他分类中,只有一种输出。

    有人能帮我解决这个问题吗?

    0 回复  |  直到 2 年前
    推荐文章