1
$\begingroup$

Why is len(clf) = 6 even though there are just 4 classes?

Data is stored in the following format:

class1 val(1,1), val(1,2)
class2 val(2,1), val(2,2)
class2 val(3,1), val(3,2)
class2 val(4,1), val(4,2)
(...) 
clf = OutputCodeClassifier(sklearn.svm.SVC(kernel = 'linear', decision_function_shape = "ovr")).fit(X, Y).estimators_
print(len(clf))

Also, the values in the code matrx are wrong. Since it should be $$a_{i,j} = \begin{cases} 1 &, i = j \\ -1, &,i \ne j \end{cases}$$

Edit:

clf = OutputCodeClassifier(sklearn.svm.SVC(kernel = 'linear', decision_function_shape = "ovr")).fit(X[:, [1, 10]], categories).estimators_

for estimator in clf:
    y = []

    for val in X[:, 1]:
        y = y + [(val*estimator.coef_[0][0] + estimator.intercept_) / estimator.coef_[0][1]]

    plt.plot(X[:, 1], y)

plt.ylim([-10, 10])
plt.show()

this example leads to the error "'ConstantPredictor' object has no attribute 'coef'". How to fix this issue?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.