Commit e773dfcc authored by qianyj's avatar qianyj
Browse files

create branch for v2.9

parents
function add_descriptive_text(texts) {
const d = $('*[data-md-source="nni"]');
// clear first
d.find("ul").remove();
let s = "";
for (const text of texts) {
s += '<li class="md-source__fact">' + text + '</li>';
}
d.find(".md-source__repository").append('<ul class="md-source__facts">' + s + '</ul>');
}
function kFormatter(num) {
// https://stackoverflow.com/questions/9461621/format-a-number-as-2-5k-if-a-thousand-or-more-otherwise-900
return Math.abs(num) > 999 ? Math.sign(num)*((Math.abs(num)/1000).toFixed(1)) + 'k' : Math.sign(num)*Math.abs(num);
}
$(document).ready(function() {
add_descriptive_text(["View on GitHub"]);
$.getJSON("https://api.github.com/repos/microsoft/nni", function (data) {
add_descriptive_text([
kFormatter(data["stargazers_count"]) + " stars",
kFormatter(data["forks"]) + " forks",
]);
});
});
// Fix the hero text effect on large screens
function resetHeroHidden() {
const scrollAmount = window.scrollY;
if (window.matchMedia("only screen and (min-width: 76.25em)").matches) {
// only enable this on large screens
if (scrollAmount == 0) {
$(".md-hero").attr("data-md-state", "");
} else {
$(".md-hero").attr("data-md-state", "hidden");
}
}
}
// https://github.com/bashtage/sphinx-material/blob/6e0ef822e58df57d6a9de5a58dc40c17fc34f557/sphinx_material/sphinx_material/static/javascripts/application.js#L1384
$(window).on("scroll", resetHeroHidden);
$(window).on("resize", resetHeroHidden);
$(window).on("orientationchange", resetHeroHidden);
// Sidebar header
$(document).ready(function() {
let language = "en"; // default english
try {
language = READTHEDOCS_DATA["language"];
} catch (e) {}
const title = $(".md-sidebar--secondary .md-nav--secondary label.md-nav__title");
if (language == "en") {
title.text("On this page");
} else if (language == "zh") {
title.text("本页内容");
}
});
// Hide navigation bar when it's too short
// Hide TOC header when it coincides with page title
function hide_nav() {
const d = $('nav.md-tabs[data-md-component="tabs"]');
if (d.find('li').length <= 1) {
d.addClass('hidden');
}
}
// Expand link
function expand_link() {
// on load, collapse all links without active on the inside
$(".md-nav__expand").filter(function (index) {
return $(".md-nav__link--active", this).length >= 1;
}).addClass("md-nav__expand--active");
function toggleExpand(event) {
event.preventDefault();
$(event.target)
.closest(".md-nav__expand")
.toggleClass("md-nav__expand--active");
return false;
}
// bind click events
$(".md-nav__expand > a").click(toggleExpand);
$(".md-nav__expand > a > .md-nav__tocarrow").click(toggleExpand);
}
// Propagate card link from another element
function propagate_card_link() {
$(".card-link-clickable").each(function() {
$(this).attr("href", $(this).next("a.reference").attr("href"));
});
}
$(document).ready(function() {
hide_nav();
expand_link();
propagate_card_link();
});
$(document).ready(function() {
const downloadNote = $(".sphx-glr-download-link-note.admonition.note");
if (downloadNote.length > 0) {
const githubLink = "https://github.com/microsoft/nni/blob/" + GIT_COMMIT_ID + "/examples/" + PAGENAME + ".py";
const notebookLink = $(".sphx-glr-download-jupyter .reference.download").attr("href");
// link to generated notebook file
const colabLink = "https://colab.research.google.com/github/microsoft/nni/blob/" + GIT_COMMIT_ID +
"/docs/source/" + PAGENAME + ".ipynb";
downloadNote.removeClass("admonition");
// the image links are stored in layout.html
// to leverage jinja engine
downloadNote.html(`
<a class="notebook-action-link" href="${notebookLink}">
<div class="notebook-action-div">
<img src="${GALLERY_LINKS.notebook}"/>
<div>Download Notebook</div>
</div>
</a>
<a class="notebook-action-link" href="${colabLink}">
<div class="notebook-action-div">
<img src="${GALLERY_LINKS.colab}"/>
<div>Run in Google Colab</div>
</div>
</a>
<a class="notebook-action-link" href="${githubLink}">
<div class="notebook-action-div">
<img src="${GALLERY_LINKS.github}"/>
<div>View on GitHub</div>
</div>
</a>
`);
}
});
try {
READTHEDOCS_DATA;
} catch (e) {
console.log('READTHEDOCS_DATA is undefined. In debug mode.');
// mock info
READTHEDOCS_DATA = {
"ad_free": false,
"api_host": "https://readthedocs.org",
"build_date": "2022-01-25T06:27:55Z",
"builder": "sphinx",
"canonical_url": null,
"commit": "ca66e346",
"docroot": "/docs/en_US/",
"features": { "docsearch_disabled": false },
"global_analytics_code": "UA-17997319-1",
"language": "en",
"page": "Tutorial",
"programming_language": "words",
"project": "nni",
"proxied_api_host": "/_",
"source_suffix": ".rst",
"subprojects": { "nni-zh": "https://nni.readthedocs.io/zh/stable/" },
"theme": "sphinx_material",
"user_analytics_code": "UA-136029994-1",
"version": "latest"
};
READTHEDOCS_VERSIONS = [
["latest", "/en/latest/"],
["stable", "/en/stable/"],
["v2.6", "/en/v2.6/"],
["v2.5", "/en/v2.5/"],
["v2.4", "/en/v2.4/"],
["v2.3", "/en/v2.3/"],
["test-version", "/en/test-version"]
];
// The above code is injected by readthedocs in production.
}
function create_dropdown(selector, button_text, items) {
const dropdown = $(selector);
const button = document.createElement("button");
button.innerHTML = button_text;
const content = document.createElement("ul");
// content.className = "dropdown-content md-hero";
dropdown.append(button);
dropdown.append(content);
for (const key in items) {
if (items.hasOwnProperty(key)) {
const li = document.createElement("li");
const a = document.createElement("a");
a.className = "md-nav__link"
a.innerHTML = key;
a.title = key;
a.href = items[key];
li.appendChild(a);
content.appendChild(li);
}
}
$(button).click(function (e) {
// first close all others.
$(".drop").find(".active").removeClass("active");
dropdown.find("ul").addClass("active");
dropdown.find("button").addClass("active");
e.stopPropagation();
})
$(document).click(function () {
$(".drop").find(".active").removeClass("active");
})
return dropdown;
}
function add_version_dropdown() {
const prev_versions = Object.assign(
{},
...READTHEDOCS_VERSIONS
.filter(([k, v]) => (k === 'stable' || k == 'latest' || k.startsWith('v')))
.map(([k, v]) => ({ [k]: v }))
);
const current_version = 'v: ' + READTHEDOCS_DATA["version"];
create_dropdown(".drop.version", current_version, prev_versions);
}
function add_language_dropdown() {
const language_dropdown = {
'en': 'English',
'zh': '简体中文'
};
let current_language = 'en';
const pathname_prefix = window.location.pathname.split('/');
if (pathname_prefix.length > 1 && language_dropdown.hasOwnProperty(pathname_prefix[1])) {
current_language = pathname_prefix[1];
}
function get_dropdown_href(lang) {
let pathname = window.location.pathname.split('/');
if (pathname.length > 1) {
pathname[1] = lang;
}
return pathname.join('/');
}
create_dropdown(".drop.language", language_dropdown[current_language], {
[language_dropdown['en']]: get_dropdown_href('en'),
[language_dropdown['zh']]: get_dropdown_href('zh')
});
}
$(document).ready(function () {
add_language_dropdown();
add_version_dropdown();
});
.. Modified from https://raw.githubusercontent.com/sphinx-doc/sphinx/4.x/sphinx/ext/autosummary/templates/autosummary/module.rst
{% if fullname == 'nni' %}
Python API Reference
====================
{% else %}
{{ fullname | escape | underline }}
{% endif %}
.. automodule:: {{ fullname }}
:noindex:
{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Module Attributes') }}
.. autosummary::
{% for item in attributes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block functions %}
{% if functions %}
.. rubric:: {{ _('Functions') }}
.. autosummary::
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block classes %}
{% if classes %}
.. rubric:: {{ _('Classes') }}
.. autosummary::
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block exceptions %}
{% if exceptions %}
.. rubric:: {{ _('Exceptions') }}
.. autosummary::
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block modules %}
{% if modules %}
.. rubric:: Modules
.. autosummary::
:toctree:
:recursive:
{% for item in modules %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% set toctree = toctree(maxdepth=theme_globaltoc_depth|toint, collapse=theme_globaltoc_collapse|tobool, includehidden=theme_globaltoc_includehidden|tobool, titles_only=True) %}
{% if toctree and sidebars and 'globaltoc.html' in sidebars %}
{% set toctree_nodes = derender_toc(toctree, False) %}
<ul class="md-nav__list">
<li class="md-nav__item md-nav__overview">
<a href="{{ pathto('index')|e }}" class="md-nav__link{% if pagename == 'index' %} md-nav__link--active{% endif %}">{{ _('Overview') }}</a>
</li>
{%- for item in toctree_nodes recursive %}
<li class="md-nav__item{% if item.children %} md-nav__expand{% endif %}">
{% if "caption" in item %}
<span class="md-nav__link caption">{{ item.caption }}</span>
{% else %}
{% if item.current %}
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc"> {{ item.contents }} </label>
{% endif %}
<a href="{{ item.href|e }}" class="md-nav__link{% if item.current %} md-nav__link--active{% endif %}">
{% if item.children %}
<span class="material-icons md-nav__tocarrow">&#xE5C5;</span>
{% endif %}
{{ item.contents }}
</a>
{% if item.current %}
{%- set sphinx_material_include_searchbox=False %}
{% include "localtoc.html" %}
{% endif %}
{%- set sphinx_material_include_searchbox=True %}
{%- if item.children -%}
<ul class="md-nav__list"> {{ loop(item.children) }}</ul>
{%- endif %}
{% endif %}
</li>
{%- endfor %}
</ul>
{# TODO: Fallback to toc? #}
{% endif %}
<header class="md-header" data-md-component="header">
<nav class="md-header-nav md-grid">
<div class="md-flex navheader">
<div class="md-flex__cell md-flex__cell--shrink">
<a href="{{ pathto(master_doc)|e }}" title="{{ docstitle|e }}"
class="md-header-nav__button md-logo">
{% if theme_logo_icon|e %}
<i class="md-icon">{{ theme_logo_icon }}</i>
{% elif logo %}
<img src="{{ pathto('_static/' ~ logo, 1) }}" height="26"
alt="{{ shorttitle|striptags|e }} logo">
{% else %}
&nbsp;
{% endif %}
</a>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label>
</div>
<div class="md-flex__cell md-flex__cell--stretch">
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
<span class="md-header-nav__topic">{{ theme_nav_title or shorttitle }}</span>
<span class="md-header-nav__topic"> {{ title|striptags|e }} </span>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--search md-header-nav__button" for="__search"></label>
{% include "searchbox.html" %}
</div>
<div class="md-flex__cell md-flex__cell--shrink drop version"></div>
<div class="md-flex__cell md-flex__cell--shrink drop language"></div>
<div class="md-flex__cell md-flex__cell--shrink">
{% if theme_repo_url %}
<div class="md-header-nav__source">
{% include "repo.html" %}
</div>
{% endif %}
</div>
</div>
</nav>
</header>
{% if pagename in theme_heroes %}
{% set hero = theme_heroes[pagename] %}
<div class="md-hero{% if nav_bar_tabs %} md-hero--expand{% endif %}" data-md-component="hero">
<div class="md-hero__inner md-grid">
<p>{{ hero }}</p>
</div>
<div class="md-hero__background">
<img src="{{ pathto('_static/img/hero-background.svg', 1) }}" />
</div>
</div>
{% endif %}
{% extends "!layout.html" %}
{#- SPECIFY PARTICULAR FONTS FOR HEADERS #}
{% block font %}
<link href="https://fonts.gstatic.com/" rel="preconnect" crossorigin>
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono:400,500,700|Roboto:400,400i,500,700|Google+Sans:400,500,600|Material+Icons&display=fallback" rel="stylesheet">
{% endblock %}
{#- TO INJECT INFORMATION FROM READTHEDOCS HERE #}
{% block scripts %}
{{ super() }}
{#- CUSTOM THEME #}
<style>
:root {
--custom-color-primary: #1381cf;
--custom-color-accent: #0e619d;
}
</style>
{% if versions %}
<script type="text/javascript">
READTHEDOCS_VERSIONS = {{ versions | tojson }}
</script>
{% endif %}
<script type="text/javascript">
// for gallery links
GIT_COMMIT_ID = "{{ git_commit_id }}";
PAGENAME = "{{ pagename }}";
GALLERY_LINKS = {
colab: "{{ pathto('_static/img/gallery-colab.svg', 1) }}",
notebook: "{{ pathto('_static/img/gallery-download.svg', 1) }}",
github: "{{ pathto('_static/img/gallery-github.svg', 1) }}"
}
</script>
{% endblock %}
{#- REPLACE ATTRIBUTES INSTANTLY TO DISABLE SOME HOOKS #}
{% block footer_scripts %}
<script type="text/javascript">
// try to disable original hook for md-source.
$('*[data-md-source="github"]').attr("data-md-source", "nni");
</script>
{{ super() }}
{% endblock %}
{%- if nav_bar_tabs and pagename != 'index' %}
<nav class="md-tabs" data-md-component="tabs">
<div class="md-tabs__inner md-grid">
<ul class="md-tabs__list">
{%- block rootrellink %}
{%- if theme_master_doc %}
<li class="md-tabs__item">
<a href="{{ pathto(master_doc)|e }}" class="md-tabs__link">
{{ shorttitle }}
<span class="material-icons md-tabs__arrow">&#xEAC9;</span>
</a>
</li>
{%- endif %}
{%- endblock %}
{#- DO NOT SUPPORT THEME NAV LINKS HERE #}
{%- for parent in parents %}
<li class="md-tabs__item">
<a href="{{ parent.link|e }}" class="md-tabs__link">
{{ parent.title }}
<span class="material-icons md-tabs__arrow">&#xEAC9;</span>
</a>
</li>
{%- endfor %}
<li class="md-tabs__item"><a href="#" class="md-tabs__link">{{ title|striptags|e }}</a></li>
</ul>
</div>
</nav>
{%- endif %}
"""
This is to keep Chinese doc update to English doc. Should be run regularly.
There is no sane way to check the contents though. PR review should enforce contributors to update the corresponding translation.
See https://github.com/microsoft/nni/issues/4298 for discussion.
Under docs, run
python tools/chineselink.py
"""
import hashlib
import shutil
import sys
from pathlib import Path
def iterate_dir(path):
for p in Path(path).iterdir():
if p.is_dir():
yield from iterate_dir(p)
continue
yield p
suffix_list = [
'.html',
'.md',
'.rst',
'.ipynb',
]
pipeline_mode = len(sys.argv) > 1 and sys.argv[1] == 'check'
failed_files = []
# in case I need to change `_zh` to something else
# files = list(filter(lambda d: d.name.endswith('zh_CN.rst'), iterate_dir('source')))
# for file in files:
# os.rename(file, file.parent / (file.name[:-7] + file.name[-4:]))
def need_to_translate(source, target):
if not target.exists():
failed_files.append('(missing) ' + target.as_posix())
if pipeline_mode:
return
shutil.copyfile(source, target)
if target.suffix == '.html':
return # FIXME I don't know how to process html
target_checksum = hashlib.sha256(path.open('rb').read()).hexdigest()[:32]
checksum = target.open('r').readline().strip()[3:]
if checksum != target_checksum:
failed_files.append('(out-of-date) ' + target.as_posix())
if pipeline_mode:
return
contents = target.open('r').readlines()
firstline = '.. ' + target_checksum + '\n'
if contents[0].startswith('.. '):
contents = [firstline] + contents[1:]
else:
contents = [firstline, '\n'] + contents
target.open('w').writelines(contents)
for path in iterate_dir(Path('source')):
relative_path = path.relative_to('source')
if relative_path.as_posix().startswith('_build'):
continue
if path.suffix in suffix_list:
if '_zh.' not in path.name:
target_path = path.parent / (path.stem + '_zh' + path.suffix)
if target_path.exists():
# whitelist files. should be translated
need_to_translate(path, target_path)
print(f'Skipped linking for {path} as it is in whitelist.')
else:
source_path = path.parent / (path.stem[:-3] + path.suffix)
if not source_path.exists():
# delete redundant files
failed_files.append('(redundant) ' + source_path.as_posix())
if not pipeline_mode:
print(f'Deleting {source_path}')
path.unlink()
if pipeline_mode and failed_files:
raise ValueError(
'The following files are not up-to-date. Please run "python3 tools/chineselink.py" under docs folder '
'to refresh them and update their corresponding translation.\n' + '\n'.join([' ' + line for line in failed_files]))
if failed_files:
print('Updated files:', failed_files)
import os
import shutil
from pathlib import Path
for root, dirs, files in os.walk('archive_en_US'):
root = Path(root)
for file in files:
moved_root = Path('en_US') / root.relative_to('archive_en_US')
shutil.move(root / file, moved_root / file)
os.remove(moved_root / (Path(file).stem + '.rst'))
"""
Fix a troublsome translation in sphinx.
Related PR: https://github.com/sphinx-doc/sphinx/pull/10303
"""
import subprocess
from pathlib import Path
import sphinx
sphinx_path = Path(sphinx.__path__[0]) / 'locale/zh_CN/LC_MESSAGES'
po_content = (sphinx_path / 'sphinx.po').read_text()
po_content = po_content.replace('%s的别名', '%s 的别名')
(sphinx_path / 'sphinx.po').write_text(po_content)
# build po -> mo
subprocess.run(['msgfmt', '-c', str(sphinx_path / 'sphinx.po'), '-o', str(sphinx_path / 'sphinx.mo')], check=True)
# Define your own Assessor
*Assessor receive intermediate result from Trial and decide whether the Trial should be killed. Once the Trial experiment meets the early stop conditions, the assessor will kill the Trial.*
So, if users want to implement a customized Assessor, they only need to:
**1) Inherit an assessor of a base Assessor class**
```python
from nni.assessor import Assessor
class CustomizedAssessor(Assessor):
def __init__(self, ...):
...
```
**2) Implement assess trial function**
```python
from nni.assessor import Assessor, AssessResult
class CustomizedAssessor(Assessor):
def __init__(self, ...):
...
def assess_trial(self, trial_history):
"""
Determines whether a trial should be killed. Must override.
trial_history: a list of intermediate result objects.
Returns AssessResult.Good or AssessResult.Bad.
"""
# you code implement here.
...
```
**3) Write a script to run Assessor**
```python
import argparse
import CustomizedAssessor
def main():
parser = argparse.ArgumentParser(description='parse command line parameters.')
# parse your assessor arg here.
...
FLAGS, unparsed = parser.parse_known_args()
tuner = CustomizedAssessor(...)
tuner.run()
main()
```
Please noted in 2). The object `trial_history` are exact the object that Trial send to Assessor by using SDK `report_intermediate_result` function.
Also, user could override the `run` function in Assessor to control the process logic.
More detail example you could see:
> * [Base-Assessor](https://msrasrg.visualstudio.com/NeuralNetworkIntelligenceOpenSource/_git/Default?_a=contents&path=%2Fsrc%2Fsdk%2Fpynni%2Fnni%2Fassessor.py&version=GBadd_readme)
# 自定义 Assessor
*Assessor 从 Trial 中接收中间结果,并决定此 Trial 是否应该终止。 一旦 Trial 满足提前终止条件,Assessor 将终止此 Trial。*
因此,如果要自定义 Assessor,需要:
**1) 继承于 Assessor 基类,创建 Assessor 类**
```python
from nni.assessor import Assessor
class CustomizedAssessor(Assessor):
def __init__(self, ...):
...
```
**2) 实现评估 Trial 的函数**
```python
from nni.assessor import Assessor, AssessResult
class CustomizedAssessor(Assessor):
def __init__(self, ...):
...
def assess_trial(self, trial_history):
"""
决定是否应该终止 Trial。 必须重载。
trial_history: 中间结果列表对象。
返回 AssessResult.Good 或 AssessResult.Bad。
"""
# 代码实现于此处。
...
```
**3) 实现脚本来运行 Assessor**
```python
import argparse
import CustomizedAssessor
def main():
parser = argparse.ArgumentParser(description='parse command line parameters.')
# 在这里解析 Assessor 的参数。
...
FLAGS, unparsed = parser.parse_known_args()
tuner = CustomizedAssessor(...)
tuner.run()
main()
```
注意 2) 中, 对象 `trial_history``report_intermediate_result` 函数返回给 Assessor 的完全一致。
也可以重载 Assessor 的 `run` 函数来控制过程逻辑。
更多示例,可参考:
> - [Base-Assessor](https://msrasrg.visualstudio.com/NeuralNetworkIntelligenceOpenSource/_git/Default?_a=contents&path=%2Fsrc%2Fsdk%2Fpynni%2Fnni%2Fassessor.py&version=GBadd_readme)
\ No newline at end of file
**Automatic Feature Engineering in nni**
===
Now we have an [example](https://github.com/SpongebBob/tabular_automl_NNI), which could automaticlly do feature engineering in nni.
These code come from our contributors. And thanks our lovely contributors!
And welcome more and more people to join us!
**NNI 中的自动特征工程** ===
[示例](https://github.com/SpongebBob/tabular_automl_NNI)在 NNI 中实现了自动特征工程。
代码来自于贡献者。 谢谢可爱的贡献者!
欢迎越来越多的人加入我们!
# Copyright (c) Microsoft Corporation
# All rights reserved.
#
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import bz2
import urllib.request
import numpy as np
from sklearn.datasets import load_svmlight_file
from sklearn.model_selection import train_test_split
from nni.algorithms.feature_engineering.gbdt_selector import GBDTSelector
url_zip_train = 'https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/rcv1_train.binary.bz2'
urllib.request.urlretrieve(url_zip_train, filename='train.bz2')
f_svm = open('train.svm', 'wt')
with bz2.open('train.bz2', 'rb') as f_zip:
data = f_zip.read()
f_svm.write(data.decode('utf-8'))
f_svm.close()
X, y = load_svmlight_file('train.svm')
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
lgb_params = {
'boosting_type': 'gbdt',
'objective': 'regression',
'metric': {'l2', 'l1'},
'num_leaves': 20,
'learning_rate': 0.05,
'feature_fraction': 0.9,
'bagging_fraction': 0.8,
'bagging_freq': 5,
'verbose': 0}
eval_ratio = 0.1
early_stopping_rounds = 10
importance_type = 'gain'
num_boost_round = 1000
topk = 10
selector = GBDTSelector()
selector.fit(X_train, y_train,
lgb_params = lgb_params,
eval_ratio = eval_ratio,
early_stopping_rounds = early_stopping_rounds,
importance_type = importance_type,
num_boost_round = num_boost_round)
print("selected features\t", selector.get_selected_features(topk=topk))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment