コード例 #1
0
def save_model_file(results, save_to_s3):
    """
    Saves a machine learning model to file or uploads to S3 as needed
    results - Dictionary of results from ML
    save_to_s3 - Boolean indicating whether or not to upload results
    """
    success = False
    if save_to_s3:
        pickled_model = ml_grading_util.get_pickle_data(
            results['prompt'], results['feature_ext'], results['classifier'],
            results['text'], results['score'])
        success, s3_public_url = ml_grading_util.upload_to_s3(
            pickled_model, results['relative_model_path'],
            str(settings.S3_BUCKETNAME))

    try:
        ml_grading_util.dump_model_to_file(results['prompt'],
                                           results['feature_ext'],
                                           results['classifier'],
                                           results['text'], results['score'],
                                           results['model_path'])
        if success:
            return True, s3_public_url
        else:
            return True, "Saved model to file."
    except:
        return False, "Could not save model."
コード例 #2
0
ファイル: ml_model_creation.py プロジェクト: qimi2008/edx-ora
def save_model_file(results, save_to_s3):
    success=False
    if save_to_s3:
        pickled_model=ml_grading_util.get_pickle_data(results['prompt'], results['feature_ext'],
            results['classifier'], results['text'],
            results['score'])
        success, s3_public_url=ml_grading_util.upload_to_s3(pickled_model, results['relative_model_path'], str(settings.S3_BUCKETNAME))

    try:
        ml_grading_util.dump_model_to_file(results['prompt'], results['feature_ext'],
            results['classifier'], results['text'],results['score'],results['model_path'])
        if success:
            return True, s3_public_url
        else:
            return True, "Saved model to file."
    except:
        return False, "Could not save model."
コード例 #3
0
ファイル: ml_model_creation.py プロジェクト: sokratik/edx-ora
def save_model_file(results, save_to_s3):
    success=False
    if save_to_s3:
        pickled_model=ml_grading_util.get_pickle_data(results['prompt'], results['feature_ext'],
            results['classifier'], results['text'],
            results['score'])
        success, s3_public_url=ml_grading_util.upload_to_s3(pickled_model, results['relative_model_path'], str(settings.S3_BUCKETNAME))

    try:
        ml_grading_util.dump_model_to_file(results['prompt'], results['feature_ext'],
            results['classifier'], results['text'],results['score'],results['model_path'])
        if success:
            return True, s3_public_url
        else:
            return True, "Saved model to file."
    except Exception:
        return False, "Could not save model."
コード例 #4
0
def save_model_file(results, save_to_s3):
    """
    Saves a machine learning model to file or uploads to S3 as needed
    results - Dictionary of results from ML
    save_to_s3 - Boolean indicating whether or not to upload results
    """
    success=False
    if save_to_s3:
        pickled_model=ml_grading_util.get_pickle_data(results['prompt'], results['feature_ext'],
            results['classifier'], results['text'],
            results['score'])
        success, s3_public_url=ml_grading_util.upload_to_s3(pickled_model, results['relative_model_path'], str(settings.S3_BUCKETNAME))

    try:
        ml_grading_util.dump_model_to_file(results['prompt'], results['feature_ext'],
            results['classifier'], results['text'],results['score'],results['model_path'])
        if success:
            return True, s3_public_url
        else:
            return True, "Saved model to file."
    except:
        return False, "Could not save model."