.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_hello_hiclass.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_hello_hiclass.py: ===================== Hello HiClass ===================== A minimalist example showing how to use HiClass to train and predict. .. GENERATED FROM PYTHON SOURCE LINES 9-33 .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/hiclass/envs/v5.0.2/lib/python3.12/site-packages/sklearn/base.py:474: FutureWarning: `BaseEstimator._validate_data` is deprecated in 1.6 and will be removed in 1.7. Use `sklearn.utils.validation.validate_data` instead. This function becomes public and is part of the scikit-learn developer API. warnings.warn( [['Animal' 'Reptile' 'Lizard'] ['Animal' 'Reptile' 'Snake'] ['Animal' 'Mammal' 'Cow'] ['Animal' 'Mammal' 'Sheep']] | .. code-block:: Python from sklearn.ensemble import RandomForestClassifier from hiclass import LocalClassifierPerNode # Define data X_train = [[1], [2], [3], [4]] X_test = [[4], [3], [2], [1]] Y_train = [ ["Animal", "Mammal", "Sheep"], ["Animal", "Mammal", "Cow"], ["Animal", "Reptile", "Snake"], ["Animal", "Reptile", "Lizard"], ] # Use random forest classifiers for every node rf = RandomForestClassifier() classifier = LocalClassifierPerNode(local_classifier=rf) # Train local classifier per node classifier.fit(X_train, Y_train) # Predict predictions = classifier.predict(X_test) print(predictions) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.642 seconds) .. _sphx_glr_download_auto_examples_plot_hello_hiclass.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_hello_hiclass.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_hello_hiclass.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_hello_hiclass.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_