I'm trying to run the R Random Forest implementation using Python. I'm using the rpy2 module to get this done easily. Here is a simple example with random generated data:
import numpy as np
from rpy2.robjects.numpy2ri import numpy2ri
from rpy2.robjects.packages import importr
from rpy2 import robjects as ro
#create data
X np.random.rand(30,100)
#create y-values
y = np.random.randint(2, size=30)
X = numpy2ri(X)
y = ro.FactorVector(numpy2ri(y))
#build RF
model = rf.randomForest(X, y)
Now, how can I access, from python, all the fields of my model? How can I get the error rate or the variable importance? In r it's really simple:
model$importance[,"MeanDecreaseGini"]
How can be this done using rpy2? How do you access all the fields of my model object?