notebooks's People
Forkers
mayer79 kissmyjazz minghao2016 arbstat qmnxxy justin-thon mcomsa taecjee rnaimehaom axc836 rspanhol praisendebelenotebooks's Issues
Fix colsample_bynode
In the new blog post with code
- https://github.com/lorentzenchr/notebooks/blob/master/blogposts/2021-11-13%20random%20forests%20monotone.ipynb
- https://github.com/lorentzenchr/notebooks/blob/master/blogposts/2021-11-13%20random%20forests%20monotone.r
the formula for colsample_bynode
might need correction.
Python int(np.sqrt(m)) / m
-> np.sqrt(m) // m
R floor(sqrt(m)) / m
-> floor(sqrt(m) / m)
@mayer79 ping
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.