# The optimal cross validation values should be found from the csv file
    try:
        with open(gridsearchcv_file_name, "r") as csvfile:
            reader = csv.reader(csvfile)
            for record in reader:
                if feature_scaling == str(record[0]) and \
                                feature_selection == (record[1]=="True") and \
                                clf_id == int(record[2]):
                    run_grid = json_loads_byteified(record[3])
                    print "Fetched best GridSearchCV values: ", run_grid
    except:
        print "Could not read grid filename: ", gridsearchcv_file_name
        print "Defaulting to parameter standard settings"
    # Check if we do have now parameters for our algorithm and set them
    if len(run_grid) > 0:
        algorithm.set_params(**run_grid)
    # Just use the standard algorithm
    wrapped_algorithm = algorithm
elif gridsearchcv == "out":
    # The optimal grid search values should be found and written (later)
    # to the CSV file
    wrapped_algorithm = GridSearchCV(algorithm, search_grid,
                                     scoring='precision')

pipe.extend([('Algorithm',wrapped_algorithm)])

# Put all the pipeline steps into an pipeline object and assign to "clf" for
# further processing and later on, serialization
clf = Pipeline(steps=pipe)

# ------------