2

我正在使用 nnet 包中的 multinom 来将逻辑回归模型拟合到由 3 个类组成的数据,但是这些类的普遍性并不平衡。我想分配权重/惩罚,以告诉模型避免对某个类别进行错误分类。这是我的代码和一部分数据:

 mnm <- multinom(formula = cut.rank ~ ., data = training.logist, trace = FALSE, maxit = 1000, weights=c(10,5,1))

> str(head(training.logist))
'data.frame':   6 obs. of  15 variables:
 $ is_top_rated_listing                       : Factor w/ 2 levels "0","1": 1 1 1 2 2 2
 $ seller_is_top_rated_seller                 : int  1 1 1 1 1 1
 $ is_auto_pay                                : Factor w/ 2 levels "0","1": 2 2 2 2 2 2
 $ is_returns_accepted                        : Factor w/ 2 levels "0","1": 2 2 2 2 2 2
 $ seller_feedback_rating_star                : Factor w/ 11 levels "Blue","Green",..: 7 7 7 9 9 9
 $ keywords_title_assoc                       : num  1 1 1 1 1 1
 $ normalized.price_shipping                  : num  0 0 0.00871 0.01853 0.01853 ...
 $ normalized.seller_feedback_score           : num  0.7117 0.8791 0.0966 0.095 0.095 ...
 $ normalized.seller_positive_feedback_percent: num  0.7117 0.8791 0.0966 0.095 0.095 ...
 $ item_condition                             : Factor w/ 2 levels "New","New other (see details)": 1 1 1 1 1 1
 $ listing_type                               : Factor w/ 2 levels "FixedPrice","StoreInventory": 2 2 2 1 1 1
 $ best_offer_enabled                         : Factor w/ 2 levels "0","1": 1 1 1 1 1 1
 $ shipping_handling_time                     : int  10 10 10 1 1 1
 $ shipping_locations                         : Factor w/ 7 levels "AU,Americas,Europe,Asia",..: 5 5 5 5 5 5
 $ cut.rank                                   : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 1
> 

任何人都知道如何分配错误分类处罚?具体来说,我想分配一个 10:5:1 的惩罚比(对应于 1,2,3 类),这意味着我真的很喜欢在 1 类上准确。我的目标变量 cut.rank 的分布是 ~ 0.04,0.08, 0.88。由于第 1 类的流行率较低,因此该类的模型敏感性较低。

4

0 回答 0