<h4 dir="auto">Describe the workflow you want to enable</h4>
<p dir="auto">As a continuation to <a href="https://github.com/scikit-learn/scikit-learn/issues/18105" data-hovercard-type="issue" data-hovercard-url="/scikit-learn/scikit-learn/issues/18105/hovercard">18105</a>, I would like to propose a feature addition to Decision Tree to enable them to handle categorical variables.</p>
<h4 dir="auto">Describe your proposed solution</h4>
<p dir="auto">The solution will be to update <code class="notranslate">fit</code> and <code class="notranslate">predict</code> method of <code class="notranslate">BaseDecisionTree</code> class in <a href="https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/tree/_classes.py">_classes.py</a>. As mentioned in <a href="https://github.com/scikit-learn/scikit-learn/issues/18105" data-hovercard-type="issue" data-hovercard-url="/scikit-learn/scikit-learn/issues/18105/hovercard">18105</a> <code class="notranslate">OrdinalEncoder</code> will be used to encoded categorical variables.</p>
<h4 dir="auto">Describe alternatives you've considered, if relevant</h4>
<p dir="auto">Althernatives were <code class="notranslate">OneHotEncoder</code> or <code class="notranslate">Dummy</code> variables but they will make the algorithm slower</p>
<p dir="auto">I propose a <code class="notranslate">__sk_clone__</code> method that <code class="notranslate">clone</code> calls (if the method exist). This way arbitrary objects can define how they want to be cloned.  This is similar to mechanism behind  <code class="notranslate">__sk_is_fitted__</code> + <code class="notranslate">check_is_fitted</code>.</p>
<h3 dir="auto">Purpose</h3>
<p dir="auto">There are PR that run into issues with <code class="notranslate">clone</code>, and it would be nice to allow the <code class="notranslate">estimator</code> to define how it wants to be cloned.</p>
<ol dir="auto">
<li>Metadata routing: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1021222017" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/21284" data-hovercard-type="pull_request" data-hovercard-url="/scikit-learn/scikit-learn/pull/21284/hovercard" href="https://github.com/scikit-learn/scikit-learn/pull/21284">#21284</a> Needed to change <code class="notranslate">clone</code> to copy an private attribute that is configured outside of <code class="notranslate">__init__</code></li>
<li>Search spaces in estimator: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1063020130" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/21784" data-hovercard-type="pull_request" data-hovercard-url="/scikit-learn/scikit-learn/pull/21784/hovercard?comment_id=979284821&amp;comment_type=issue_comment" href="https://github.com/scikit-learn/scikit-learn/pull/21784#issuecomment-979284821">#21784 (comment)</a> the search space itself needs to be copied over when <code class="notranslate">clone</code> gets called.</li>
<li>Ability to customize cloning: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="512892023" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/15371" data-hovercard-type="issue" data-hovercard-url="/scikit-learn/scikit-learn/issues/15371/hovercard?comment_id=546655096&amp;comment_type=issue_comment" href="https://github.com/scikit-learn/scikit-learn/issues/15371#issuecomment-546655096">#15371 (comment)</a></li>
</ol>