Giter Site home page Giter Site logo

notebooks's People

Contributors

lorentzenchr avatar mayer79 avatar rth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

notebooks's Issues

Random forest feature subsampling error in charts

Thank your for your interesting review. The code in seaborn seems buggy (some dataset's names are missing) and the visualisation seems poor to me. I'd prefer using ggplot in R like this:

df <- arrow::read_parquet('./data/random_forests_max_features.parquet')
library(tidyverse)
# fill na with zero
df[is.na(df)] <- 0
df %>%
    mutate(max_features = factor(max_features, levels = c("p/3", "sqrt(p)", "0.9p", "p"))) %>%
    ggplot( aes(x=max_features, y=mse, fill=max_features)) + 
    geom_bar(stat = "identity")+
    geom_errorbar(aes(ymin=mse-mse_std, ymax=mse+mse_std), width=.2) +
    scale_fill_brewer(palette = "Set1")+
    facet_wrap(facets = vars(dataset), scales = 'free_y')+
    theme(legend.position="none")

df %>%
    mutate(max_features = factor(max_features, levels = c("p/3", "sqrt(p)", "0.9p", "p"))) %>%
    ggplot( aes(x=max_features, y=fit_time, fill=max_features)) + 
    geom_bar(stat = "identity")+
    scale_fill_brewer(palette = "Set1")+
    facet_wrap(facets = vars(dataset), scales = 'free_y')+
    theme(legend.position="none")

I usually use python and I'm not very confident in R but I love ggplot (unfortunately altair doesn't catch up yet even though it's better than seaborn - I hate that "ci" in seaborn does not accept a field as value - but I find it sometimes tricky). Give it a try:

import altair as alt
d = {}
for i,data in enumerate(df.dataset.unique()):
    tmpdf = df[df['dataset']==data]
    
    # the base chart
    base = alt.Chart(tmpdf).transform_calculate(
    ymin="datum.mse-datum.mse_std",
    ymax="datum.mse+datum.mse_std"
    )
    
    # Add BarChart
    barchart = base.mark_bar().encode(
    x=alt.X(field='max_features', type='nominal',
           sort=["p/3", "sqrt(p)", "0.9p", "p"], title=data),
    y=alt.Y('mse:Q', title='mse'),
    color=alt.Color('max_features:N',legend=None, scale=alt.Scale(scheme='set1'))    
    ).properties(width=200)
    
    # Add errorbars
    errorbars = base.mark_errorbar().encode(
    x=alt.X(field='max_features', type='nominal',
           sort=["p/3", "sqrt(p)", "0.9p", "p"]),
    y=alt.Y("ymin:Q", title="mse"),
    y2="ymax:Q"
    )
        
    # Assign value
    d[f"bars_{i}"]  = barchart + errorbars

# Concat and display  on 3 columns
alt.concat(
    *d.values(),
columns=3
)

There are some weird values like in Brazilian_houses where the std is huge and a couple of missing values (colleges is NA for p).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.