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
I have checked the CHANGELOG and the commit log to find out if the bug was already fixed in the main branch.
I have included in the "Description" section below a traceback from any exceptions related to this bug.
I have included in the "Related issues or possible duplicates" section beloew all related issues and possible duplicate issues (If there are none, check this box anyway).
I have included in the "Environment" section below the name of the operating system and Python version that I was using when I discovered this bug.
Description
Errors when trying to use partial_fit in a variety of ways - I am getting this with int or string values for y and with and without providing classes to partial_fit. Could you point me to what I'm doing wrong here?
importnumpyasnpfromtreepleimportPatchObliqueRandomForestClassifierX=np.array([[1, 2, 3]]).Ty=np.array(["x", "y", "z"])
classes=yporf=PatchObliqueRandomForestClassifier()
porf.fit(X, y, classes=classes)
porf.partial_fit(X, y, classes=classes)
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
File /Users/ben.pedigo/code/meshrep/meshrep/sandbox/view_model.py:9
[7](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/meshrep/sandbox/view_model.py:7) classes = y
[8](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/meshrep/sandbox/view_model.py:8) porf = PatchObliqueRandomForestClassifier()
----> [9](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/meshrep/sandbox/view_model.py:9) porf.fit(X, y, classes=classes)
[10](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/meshrep/sandbox/view_model.py:10) porf.partial_fit(X, y, classes=classes)
File ~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/base.py:1473, in _fit_context.<locals>.decorator.<locals>.wrapper(estimator, *args, **kwargs)
[1466](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/base.py:1466) estimator._validate_params()
[1468](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/base.py:1468) with config_context(
[1469](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/base.py:1469) skip_parameter_validation=(
[1470](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/base.py:1470) prefer_skip_nested_validation or global_skip_validation
[1471](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/base.py:1471) )
[1472](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/base.py:1472) ):
-> [1473](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/base.py:1473) return fit_method(estimator, *args, **kwargs)
File ~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:595, in BaseForest.fit(self, X, y, sample_weight, classes)
[592](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:592) random_state.randint(MAX_INT, size=len(self.estimators_))
[594](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:594) # construct the trees in parallel
--> [595](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:595) self._construct_trees(
[596](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:596) X,
[597](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:597) y,
[598](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:598) sample_weight,
[599](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:599) random_state,
[600](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:600) n_samples_bootstrap,
[601](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:601) missing_values_in_feature_mask,
[602](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:602) classes,
[603](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:603) n_more_estimators,
[604](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:604) )
[606](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:606) ifself.oob_score and (
[607](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:607) n_more_estimators >0ornothasattr(self, "oob_score_")
[608](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:608) ):
[609](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:609) y_type = type_of_target(y)
File ~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:661, in BaseForest._construct_trees(self, X, y, sample_weight, random_state, n_samples_bootstrap, missing_values_in_feature_mask, classes, n_more_estimators)
[650](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:650) trees = [
[651](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:651) self._make_estimator(append=False, random_state=random_state)
[652](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:652) for i inrange(n_more_estimators)
[653](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:653) ]
[655](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:655) # Parallel loop: we prefer the threading backend as the Cython code
[656](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:656) # for fitting the trees is internally releasing the Python GIL
[657](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:657) # making threading more efficient than multiprocessing in
[658](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:658) # that case. However, for joblib 0.12+ we respect any
[659](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:659) # parallel_backend contexts set at a higher level,
[660](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:660) # since correctness does not rely on using threads.
--> [661](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:661) trees = Parallel(
[662](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:662) n_jobs=self.n_jobs,
[663](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:663) verbose=self.verbose,
[664](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:664) prefer="threads",
[665](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:665) )(
[666](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:666) delayed(_parallel_build_trees)(
[667](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:667) t,
[668](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:668) self.bootstrap,
[669](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:669) X,
[670](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:670) y,
[671](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:671) sample_weight,
[672](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:672) i,
[673](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:673) len(trees),
[674](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:674) verbose=self.verbose,
[675](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:675) class_weight=self.class_weight,
[676](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:676) n_samples_bootstrap=n_samples_bootstrap,
[677](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:677) missing_values_in_feature_mask=missing_values_in_feature_mask,
[678](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:678) classes=classes,
[679](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:679) )
[680](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:680) for i, t inenumerate(trees)
[681](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:681) )
[683](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:683) # Collect newly grown trees
[684](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/ensemble/_forest.py:684) self.estimators_.extend(trees)
File ~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/utils/parallel.py:74, in Parallel.__call__(self, iterable)
[69](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/utils/parallel.py:69) config = get_config()
[70](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/utils/parallel.py:70) iterable_with_config = (
[71](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/utils/parallel.py:71) (_with_config(delayed_func, config), args, kwargs)
[72](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/utils/parallel.py:72) for delayed_func, args, kwargs in iterable
[73](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/utils/parallel.py:73) )
---> [74](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/sklearn/utils/parallel.py:74) return super().__call__(iterable_with_config)
File ~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1918, in Parallel.__call__(self, iterable)
[1916](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1916) output = self._get_sequential_output(iterable)
[1917](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1917) next(output)
-> [1918](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1918) return output if self.return_generator else list(output)
[1920](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1920) # Let's create an ID that uniquely identifies the current call. If the
[1921](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1921) # call is interrupted early and that the same instance is immediately
[1922](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1922) # re-used, this id will be used to prevent workers that were
[1923](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1923) # concurrently finalizing a task from the previous call to run the
[1924](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1924) # callback.
[1925](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1925) with self._lock:
File ~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1847, in Parallel._get_sequential_output(self, iterable)
[1845](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1845) self.n_dispatched_batches += 1
[1846](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1846) self.n_dispatched_tasks += 1
-> [1847](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1847) res = func(*args, **kwargs)
[1848](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1848) self.n_completed_tasks += 1
[1849](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/joblib/parallel.py:1849) self.print_progress()
...
[324](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/tree/_classes.py:324) ]
[325](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/tree/_classes.py:325) else:
[326](https://file+.vscode-resource.vscode-cdn.net/Users/ben.pedigo/code/meshrep/~/code/meshrep/meshrep/.venv/lib/python3.11/site-packages/treeple/_lib/sklearn/tree/_classes.py:326) for k inrange(self.n_outputs_):
IndexError: index 0 is out of bounds for axis 0 with size 0
Environment
OS: Mac
Python version: 3.11
Treeple 0.9.1
The text was updated successfully, but these errors were encountered:
Hey @bdpedigo thanks for reporting the issue. So the PatchObliquDTC could be rewritten. There are some weird issues because I implemented it in a naive way. In addition, partial_fit is an experimental feature we added that hasn't been fully tested.
Checklist
main
branch.Description
Errors when trying to use
partial_fit
in a variety of ways - I am getting this with int or string values fory
and with and without providingclasses
topartial_fit
. Could you point me to what I'm doing wrong here?Environment
OS: Mac
Python version: 3.11
Treeple 0.9.1
The text was updated successfully, but these errors were encountered: