Python Forum

Full Version: Applying Multi-Class Classification instead of binary classification
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I working on machine learning classification problem for logistic regression with 2 classes (walking and sitting).
I am trying to change it to Multi-Class Classification with six activities (classes) (walking, walkingupstairs, walkingdownstairs, sitting, standing, lying) instead of binary classification.


the ML model is defined in the following two classes

def set_weights(intercept, coef, classes, model=linear_model.SGDClassifier()):
    model.intercept_ = intercept
    model.coef_ = coef
    model.classes_ = classes
    return model
def train_model(intercept_init, coef_init, X, y, epochs, lr, batch_size=None, randomise=True):
    if batch_size is None or batch_size <= 0:
        batch_size = X.shape[0]
    classes = np.unique(y)
    model = linear_model.SGDClassifier(loss='log', learning_rate='constant', eta0=lr, verbose=0)
    set_weights(intercept_init, coef_init, classes, model)
    batch_train(model, X, y, classes, epochs, batch_size, randomise)
    return model
Please let me know how to make it work for multi-class ?
Any suggestion ???