You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
please check `Hyperparameter Search for Tree-Based Linear Method <../auto_examples/plot_tree_gridsearch_tutorial.html>`_.
8
+
4
9
This guide helps users to tune the hyperparameters of the feature generation step and the linear model.
10
+
In this guide, the following methods are available:
11
+
``1vsrest``, ``thresholding``, ``cost_sensitive``, ``cost_sensitive_micro``, and ``binary_and_multiclass``.
5
12
6
13
Here we show an example of tuning a linear text classifier with the `rcv1 dataset <https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multilabel.html#rcv1v2%20(topics;%20full%20sets)>`_.
7
14
Starting with loading and preprocessing of the data without using ``Preprocessor``:
For more details about the implementation of tree-based linear methods and hyperparameter search.
22
+
23
+
Here we show an example of tuning a tree-based linear text classifier with the `rcv1 dataset <https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multilabel.html#rcv1v2%20(topics;%20full%20sets)>`_.
# Following the suggestions in the `implementation document <https://www.csie.ntu.edu.tw/~cjlin/papers/libmultilabel/libmultilabel_implementation.pdf>`_,
57
+
# we define 18 configurations to build a simple yet strong baseline.
58
+
#
59
+
# The search space covers several key parts of the search process:
60
+
#
61
+
# - Text feature extraction: (``ngram_range``, ``stop_words``)
62
+
#
63
+
# - We use the vectorizer ``TfidfVectorizer`` from ``sklearn`` to generate features from raw text.
64
+
#
65
+
# - Label tree structure: (``dmax``, ``K``)
66
+
#
67
+
# - The depth and node degree of the label tree. Note that ``K`` is the number of clusters and is calculated using the formula from the `implementation document <https://www.csie.ntu.edu.tw/~cjlin/papers/libmultilabel/libmultilabel_implementation.pdf>`_.
68
+
#
69
+
# - Linear classifier: (``s``, ``c``, ``B``)
70
+
#
71
+
# - We combined them into a LIBLINEAR option string for training linear classifiers. (see *train Usage* in `liblinear <https://github.com/cjlin1/liblinear>`__ README)
72
+
#
73
+
# - Prediction: (``beam_width``, ``prob_A``)
74
+
#
75
+
# - The number of candidates considered and the parameter for the probability estimation function at each level during prediction.
76
+
#
77
+
# .. tip::
78
+
#
79
+
# Available hyperparameters (and their defaults) are defined in the class variables of :py:class:`~libmultilabel.linear.TreeGridParameter`.
80
+
#
81
+
# In :py:class:`~libmultilabel.linear.TreeGridSearch`, we perform cross-validation for evaluation.
82
+
# Specifically, we split the training data into ``n_folds``,
83
+
# sequentially using each fold as the validation set while training on the remaining folds.
84
+
# Finally, we aggregate the validation outputs from each fold and compute the ``monitor_metrics``.
85
+
# Initialization requires the dataset, the number of cross-validation folds, and the evaluation metrics.
# ``cv_scores`` is a dictionary where keys are :py:class:`~libmultilabel.linear.TreeGridParameter` instances and values are the ``monitor_metrics`` results.
94
+
#
95
+
# Here we sort the results in descending order by the first metric in ``monitor_metrics``.
96
+
# You can retrieve the best parameters after the grid search with the following code:
0 commit comments