我正在构建信用违约预测模型。 所有100个测试用例的预测是:NonDefault。 我不确定为什么(错误,错误,......)?
我将训练数据和测试数据放在两个不同的.csv文件中。 两者都具有相同的列数。我的类输出变量(例如LoanStatus)位于文件的最后一列,并被指定为因子。测试数据文件中有LoanStatus的列标题,但所有值都为空。
credit$LoanStatus <- as.factor(credit$LoanStatus)
creditTesting$LoanStatus <- as.factor(creditTesting$LoanStatus)
str(credit)
'data.frame': 8580 obs. of 37 variables:
$ ListingCategory : int 1 7 3 1 1 7 1 1 1 1 ...
$ IncomeRange : int 3 4 6 4 4 3 3 4 3 3 ...
$ StatedMonthlyIncome : num 2583 4326 10500 4167 5667 ...
$ IncomeVerifiable : logi TRUE TRUE TRUE FALSE TRUE TRUE ...
$ DTIwProsperLoan : num 1.8e-01 2.0e-01 1.7e-01 1.0e+06 1.8e-01 4.4e-01 2.2e-01 2.0e-01 2.0e-01 3.1e-01 ...
$ EmploymentStatusDescription: Factor w/ 7 levels "Employed","Full-time",..: 1 4 1 7 1 1 1 1 1 1 ...
$ BorrowerState : Factor w/ 48 levels "AK","AL","AR",..: 22 32 5 5 14 28 4 10 10 34 ...
$ LenderIndicator : int 0 0 0 1 0 0 0 0 1 0 ...
$ GroupIndicator : logi FALSE FALSE FALSE TRUE FALSE FALSE ...
$ ChannelCode : int 90000 90000 90000 80000 40000 40000 90000 90000 80000 90000 ...
$ MonthlyDebt : int 247 785 1631 817 644 1524 427 817 654 749 ...
$ CurrentDelinquencies : int 0 0 0 0 0 0 0 1 0 1 ...
$ DelinquenciesLast7Years : int 0 10 0 0 0 0 0 0 0 0 ...
$ PublicRecordsLast10Years : int 0 1 0 0 0 0 1 0 1 0 ...
$ PublicRecordsLast12Months : int 0 0 0 0 0 0 0 0 0 0 ...
$ CreditLinesLast7Years : int 53 30 36 26 7 22 15 20 34 32 ...
$ InquiriesLast6Months : int 2 8 5 0 0 0 0 3 0 0 ...
$ AmountDelinquent : int 0 0 0 0 0 0 0 63 0 15 ...
$ CurrentCreditLines : int 10 10 18 10 4 11 6 10 7 8 ...
$ OpenCreditLines : int 9 10 15 8 3 8 5 7 7 8 ...
$ BankcardUtilization : num 0.26 0.69 0.94 0.69 0.81 0.38 0.55 0.24 0.03 0 ...
$ TotalOpenRevolvingAccounts : int 9 7 12 10 3 5 4 5 4 6 ...
$ RealEstateBalance : int 0 0 577745 0 0 0 191296 0 0 126039 ...
$ RevolvingBalance : int 5265 9967 94966 50511 37871 22463 19550 2436 1223 3236 ...
$ RealEstatePayment : int 0 0 4159 0 0 0 1303 0 0 1279 ...
$ RevolvingAvailablePercent : int 78 52 36 45 18 61 44 74 96 76 ...
$ TotalInquiries : int 8 11 15 2 0 0 1 7 1 1 ...
$ TotalTradeItems : int 53 30 36 26 7 22 15 20 34 32 ...
$ SatisfactoryAccounts : int 52 23 36 26 7 19 15 18 34 29 ...
$ NowDelinquentDerog : int 0 0 0 0 0 0 0 1 0 1 ...
$ WasDelinquentDerog : int 1 7 0 0 0 3 0 1 0 2 ...
$ OldestTradeOpenDate : int 5092001 5011977 12011984 4272000 9081993 9122000 6161987 11181999 9191990 4132000 ...
$ DelinquenciesOver30Days : int 0 6 0 0 0 13 0 2 0 2 ...
$ DelinquenciesOver60Days : int 0 4 0 0 0 0 0 0 0 1 ...
$ DelinquenciesOver90Days : int 0 10 0 0 0 0 0 0 0 0 ...
$ IsHomeowner : logi FALSE FALSE TRUE FALSE FALSE FALSE ...
$ LoanStatus : Factor w/ 2 levels "Default","NonDefault": 2 1 1 2 2 2 2 2 2 1 ...
str(creditTesting)
'data.frame': 101 obs. of 45 variables:
$ ListingCategory : int 1 2 6 2 1 1 1 1 2 18 ...
$ IncomeRange : int 3 3 4 3 4 3 6 5 3 4 ...
$ StatedMonthlyIncome : num 3333 2500 4271 2667 5000 ...
$ IncomeVerifiable : logi TRUE TRUE TRUE TRUE TRUE TRUE ...
$ DTIwProsperLoan : num 5.9e-01 8.0e-01 3.3e-01 1.0e-01 1.4e-01 2.2e-01 1.4e-01 1.5e-01 1.0e+06 2.2e-01 ...
$ EmploymentStatusDescription: Factor w/ 5 levels "Employed","Full-time",..: 1 2 1 1 1 4 1 1 5 1 ...
$ Occupation : Factor w/ 34 levels "Accountant/CPA",..: 21 30 2 34 22 22 28 25 25 25 ...
$ MonthsEmployed : int 113 176 112 86 19 0 295 100 12 19 ...
$ BorrowerState : Factor w/ 32 levels "AL","CA","CO",..: 7 4 13 7 4 7 20 20 20 29 ...
$ BorrowerCity : Factor w/ 91 levels "ARLINGTON","ATLANTA",..: 7 32 46 15 62 14 58 61 16 18 ...
$ BorrowerMetropolitanArea : Factor w/ 1 level "(Not Implemented)": 1 1 1 1 1 1 1 1 1 1 ...
$ LenderIndicator : int 0 0 0 0 0 0 0 0 0 0 ...
$ GroupIndicator : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
$ GroupName : Factor w/ 3 levels "","1st and BEST for Loans",..: 1 1 1 1 1 1 1 1 1 1 ...
$ ChannelCode : int 70000 80000 80000 80000 40000 70000 90000 40000 90000 40000 ...
$ AmountParticipation : int 0 0 0 0 0 0 0 0 0 0 ...
$ MonthlyDebt : int 1450 1622 1329 132 555 353 513 1014 3279 835 ...
$ CurrentDelinquencies : int 0 0 0 0 0 0 0 0 0 0 ...
$ DelinquenciesLast7Years : int 0 0 0 9 21 0 0 0 0 0 ...
$ PublicRecordsLast10Years : int 0 0 1 0 0 0 0 0 0 0 ...
$ PublicRecordsLast12Months : int 0 0 0 0 0 0 0 0 0 0 ...
$ FirstRecordedCreditLine : Factor w/ 99 levels "1/12/91 0:00",..: 73 65 67 21 44 6 29 97 20 41 ...
$ CreditLinesLast7Years : int 44 39 16 14 24 24 39 26 34 21 ...
$ InquiriesLast6Months : int 1 0 0 2 3 0 0 1 0 0 ...
$ AmountDelinquent : int 0 0 0 0 0 0 0 0 0 0 ...
$ CurrentCreditLines : int 26 15 8 8 7 9 14 16 17 11 ...
$ OpenCreditLines : int 25 14 8 7 6 6 10 16 16 10 ...
$ BankcardUtilization : num 0.51 0.82 0.96 0.24 0.08 0.62 0.63 0.95 0.92 0.17 ...
$ TotalOpenRevolvingAccounts : int 26 13 6 6 7 7 10 15 16 8 ...
$ InstallmentBalance : int 22471 7373 11312 0 23022 0 0 9096 4322 12224 ...
$ RealEstateBalance : int 101872 0 0 187094 0 0 467861 149718 0 169056 ...
$ RevolvingBalance : int 41511 44578 19246 2301 1357 10462 38677 33587 114211 12305 ...
$ RealEstatePayment : int 743 0 0 1000 0 0 3990 1064 0 1438 ...
$ RevolvingAvailablePercent : int 55 18 25 79 92 52 40 11 19 78 ...
$ TotalInquiries : int 2 6 2 6 7 2 4 4 0 7 ...
$ TotalTradeItems : int 44 39 16 14 24 24 39 26 34 21 ...
$ SatisfactoryAccounts : int 44 38 15 13 22 20 39 26 34 20 ...
$ NowDelinquentDerog : int 0 0 0 0 0 0 0 0 0 0 ...
$ WasDelinquentDerog : int 0 1 1 1 2 4 0 0 0 1 ...
$ OldestTradeOpenDate : int 7011999 6101990 6171985 11162005 3012000 1081990 11061996 9261994 11011977 2252002 ...
$ DelinquenciesOver30Days : int 0 1 0 3 1 13 0 0 0 2 ...
$ DelinquenciesOver60Days : int 0 0 0 2 1 2 0 0 0 1 ...
$ DelinquenciesOver90Days : int 0 0 0 9 21 0 0 0 0 0 ...
$ IsHomeowner : logi TRUE FALSE FALSE TRUE FALSE FALSE ...
$ LoanStatus : Factor w/ 0 levels: NA NA NA NA NA NA NA NA NA NA ...
summary(credit)
ListingCategory IncomeRange StatedMonthlyIncome IncomeVerifiable
Min. : 0.000 Min. :1.000 Min. : 0 Mode :logical
1st Qu.: 1.000 1st Qu.:3.000 1st Qu.: 3167 FALSE:784
Median : 2.000 Median :4.000 Median : 4750 TRUE :7796
Mean : 4.997 Mean :4.089 Mean : 5755 NA's :0
3rd Qu.: 7.000 3rd Qu.:5.000 3rd Qu.: 7083
Max. :20.000 Max. :7.000 Max. :250000
DTIwProsperLoan EmploymentStatusDescription BorrowerState
Min. : 0.0 Employed :7182 CA :1056
1st Qu.: 0.1 Full-time : 416 FL : 608
Median : 0.2 Not employed : 122 NY : 574
Mean : 91609.4 Other : 475 TX : 532
3rd Qu.: 0.3 Part-time : 7 IL : 443
Max. :1000000.0 Retired : 32 GA : 343
Self-employed: 346 (Other):5024
LenderIndicator GroupIndicator ChannelCode MonthlyDebt
Min. :0.00000 Mode :logical Min. :40000 Min. : 0.0
1st Qu.:0.00000 FALSE:8325 1st Qu.:80000 1st Qu.: 364.0
Median :0.00000 TRUE :255 Median :80000 Median : 708.0
Mean :0.09196 NA's :0 Mean :77196 Mean : 885.5
3rd Qu.:0.00000 3rd Qu.:90000 3rd Qu.: 1205.2
Max. :1.00000 Max. :90000 Max. :30213.0
CurrentDelinquencies DelinquenciesLast7Years PublicRecordsLast10Years
Min. : 0.0000 Min. : 0.000 Min. : 0.0000
1st Qu.: 0.0000 1st Qu.: 0.000 1st Qu.: 0.0000
Median : 0.0000 Median : 0.000 Median : 0.0000
Mean : 0.4119 Mean : 4.009 Mean : 0.2809
3rd Qu.: 0.0000 3rd Qu.: 3.000 3rd Qu.: 0.0000
Max. :21.0000 Max. :99.000 Max. :11.0000
PublicRecordsLast12Months CreditLinesLast7Years InquiriesLast6Months
Min. :0.00000 Min. : 2.0 Min. : 0.0000
1st Qu.:0.00000 1st Qu.: 16.0 1st Qu.: 0.0000
Median :0.00000 Median : 24.0 Median : 1.0000
Mean :0.01364 Mean : 26.1 Mean : 0.9994
3rd Qu.:0.00000 3rd Qu.: 34.0 3rd Qu.: 1.0000
Max. :4.00000 Max. :115.0 Max. :15.0000
AmountDelinquent CurrentCreditLines OpenCreditLines BankcardUtilization
Min. : 0 Min. : 0.000 Min. : 0.000 Min. :0.0000
1st Qu.: 0 1st Qu.: 5.000 1st Qu.: 5.000 1st Qu.:0.2500
Median : 0 Median : 9.000 Median : 8.000 Median :0.5400
Mean : 1195 Mean : 9.345 Mean : 8.306 Mean :0.5182
3rd Qu.: 0 3rd Qu.:12.000 3rd Qu.:11.000 3rd Qu.:0.7900
Max. :179158 Max. :54.000 Max. :42.000 Max. :2.2300
TotalOpenRevolvingAccounts RealEstateBalance RevolvingBalance
Min. : 0.000 Min. : 0 Min. : 0
1st Qu.: 3.000 1st Qu.: 0 1st Qu.: 2799
Median : 6.000 Median : 26154 Median : 8784
Mean : 6.441 Mean : 109306 Mean : 19555
3rd Qu.: 9.000 3rd Qu.: 176542 3rd Qu.: 21110
Max. :44.000 Max. :1938421 Max. :695648
RealEstatePayment RevolvingAvailablePercent TotalInquiries TotalTradeItems
Min. : 0.0 Min. : 0.00 Min. : 0.00 Min. : 2.0
1st Qu.: 0.0 1st Qu.: 29.00 1st Qu.: 2.00 1st Qu.: 16.0
Median : 346.5 Median : 52.00 Median : 3.00 Median : 24.0
Mean : 830.5 Mean : 51.46 Mean : 3.91 Mean : 26.1
3rd Qu.: 1382.2 3rd Qu.: 75.00 3rd Qu.: 5.00 3rd Qu.: 34.0
Max. :13651.0 Max. :100.00 Max. :36.00 Max. :115.0
SatisfactoryAccounts NowDelinquentDerog WasDelinquentDerog OldestTradeOpenDate
Min. : 1.00 Min. : 0.0000 Min. : 0.000 Min. : 1011957
1st Qu.: 14.00 1st Qu.: 0.0000 1st Qu.: 0.000 1st Qu.: 4101996
Median : 21.00 Median : 0.0000 Median : 1.000 Median : 7191993
Mean : 23.34 Mean : 0.4119 Mean : 2.343 Mean : 6934230
3rd Qu.: 30.25 3rd Qu.: 0.0000 3rd Qu.: 3.000 3rd Qu.:10011990
Max. :113.00 Max. :21.0000 Max. :32.000 Max. :12312004
DelinquenciesOver30Days DelinquenciesOver60Days DelinquenciesOver90Days
Min. : 0.000 Min. : 0.000 Min. : 0.000
1st Qu.: 0.000 1st Qu.: 0.000 1st Qu.: 0.000
Median : 1.000 Median : 0.000 Median : 0.000
Mean : 4.332 Mean : 1.908 Mean : 4.009
3rd Qu.: 5.000 3rd Qu.: 2.000 3rd Qu.: 3.000
Max. :99.000 Max. :73.000 Max. :99.000
IsHomeowner LoanStatus
Mode :logical Default :1518
FALSE:4264 NonDefault:7062
TRUE :4316
NA's :0
In [113]:
summary(creditTesting)
Out[113]:
ListingCategory IncomeRange StatedMonthlyIncome IncomeVerifiable
Min. : 1.000 Min. :2.000 Min. : 0 Mode :logical
1st Qu.: 1.000 1st Qu.:3.000 1st Qu.: 3583 FALSE:5
Median : 1.000 Median :4.000 Median : 5000 TRUE :96
Mean : 4.277 Mean :4.119 Mean : 5696 NA's :0
3rd Qu.: 3.000 3rd Qu.:5.000 3rd Qu.: 6833
Max. :20.000 Max. :7.000 Max. :37500
DTIwProsperLoan EmploymentStatusDescription Occupation
Min. : 0.0 Employed :86 Other :22
1st Qu.: 0.1 Full-time : 4 Professional :13
Median : 0.2 Not employed : 1 Sales - Commission : 6
Mean : 49510.2 Other : 7 Computer Programmer : 5
3rd Qu.: 0.3 Self-employed: 3 Accountant/CPA : 4
Max. :1000000.0 Administrative Assistant: 4
(Other) :47
MonthsEmployed BorrowerState BorrowerCity BorrowerMetropolitanArea
Min. : -1.00 CA :13 BROOKLYN : 3 (Not Implemented):101
1st Qu.: 26.00 NJ : 8 LOUISVILLE: 3
Median : 71.00 IL : 7 ATLANTA : 2
Mean : 98.47 TX : 7 CHICAGO : 2
3rd Qu.:152.00 FL : 6 LAKEWOOD : 2
Max. :424.00 NY : 6 RACINE : 2
(Other):54 (Other) :87
LenderIndicator GroupIndicator GroupName
Min. :0.00000 Mode :logical :98
1st Qu.:0.00000 FALSE:97 1st and BEST for Loans : 1
Median :0.00000 TRUE :4 BORROWERS - LARGEST GROUP: 2
Mean :0.05941 NA's :0
3rd Qu.:0.00000
Max. :1.00000
ChannelCode AmountParticipation MonthlyDebt CurrentDelinquencies
Min. :40000 Min. :0 Min. : 25.0 Min. :0.0000
1st Qu.:70000 1st Qu.:0 1st Qu.: 474.0 1st Qu.:0.0000
Median :80000 Median :0 Median : 814.0 Median :0.0000
Mean :74059 Mean :0 Mean : 888.9 Mean :0.3168
3rd Qu.:90000 3rd Qu.:0 3rd Qu.:1189.0 3rd Qu.:0.0000
Max. :90000 Max. :0 Max. :5928.0 Max. :8.0000
DelinquenciesLast7Years PublicRecordsLast10Years PublicRecordsLast12Months
Min. : 0.000 Min. :0.0000 Min. :0
1st Qu.: 0.000 1st Qu.:0.0000 1st Qu.:0
Median : 0.000 Median :0.0000 Median :0
Mean : 4.139 Mean :0.3168 Mean :0
3rd Qu.: 3.000 3rd Qu.:0.0000 3rd Qu.:0
Max. :51.000 Max. :7.0000 Max. :0
FirstRecordedCreditLine CreditLinesLast7Years InquiriesLast6Months
4/1/95 0:00 : 2 Min. : 4.00 Min. :0.0000
9/26/94 0:00: 2 1st Qu.:17.00 1st Qu.:0.0000
1/12/91 0:00: 1 Median :26.00 Median :1.0000
1/13/89 0:00: 1 Mean :27.08 Mean :0.9604
1/20/98 0:00: 1 3rd Qu.:37.00 3rd Qu.:2.0000
1/26/01 0:00: 1 Max. :67.00 Max. :5.0000
(Other) :93
AmountDelinquent CurrentCreditLines OpenCreditLines BankcardUtilization
Min. : 0 Min. : 1.000 Min. : 1.000 Min. :0.0000
1st Qu.: 0 1st Qu.: 6.000 1st Qu.: 5.000 1st Qu.:0.3400
Median : 0 Median : 9.000 Median : 8.000 Median :0.6000
Mean : 1153 Mean : 9.782 Mean : 8.802 Mean :0.5679
3rd Qu.: 0 3rd Qu.:14.000 3rd Qu.:12.000 3rd Qu.:0.8000
Max. :56288 Max. :26.000 Max. :25.000 Max. :1.0000
TotalOpenRevolvingAccounts InstallmentBalance RealEstateBalance
Min. : 0.000 Min. : 0 Min. : 0
1st Qu.: 4.000 1st Qu.: 2657 1st Qu.: 0
Median : 6.000 Median : 13109 Median : 0
Mean : 7.109 Mean : 26038 Mean : 101924
3rd Qu.:10.000 3rd Qu.: 32549 3rd Qu.: 149718
Max. :26.000 Max. :220085 Max. :1571558
NA's :3
RevolvingBalance RealEstatePayment RevolvingAvailablePercent TotalInquiries
Min. : 0 Min. : 0.0 Min. : 0.00 Min. : 0.000
1st Qu.: 4422 1st Qu.: 0.0 1st Qu.: 32.00 1st Qu.: 2.000
Median : 8886 Median : 0.0 Median : 50.00 Median : 4.000
Mean : 24627 Mean : 757.8 Mean : 49.18 Mean : 3.772
3rd Qu.: 21189 3rd Qu.:1217.0 3rd Qu.: 68.00 3rd Qu.: 5.000
Max. :795296 Max. :7830.0 Max. :100.00 Max. :13.000
TotalTradeItems SatisfactoryAccounts NowDelinquentDerog WasDelinquentDerog
Min. : 4.00 Min. : 2.00 Min. :0.0000 Min. : 0.000
1st Qu.:17.00 1st Qu.:15.00 1st Qu.:0.0000 1st Qu.: 0.000
Median :26.00 Median :22.00 Median :0.0000 Median : 1.000
Mean :27.08 Mean :24.35 Mean :0.3168 Mean : 2.416
3rd Qu.:37.00 3rd Qu.:34.00 3rd Qu.:0.0000 3rd Qu.: 4.000
Max. :67.00 Max. :67.00 Max. :8.0000 Max. :17.000
OldestTradeOpenDate DelinquenciesOver30Days DelinquenciesOver60Days
Min. : 1081990 Min. : 0.000 Min. : 0.000
1st Qu.: 4131991 1st Qu.: 0.000 1st Qu.: 0.000
Median : 8032006 Median : 1.000 Median : 0.000
Mean : 7123082 Mean : 4.614 Mean : 2.089
3rd Qu.:10012009 3rd Qu.: 6.000 3rd Qu.: 2.000
Max. :12301997 Max. :41.000 Max. :20.000
DelinquenciesOver90Days IsHomeowner LoanStatus
Min. : 0.000 Mode :logical NA's:101
1st Qu.: 0.000 FALSE:59
Median : 0.000 TRUE :42
Mean : 4.139 NA's :0
3rd Qu.: 3.000
Max. :51.000
ctrl <- trainControl(method = "repeatedcv", repeats = 3, classProbs = TRUE, summaryFunction = twoClassSummary)
multinomFit <- train(LoanStatus~., credit, method = "multinom", family=binomial, metric = "ROC",
preProcess=c("center", "scale", "pca"),
trControl = ctrl)
Penalized Multinomial Regression
8580 samples
36 predictor
2 classes: 'Default', 'NonDefault'
Pre-processing: centered, scaled, principal component signal extraction
Resampling: Cross-Validated (10 fold, repeated 3 times)
Summary of sample sizes: 7721, 7722, 7722, 7722, 7722, 7723, ...
Resampling results across tuning parameters:
decay ROC Sens Spec ROC SD Sens SD Spec SD
0e+00 0.6475924 0.01909783 0.9945719 0.02439430 0.01070060 0.002929591
1e-04 0.6475921 0.01909783 0.9945719 0.02439472 0.01070060 0.002929591
1e-01 0.6475930 0.01887853 0.9945719 0.02440801 0.01061464 0.002929591
ROC was used to select the optimal model using the largest value.
The final value used for the model was decay = 0.1.
呼叫: multinom(公式= .outcome~。,data = dat,decay = param $ decay, family = ..1)
Coefficients:
Values Std. Err.
(Intercept) 1.661559e+00 0.03135811
PC1 -8.412986e-02 0.01222495
PC2 4.553628e-02 0.01278523
PC3 1.219468e-01 0.01555913
PC4 6.770858e-02 0.01996412
PC5 -3.103824e-02 0.01907472
PC6 3.550245e-02 0.02133001
PC7 1.443212e-01 0.02396368
PC8 2.074222e-01 0.02760976
PC9 -1.651602e-01 0.02448699
PC10 -1.339219e-01 0.02481627
PC11 -8.404567e-02 0.02479423
PC12 9.089093e-02 0.02924268
PC13 -4.247345e-02 0.02753968
PC14 2.509833e-02 0.02665515
PC15 4.533390e-02 0.02832468
PC16 -3.765632e-02 0.02759775
PC17 1.906671e-02 0.02859806
PC18 -2.857844e-02 0.02777393
PC19 -2.601204e-02 0.02821992
PC20 4.960850e-02 0.02824554
PC21 7.618470e-02 0.02794719
PC22 1.577422e-02 0.02808431
PC23 -2.763435e-02 0.02796787
PC24 -2.454515e-03 0.02902528
PC25 8.217990e-03 0.02808979
PC26 3.184139e-02 0.02901644
PC27 3.955461e-02 0.02916539
PC28 1.260333e-01 0.02984005
PC29 -3.960489e-02 0.02949268
PC30 -8.586754e-02 0.02889836
PC31 -2.481118e-02 0.02795710
PC32 -4.558708e-03 0.02976663
PC33 1.298065e-02 0.02745320
PC34 2.451963e-02 0.02824458
PC35 1.248370e-02 0.02895790
PC36 -1.463200e-02 0.02854997
PC37 -1.196070e-02 0.02897936
PC38 5.596941e-02 0.02902472
PC39 -5.391409e-02 0.02956513
PC40 2.108806e-02 0.02779666
PC41 -9.459884e-03 0.02849543
PC42 -6.300733e-02 0.02830865
PC43 2.135377e-02 0.02996247
PC44 6.512672e-03 0.03040486
PC45 -4.486076e-02 0.02837301
PC46 -2.150908e-02 0.03071156
PC47 2.169651e-03 0.02968346
PC48 5.521734e-02 0.03204429
PC49 3.248101e-02 0.03005834
PC50 2.464231e-02 0.03058966
PC51 3.244047e-02 0.02980442
PC52 9.181668e-05 0.02957302
PC53 -5.255398e-02 0.02916945
PC54 2.471085e-02 0.02861254
PC55 1.299871e-01 0.02982951
PC56 4.561386e-03 0.02848702
PC57 -1.546641e-02 0.02797762
PC58 1.001523e-01 0.03000506
PC59 5.561718e-02 0.03021967
PC60 -4.221097e-02 0.03084724
PC61 -3.205970e-02 0.02969792
PC62 -7.822227e-02 0.03237215
PC63 -6.974787e-02 0.03219820
PC64 -8.391386e-02 0.03218637
PC65 -5.468543e-02 0.03329968
PC66 1.149728e-01 0.03465573
PC67 7.122453e-02 0.03717676
PC68 -7.438698e-02 0.03355053
Residual Deviance: 7540.3
AIC: 7678.3
multinomClasses <- predict(multinomFit, newdata = creditTesting)
multinomClasses
NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault Default NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault NonDefault
multinomProbs <- predict(multinomFit, newdata = creditTesting, type = "prob")
multinomProbs
Default NonDefault
1 0.1696353 0.8303647
2 0.1294708 0.8705292
3 0.2195003 0.7804997
4 0.2239879 0.7760121
5 0.1320599 0.8679401
6 0.2361062 0.7638938
7 0.08251747 0.9174825
8 0.1157858 0.8842142
9 0.2883426 0.7116574
10 0.1005039 0.8994961
11 0.09416405 0.905836
12 0.2575161 0.7424839
13 0.5283096 0.4716904
14 0.006361443 0.9936386
15 0.1884999 0.8115001
16 0.1195356 0.8804644
17 0.1997128 0.8002872
18 0.2019061 0.7980939
19 0.2959732 0.7040268
20 0.1662932 0.8337068
21 0.06248543 0.9375146
22 0.08954305 0.9104569
23 0.1669996 0.8330004
24 0.1366132 0.8633868
25 0.09438881 0.9056112
26 0.07180876 0.9281912
27 0.1387811 0.8612189
28 0.3140691 0.6859309
29 0.2012253 0.7987747
30 0.3330198 0.6669802
31 0.1883894 0.8116106
32 0.1444536 0.8555464
33 0.08972971 0.9102703
34 0.09828264 0.9017174
35 0.1547096 0.8452904
36 0.06803248 0.9319675
37 0.09852268 0.9014773
38 0.07810421 0.9218958
39 0.1635697 0.8364303
40 0.2745873 0.7254127
41 0.2124576 0.7875424
42 0.1263433 0.8736567
43 0.1460307 0.8539693
44 0.212215 0.787785
45 0.156162 0.843838
46 0.261491 0.738509
47 0.1256826 0.8743174
48 0.2127443 0.7872557
49 0.1219385 0.8780615
50 0.1885034 0.8114966
51 0.1520502 0.8479498
52 0.2068344 0.7931656
53 0.1229164 0.8770836
54 0.1614266 0.8385734
55 0.1464662 0.8535338
56 0.1398765 0.8601235
57 0.3510801 0.6489199
58 0.1208267 0.8791733
59 0.08798058 0.9120194
60 0.2338337 0.7661663
... 100 0.08459862 0.9154014 101 0.2787546 0.7212454 在[119]:
levels(multinomClasses)
Out[119]:
'Default' 'NonDefault'