Skip to content

TLDR Example Fails #204

@mahiki

Description

@mahiki

I'm new to all the packages referenced here, sorry I can't diagnose.

Environment:

julia version 1.10.4


cat Project.toml
[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Term = "22787eb5-b846-44ae-b979-8e399b8463ab"
XGBoost = "009559a3-9522-5dbb-924b-0b6ed2b22bb9"

pkg> st
Status ...etc
  [a93c6f00] DataFrames v1.6.1
  [22787eb5] Term v2.0.6
  [009559a3] XGBoost v2.5.1

I tried out the TLDR example in the docs:

using DataFrames, XGBoost, Term

# training set of 100 datapoints of 4 features
(X, y) = (randn(100,4), randn(100))

# create and train a gradient boosted tree model of 5 trees
bst = xgboost((X, y), num_round=5, max_depth=6, objective="reg:squarederror")

# obtain model predictions= predict(bst, X)

df = DataFrame(randn(100,3), [:a, :b, :y])

# can accept tabular data, will keep feature names
bst = xgboost((df[!, [:a, :b]], df.y))

# display importance statistics retaining feature names
importancereport(bst)

╭───────────┬────────────┬──────────┬───────────┬──────────────┬───────────────╮
│  feature  │    gain    │  weight  │   cover   │  total_gain  │  total_cover  │
├───────────┼────────────┼──────────┼───────────┼──────────────┼───────────────┤
│    "b"1.1655382.034.707395.57352846.0     │
├───────────┼────────────┼──────────┼───────────┼──────────────┼───────────────┤
│    "a"0.918156108.026.46399.16082858.0     │
╰───────────┴────────────┴──────────┴───────────┴──────────────┴───────────────╯

So far so good

trees(bst)

#... stack trace in next comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions