Пример #1
0
def _run_classification_and_evaluation(
        database_class: DataBase, classifier: str,
        is_classifier_bootstrap: bool, **kwargs: dict) -> DataBase:
    """
    Runs active learning classification and evaluation methods

    Parameters
    ----------
    database_class
        An instance of DataBase class
    classifier
        Machine Learning algorithm.
        Currently 'RandomForest', 'GradientBoostedTrees',
        'KNN', 'MLP', 'SVM' and 'NB' are implemented.
        Default is 'RandomForest'.
    is_classifier_bootstrap
        if tp apply a machine learning classifier by bootstrapping
    kwargs
       All keywords required by the classifier function.
    """
    if is_classifier_bootstrap:
        database_class.classify_bootstrap(method=classifier, **kwargs)
    else:
        database_class.classify(method=classifier, **kwargs)
    database_class.evaluate_classification()
    return database_class
Пример #2
0
def run_classification(database_class: DataBase, classifier: str,
                       is_classifier_bootstrap: bool, prediction_dir: str,
                       is_save_prediction: bool, iteration_step: int,
                       **kwargs: dict) -> DataBase:
    """
    Run active learning classification model

    Parameters
    ----------
    database_class
        An instance of DataBase class
    classifier
        Machine Learning algorithm.
        Currently implemented options are 'RandomForest', 'GradientBoostedTrees',
        'KNNclassifier','MLPclassifier','SVMclassifier' and 'NBclassifier'.
        Default is 'RandomForest'.
    is_classifier_bootstrap
        if tp apply a machine learning classifier by bootstrapping
    prediction_dir
       Output directory to store prediction file for each loop.
       Only used if `save_predictions==True
    is_save_prediction
        if predictions should be saved
    iteration_step
        active learning iteration number
    kwargs
       All keywords required by the classifier function.
    -------

    """
    if is_classifier_bootstrap:
        database_class.classify_bootstrap(method=classifier,
                                          loop=iteration_step,
                                          pred_dir=prediction_dir,
                                          save_predictions=is_save_prediction,
                                          **kwargs)
    else:
        database_class.classify(method=classifier,
                                pred_dir=prediction_dir,
                                loop=iteration_step,
                                save_predictions=is_save_prediction,
                                **kwargs)
    return database_class