<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def model_fit(X_train, y_train, svm_hardness, fit_intercept, number_of_threads, classifier_type="LinearSVC"):
 """ Fits a Linear Support Vector Classifier to the labelled graph-based features using the LIBLINEAR library. One-vs-All: http://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsRestClassifier.html LinearSVC: http://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html Inputs: - feature_matrix: The graph based-features in either NumPy or SciPy sparse array format. - node_label_matrix: The node-label ground truth in a SciPy sparse matrix format. - svm_hardness: Penalty of the error term. - fit_intercept: Data centering as per scikit-learn. - number_of_threads: The number of threads to use for training the multi-label scheme. - classifier_type: A string to be chosen among: * LinearSVC (LibLinear) * LogisticRegression (LibLinear) * RandomForest Output: - model: A trained scikit-learn One-vs-All multi-label scheme of linear SVC models. """

    if classifier_type == "LinearSVC":
        if X_train.shape[0] > X_train.shape[1]:
            dual = False
        else:
            dual = True

        model = OneVsRestClassifier(LinearSVC(C=svm_hardness, random_state=0, dual=dual,
                                              fit_intercept=fit_intercept),
                                    n_jobs=number_of_threads)
        model.fit(X_train, y_train)
    elif classifier_type == "LogisticRegression":
        if X_train.shape[0] > X_train.shape[1]:
            dual = False
        else:
            dual = True

        model = OneVsRestClassifier(LogisticRegression(C=svm_hardness, random_state=0, dual=dual,
                                                       fit_intercept=fit_intercept),
                                    n_jobs=number_of_threads)
        model.fit(X_train, y_train)
    elif classifier_type == "RandomForest":
        model = OneVsRestClassifier(RandomForestClassifier(n_estimators=1000, criterion="gini",
                                                           n_jobs=number_of_threads, random_state=0))
        if issparse(X_train):
            model.fit(X_train.tocsc(), y_train.toarray())
        else:
            model.fit(X_train, y_train.toarray())
    else:
        print("Invalid classifier type.")
        raise RuntimeError

    return model