Variable importance bar plot

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Variable importance bar plot

Enoch Gyamfi Ampadu
Dear List,

I hope this finds you well. Please I have done a Land cover classification
using randomForest. I used selected satellite image bands as input
variables. I have four thematic classes. I obtained the general variable
importance using *varImpPlot (my model) . *Now I want to have bar chart
plot showing each thematic class and the variable importance for each
class. That is, how each band is ranked in predicting a thematic class. I
tried using this function:

*importance = varImp(my model, scale= TRUE)*

*plot (importance. *

However it did not work. I tried to put in *geom= "bar*". And I had error.

Please I will be glad to get some assistance.

Thank you.

Best regards,

Enoch


Enoch Gyamfi - Ampadu

email: [hidden email]
skype: enoch.ampadu

The highest sense of nobility is self control.

A simple act of kindness creates endless ripple

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Variable importance bar plot

Sarah Goslee
It's not entirely clear to me how you expect the values to be
calculated, but you might look at partial dependence plots, for
example as implemented in the pdp package.

Sarah

On Sun, Oct 27, 2019 at 6:00 AM Enoch Gyamfi Ampadu <[hidden email]> wrote:

>
> Dear List,
>
> I hope this finds you well. Please I have done a Land cover classification
> using randomForest. I used selected satellite image bands as input
> variables. I have four thematic classes. I obtained the general variable
> importance using *varImpPlot (my model) . *Now I want to have bar chart
> plot showing each thematic class and the variable importance for each
> class. That is, how each band is ranked in predicting a thematic class. I
> tried using this function:
>
> *importance = varImp(my model, scale= TRUE)*
>
> *plot (importance. *
>
> However it did not work. I tried to put in *geom= "bar*". And I had error.
>
> Please I will be glad to get some assistance.
>
> Thank you.
>
> Best regards,
>
> Enoch
>


--
Sarah Goslee (she/her)
http://www.numberwright.com

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Variable importance bar plot

Bede-Fazekas Ákos
Dear Enoch,

randomForest:varImpPlot() has a parameter called 'class' that is NULL by
default but can be changed to get the class-specific measure of importance.
'geom= "bar"': do you want to plot the result using ggplot2 instead of
the base plot produced by varImpPlot()? In this case you should firstly
assign the invisiby returning result of varImpPlot() (or that of
importance()) to a variable, and then plot it with ggplot().

HTH,
Ákos Bede-Fazekas
Hungarian Academy of Sciences


2019.10.29. 15:51 keltezéssel, Sarah Goslee írta:

> It's not entirely clear to me how you expect the values to be
> calculated, but you might look at partial dependence plots, for
> example as implemented in the pdp package.
>
> Sarah
>
> On Sun, Oct 27, 2019 at 6:00 AM Enoch Gyamfi Ampadu <[hidden email]> wrote:
>> Dear List,
>>
>> I hope this finds you well. Please I have done a Land cover classification
>> using randomForest. I used selected satellite image bands as input
>> variables. I have four thematic classes. I obtained the general variable
>> importance using *varImpPlot (my model) . *Now I want to have bar chart
>> plot showing each thematic class and the variable importance for each
>> class. That is, how each band is ranked in predicting a thematic class. I
>> tried using this function:
>>
>> *importance = varImp(my model, scale= TRUE)*
>>
>> *plot (importance. *
>>
>> However it did not work. I tried to put in *geom= "bar*". And I had error.
>>
>> Please I will be glad to get some assistance.
>>
>> Thank you.
>>
>> Best regards,
>>
>> Enoch
>>
>

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Variable importance bar plot

Enoch Gyamfi Ampadu
In reply to this post by Sarah Goslee
Hi Sarah,

Thank you for getting in touch and providing a suggestion.  I have checked
but that is not what want actually.

 I want to have a vertical bar plot depicting how each variable contrite to
predicting the class. I used 8 bands of landsat image. So let's say if one
of the  land cover class to be Built up, I want to have bar plots in
ranking order of the bands to enable me compare their importance in
predicting the land cover class. I don't know if this explains what I want
better.

Thank you.

Best regards,

Enoch

Enoch Gyamfi - Ampadu

email: [hidden email]
skype: enoch.ampadu

The highest sense of nobility is self control.

A simple act of kindness creates endless ripple


On Tue, 29 Oct 2019, 16:51 Sarah Goslee, <[hidden email]> wrote:

> It's not entirely clear to me how you expect the values to be
> calculated, but you might look at partial dependence plots, for
> example as implemented in the pdp package.
>
> Sarah
>
> On Sun, Oct 27, 2019 at 6:00 AM Enoch Gyamfi Ampadu <[hidden email]>
> wrote:
> >
> > Dear List,
> >
> > I hope this finds you well. Please I have done a Land cover
> classification
> > using randomForest. I used selected satellite image bands as input
> > variables. I have four thematic classes. I obtained the general variable
> > importance using *varImpPlot (my model) . *Now I want to have bar chart
> > plot showing each thematic class and the variable importance for each
> > class. That is, how each band is ranked in predicting a thematic class. I
> > tried using this function:
> >
> > *importance = varImp(my model, scale= TRUE)*
> >
> > *plot (importance. *
> >
> > However it did not work. I tried to put in *geom= "bar*". And I had
> error.
> >
> > Please I will be glad to get some assistance.
> >
> > Thank you.
> >
> > Best regards,
> >
> > Enoch
> >
>
>
> --
> Sarah Goslee (she/her)
> http://www.numberwright.com
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo