blob: 9f341b3d330c7ca4ee327032ccbb475656120af3 [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="This module implements the config for gradient boosting."><meta name="keywords" content="rust, rustlang, rust-lang, config"><title>gbdt::config - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../gbdt/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../gbdt/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Module config</a></h2><div class="sidebar-elems"><section><ul class="block"><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#functions">Functions</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Module <a href="../index.html">gbdt</a>::<wbr><a class="mod" href="#">config</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/gbdt/config.rs.html#1-408">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>This module implements the config for gradient boosting.</p>
<p>Following hyperparameters are supported:</p>
<ol>
<li>
<p>feature_size: the size of features. Training data and test data should have
the same feature size. (default = 1)</p>
</li>
<li>
<p>max_depth: the max depth of a single decision tree. The root node is considered
to be in the layer 0. (default = 2)</p>
</li>
<li>
<p>iterations: the iterations for training, which is also the number of trees in the
gradient boosting algorithm. (default = 2)</p>
</li>
<li>
<p>shrinkage: the learning rate parameter of the gradient boosting algorithm.
(default = 1.0)</p>
</li>
<li>
<p>feature_sample_raio: portion of features to be splited. When spliting a node, a subset of
the features (feature_size * feature_sample_ratio) will be randomly selected to calculate
impurity. (default = 1.0)</p>
</li>
<li>
<p>data_sample_ratio: portion of data used to train in a single iteration. Data will
be randomly selected for the training. (default = 1.0)</p>
</li>
<li>
<p>min_leaf_size: the minimum number of samples required to be at a leaf node during training.
(default = 1)</p>
</li>
<li>
<p>loss: the loss function type. SquaredError, LogLikelyhood and LAD are supported for training and inference.
RegLinear, RegLogistic, BinaryLogistic, BinaryLogitraw, MultiSoftprob, MultiSoftmax, RankPairwise are supported for inference with xgboost’s model.
See <a href="enum.Loss.html">Loss</a>. (default = SquareError)</p>
</li>
<li>
<p>debug: whether the debug information should be outputed. (default = false)</p>
</li>
<li>
<p>initial_guess_enabled: whether initial guess for test data is enabled. (default = false)</p>
</li>
</ol>
<h2 id="example"><a href="#example">Example</a></h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>gbdt::config::Config;
<span class="kw">let </span><span class="kw-2">mut </span>cfg = Config::new();
cfg.set_feature_size(<span class="number">4</span>);
cfg.set_max_depth(<span class="number">3</span>);
cfg.set_iterations(<span class="number">3</span>);
cfg.set_loss(<span class="string">&quot;LAD&quot;</span>);
<span class="macro">println!</span>(<span class="string">&quot;{}&quot;</span>, cfg.to_string());
<span class="comment">// output
// number of features = 4
// min leaf size = 1
// maximum depth = 3
// iterations = 3
// shrinkage = 1
// feature sample ratio = 1
// data sample ratio = 1
// debug enabled = false
// loss type = LAD
// initial guess enabled = false</span></code></pre></div>
</div></details><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Config.html" title="gbdt::config::Config struct">Config</a></div><div class="item-right docblock-short">The config for the gradient boosting algorithm.</div></div></div><h2 id="enums" class="small-section-header"><a href="#enums">Enums</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.Loss.html" title="gbdt::config::Loss enum">Loss</a></div><div class="item-right docblock-short">This enum defines the loss type.</div></div></div><h2 id="functions" class="small-section-header"><a href="#functions">Functions</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.loss2string.html" title="gbdt::config::loss2string fn">loss2string</a></div><div class="item-right docblock-short">Converting <a href="enum.Loss.html">Loss</a> to <a href="https://doc.rust-lang.org/std/string/struct.String.html">std::string::String</a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.string2loss.html" title="gbdt::config::string2loss fn">string2loss</a></div><div class="item-right docblock-short">Converting <a href="https://doc.rust-lang.org/std/string/struct.String.html">std::string::String</a> to <a href="enum.Loss.html">Loss</a>.</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="gbdt" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>