Skip to content

Not able to recognize classes after fitting #41

@sanket1105

Description

@sanket1105

What's wrong with this code? Given my "y_train" has 2 unique values: 0 and 1.

Output:
Unique values in target variable: 2
Classes in IcpClassifier before fit: None
Classes in IcpClassifier after fit: None

`from nonconformist.icp import IcpClassifier
from nonconformist.nc import ClassifierNc, MarginErrFunc
import catboost
import numpy as np

Create a CatBoost classifier

model = catboost.CatBoostClassifier(iterations=100,
loss_function='Logloss',
depth=5,
eval_metric='Logloss',
random_seed=42,
learning_rate=0.1,
leaf_estimation_iterations=10,
verbose=False)

Initialing the model

model.fit(train_X, train_y)
nc = ClassifierNc(model)
icp = IcpClassifier(nc)

Print information about the target variable

print("Unique values in target variable:", train_y.nunique())

Print classes in IcpClassifier before fit

print("Classes in IcpClassifier before fit:", icp.classes)

Fit the IcpClassifier with the training data

icp.fit(train_X, train_y)

Print classes in IcpClassifier after fit

print("Classes in IcpClassifier after fit:", icp.classes)

Obtain prediction intervals for the test set

prediction_intervals = icp.predict(test_X, significance=0.05)
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions