Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make multiclass classification using exercise two ? #24

Open
maxihidara opened this issue Nov 12, 2018 · 0 comments
Open

How to make multiclass classification using exercise two ? #24

maxihidara opened this issue Nov 12, 2018 · 0 comments

Comments

@maxihidara
Copy link

Hi, i am getting confuse, when i try to make multiclass classification using exercise two. How to make multiclass classification using binary classifier. Can i just add class, and feature_matrix in this code ?

def train_classifier(feature_matrix_0, feature_matrix_1, algorithm='SVM'):
"""Train a binary classifier.

Train a binary classifier. First perform Z-score normalization, then
fit

Args:
    feature_matrix_0 (numpy.ndarray): array of shape (n_samples,
        n_features) with examples for Class 0
    feature_matrix_0 (numpy.ndarray): array of shape (n_samples,
        n_features) with examples for Class 1
    alg (str): Type of classifer to use. Currently only SVM is
        supported.

Returns:
    (sklearn object): trained classifier (scikit object)
    (numpy.ndarray): normalization mean
    (numpy.ndarray): normalization standard deviation
"""
# Create vector Y (class labels)
class0 = np.zeros((feature_matrix_0.shape[0], 1))
class1 = np.ones((feature_matrix_1.shape[0], 1))

# Concatenate feature matrices and their respective labels
y = np.concatenate((class0, class1), axis=0)
features_all = np.concatenate((feature_matrix_0, feature_matrix_1),
                              axis=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant