use sample weights fit model multiclass

The solution for “use sample weights fit model multiclass” can be found here. The following code will assist you in solving the problem.

from sklearn.utils import class_weight

class_weights = class_weight.compute_class_weight(‘balanced’,
np.unique(y_train),
y_train)

model.fit(X_train, y_train, class_weight=class_weights)

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in