many_class_classifier ¶
ManyClassClassifier ¶
Bases: OutputCodeClassifier
Output-Code multiclass strategy with deciary codebook.
This class extends the original OutputCodeClassifier to support n-ary codebooks (with n=alphabet_size), allowing for handling more classes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
estimator |
estimator object
An estimator object implementing :term: |
required | |
random_state |
int, RandomState instance, default=None
The generator used to initialize the codebook.
Pass an int for reproducible output across multiple function calls.
See :term: |
None
|
Attributes:
Name | Type | Description |
---|---|---|
estimators_ |
list of |
|
classes_ |
ndarray of shape (n_classes,) Array containing labels. |
|
code_book_ |
ndarray of shape (n_classes, |
>>> from sklearn.datasets import load_iris
>>> from tabpfn.scripts.estimator import ManyClassClassifier, TabPFNClassifier
>>> from sklearn.model_selection import train_test_split
>>> x, y = load_iris(return_X_y=True)
>>> x_train, x_test, y_train, y_test = train_test_split(x, y, random_state=42)
>>> clf = TabPFNClassifier()
>>> clf = ManyClassClassifier(clf, alphabet_size=clf.max_num_classes_)
>>> clf.fit(x_train, y_train)
>>> clf.predict(x_test)
fit ¶
Fit underlying estimators.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
{array-like, sparse matrix} of shape (n_samples, n_features) Data. |
required | |
y |
array-like of shape (n_samples,) Multi-class targets. |
required | |
**fit_params |
dict
Parameters passed to the |
{}
|
Returns:
Name | Type | Description |
---|---|---|
self |
object Returns a fitted instance of self. |
predict_proba ¶
Predict probabilities using the underlying estimators.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
{array-like, sparse matrix} of shape (n_samples, n_features) Data. |
required |
Returns:
Name | Type | Description |
---|---|---|
p |
ndarray of shape (n_samples, n_classes)
Returns the probability of the samples for each class in the model,
where classes are ordered as they are in |