I have a multi-class problem. I want to solve this problem using the LCPN (Local Classifier per Parent Node) method of heirachical classification. Therefore, I have manually divided the original dataset into a hierarchy of 2 levels. Level 1 has, 4 parent classes & each of the parent classes have child classes.
I built a model for level 1 classification (for predicting the parent class). Based on the predictions of level 1, now I want to send the instances that were classified as class 1, to a second classifier that distinguishes between the child labels of class 1. Likewise, I want to repeat this process for the other parent classes as well. I’m mainly doing this to avoid, inconsistency problem associated with LCPN.
This is what I have mainly done so far.
X = data_frame.drop([‘region’], axis = 1) # Features y = data_frame[‘region’] # Labels X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42) sm = SMOTE() X_resampled, y_resampled = sm.fit_sample(X_train, y_train) model = DecisionTreeClassifier().fit(X_resampled, y_resampled)
predictions = model.predict(X_test) print(classification_report_imbalanced(y_test, predictions))
I’m bit struggling finding a way how to proceed further with the second level of classification, based on the predictions of level 1. Can anyone suggest me a good way to do this.
Thanks in advance