2017-05-31 2 views
1

Comment puis-je obtenir une évaluation d'interaction pour gbm calculée avec n.trees fixes? J'ai essayé:gbm.interactions for gbm.fixed

data(Anguilla_train) 
angaus.fixed <- gbm.fixed(data=Anguilla_train, gbm.x = 3:13, 
    gbm.y = 2,family = "bernoulli", tree.complexity = 5, learning.rate = 0.01, 
    bag.fraction = 0.5, n.trees = 5000) 
find.int <- gbm.interactions(angaus.fixed) 

Mais:

1 Erreur dans [.data.frame (pred.frame, n): colonnes non définies sélectionnées

Répondre

1

Après un examen attentif de la fonction dismo::gbm.interactions , J'ai trouvé que dismo::gbm.fixed renvoie un objet qui n'est pas entièrement compatible avec gbm.interactions.
Voici comment votre code pourrait être modifié:

library(dismo) 
data(Anguilla_train) 
angaus.fixed <- gbm.fixed(data=Anguilla_train, gbm.x = 3:13, 
    gbm.y = 2,family = "bernoulli", tree.complexity = 5, learning.rate = 0.01, 
    bag.fraction = 0.5, n.trees = 5000) 

# Change the name of angaus.fixed$gbm.call$data with angaus.fixed$gbm.call$dataframe 
names(angaus.fixed$gbm.call)[1] <- "dataframe" 

find.int <- gbm.interactions(angaus.fixed) 

###### 
gbm.interactions - version 2.9 
Cross tabulating interactions for gbm model with 11 predictors 
1 2 3 4 5 6 7 8 9 10 

Maintenant gbm.interactions fonctionne bien et donne les résultats suivants:

find.int$interactions 

####### 
      SegSumT SegTSeas SegLowFlow DSDist DSMaxSlope USAvgT USRainDays USSlope USNative DSDam Method 
SegSumT   0 28.35  0.88 150.10  13.20 24.38  30.30 17.85 22.57 0.27 44.68 
SegTSeas   0  0.00  17.66 130.69  7.96 16.93  3.14 18.59 25.90 0.14 4.15 
SegLowFlow  0  0.00  0.00 5.92  3.85 6.88  4.69 10.85  5.06 0.09 6.23 
DSDist   0  0.00  0.00 0.00  2.40 10.68  47.77 41.54  6.82 0.01 11.42 
DSMaxSlope  0  0.00  0.00 0.00  0.00 3.22  2.85 3.80  2.64 0.00 1.25 
USAvgT   0  0.00  0.00 0.00  0.00 0.00  3.08 11.76 24.90 0.04 1.94 
USRainDays  0  0.00  0.00 0.00  0.00 0.00  0.00 4.69 15.26 0.09 18.16 
USSlope   0  0.00  0.00 0.00  0.00 0.00  0.00 0.00 12.08 0.03 19.44 
USNative   0  0.00  0.00 0.00  0.00 0.00  0.00 0.00  0.00 0.02 12.79 
DSDam   0  0.00  0.00 0.00  0.00 0.00  0.00 0.00  0.00 0.00 0.13 
Method   0  0.00  0.00 0.00  0.00 0.00  0.00 0.00  0.00 0.00 0.00 


find.int$rank.list 

####### 
    var1.index var1.names var2.index var2.names int.size 
1   4  DSDist   1 SegSumT 150.10 
2   4  DSDist   2 SegTSeas 130.69 
3   7 USRainDays   4  DSDist 47.77 
4   11  Method   1 SegSumT 44.68 
5   8 USSlope   4  DSDist 41.54 
6   7 USRainDays   1 SegSumT 30.30 
+0

Merci beaucoup. Le code fonctionne parfaitement et est très utile. –

+0

@ F.Johann Je suis heureux que ma réponse puisse vous aider! S'il vous plaît, pensez à upvote ma réponse et de fermer la question (https://meta.stackexchange.com/questions/173399/how-to-upvote-on-stack-overflow) –