Beispiel #1
0
def predictRouteClient():
    try:
        if request.json is not None:
            path = request.json['filepath']

            pred_val = pred_validation(path) #object initialization

            pred_val.prediction_validation() #calling the prediction_validation function

            pred = prediction(path) #object initialization

            # predicting for dataset present in database
            path = pred.predictionFromModel()
            return Response("Prediction File created at %s!!!" % path)
        elif request.form is not None:
            path = request.form['filepath']

            pred_val = pred_validation(path) #object initialization

            #pred_val.prediction_validation() #calling the prediction_validation function

            pred = prediction(path) #object initialization

            # predicting for dataset present in database
            path = pred.predictionFromModel()
            return Response("Prediction File created at %s!!!" % path)

    except ValueError:
        return Response("Error Occurred! %s" %ValueError)
    except KeyError:
        return Response("Error Occurred! %s" %KeyError)
    except Exception as e:
        return Response("Error Occurred! %s" %e)
Beispiel #2
0
def predictRouteClient():
    try:
        if request.json is not None:
            path = request.json['C:/Machine learning project/Visibility/visibility/code/7visibility_climate/Prediction_Batch_files/visibility_082019_120021.csv']

            pred_val = pred_validation(path) #object initialization

            pred_val.prediction_validation() #calling the prediction_validation function

            pred = prediction(path) #object initialization

            # predicting for dataset present in database
            path = pred.predictionFromModel()
            return Response("Prediction File created at %s!!!" % path)
        elif request.form is not None:
            path = request.form['filepath']

            pred_val = pred_validation(path) #object initialization

            pred_val.prediction_validation() #calling the prediction_validation function

            pred = prediction(path) #object initialization

            # predicting for dataset present in database
            path = pred.predictionFromModel()
            return Response("Prediction File created at %s!!!" % path)

    except ValueError:
        return Response("Error Occurred! %s" %ValueError)
    except KeyError:
        return Response("Error Occurred! %s" %KeyError)
    except Exception as e:
        return Response("Error Occurred! %s" %e)
Beispiel #3
0
def predictRouteClient():
    try:
        if request.json is not None:
            path = request.json['filepath']

            pred_val = pred_validation(path) #object initialization

            pred_val.prediction_validation() #calling the prediction_validation function

            pred = prediction(path) #object initialization

            # predicting for dataset present in database
            path,json_predictions = pred.predictionFromModel()
            return Response("Prediction File created at !!!"  +str(path) +'and few of the predictions are '+str(json.loads(json_predictions) ))
        elif request.form is not None:
            path = request.form['filepath']

            pred_val = pred_validation(path) #object initialization

            pred_val.prediction_validation() #calling the prediction_validation function

            pred = prediction(path) #object initialization

            # predicting for dataset present in database
            path,json_predictions = pred.predictionFromModel()
            return Response("Prediction File created at !!!"  +str(path) +'and few of the predictions are '+str(json.loads(json_predictions) ))
        else:
            print('Nothing Matched')
    except ValueError:
        return Response("Error Occurred! %s" %ValueError)
    except KeyError:
        return Response("Error Occurred! %s" %KeyError)
    except Exception as e:
        return Response("Error Occurred! %s" %e)
Beispiel #4
0
def predictRouteClient():
    try:
        if request.json is not None:
            path = request.json['filepath']

            pred_val = pred_validation(path)  # object initialization

            pred_val.prediction_validation(
            )  # calling the prediction_validation function

            pred = prediction(path)  # object initialization
            pred_input_data = pd.read_csv(
                "Prediction_FileFromDB/inputFile.Csv")

            # predicting for dataset present in database
            path, result = pred.predictionFromModel()
            X = pd.concat(
                [pred_input_data, pd.DataFrame(result)], axis=1, sort=False)
            print(X)
            return Response("Prediction File created at %s!!!" % path + "  " +
                            "prediction results are given below %s" %
                            X.to_html())

        elif request.form is not None:
            path = request.form['filepath']

            pred_val = pred_validation(path)  # object initialization

            pred_val.prediction_validation(
            )  # calling the prediction_validation function

            pred = prediction(path)  # object initialization
            pred_data = pd.read_csv("Prediction_FileFromDB/inputFile.Csv")
            # predicting for dataset present in database
            path, result = pred.predictionFromModel()
            X = pd.concat([pred_data, pd.DataFrame(result)],
                          axis=1,
                          sort=False)
            return Response("Prediction File created at %s!!!" % path + "   " +
                            "prediction results are given below %s" %
                            X.to_html())

    except ValueError:
        return Response("Error Occurred! %s" % ValueError)
    except KeyError:
        return Response("Error Occurred! %s" % KeyError)
    except Exception as e:
        return Response("Error Occurred! %s" % e)
Beispiel #5
0
def predictRouteClient():
    try:
        path = request.form['Default_File_Predict']

        pred_val = pred_validation(path)  # object initialization

        pred_val.prediction_validation(
        )  # calling the prediction_validation function

        pred = prediction(path)  # object initialization

        # predicting for dataset present in database
        path, json_predictions = pred.predictionFromModel()

        return render_template(
            'results.html',
            prediction=
            'Prediction has been saved at {} and few of the predictions are '.
            format(path) + ' ' + str(json.loads(json_predictions)))

    except ValueError:
        return Response("Error Occurred! %s" % ValueError)
    except KeyError:
        return Response("Error Occurred! %s" % KeyError)
    except Exception as e:
        return Response("Error Occurred! %s" % e)
Beispiel #6
0
def predictionTest(path=None):
    try:
        az_blb_mgt = AzureBlobManagement()
        execution_id = str(uuid.uuid4())
        if path is None:
            path = 'prediction-batch-files'
        else:
            path = path
        pred_val = pred_validation(path, execution_id)  # object initialization

        pred_val.prediction_validation(
        )  # calling the prediction_validation function

        pred = prediction(path, execution_id)  # object initialization

        # predicting for dataset present in database
        path, json_predictions = pred.predictionFromModel()
        prediction_location = "prediction-output-file"
        file_list = "prediction-output-file"
        #selecting all failed file name
        return Response("Prediction File created at !!!" + str(path) +
                        'and few of the predictions are ' +
                        str(json.loads(json_predictions)))

    except ValueError:
        return Response("Error Occurred! %s" % ValueError)
    except KeyError:
        return Response("Error Occurred! %s" % KeyError)
    except Exception as e:
        return Response("Error Occurred! %s" % e)
Beispiel #7
0
def predictRouteClient():
    try:
        user_input = st.text_input("Enter the name of folder containing files for prediction", "default")
        if user_input!="default":

            path=user_input

            pred_val = pred_validation(path) #object initialization


            df=pred_val.prediction_validation() #calling the prediction_validation function
            if len(df)>0:
                st.subheader("The Predicted cement strength for each input is")
                # st.write(df)

            pred = prediction(path) #object initialization

            # predicting for dataset present in database
            path,json_data,result = pred.predictionFromModel()
            if len(result)>0:
                df1=pd.concat([df,result],axis=1,ignore_index=True)
                df1.columns = list(df.columns.values) + list(result.columns.values)
                st.write(df1)
    except Exception as e:
        st.write("Error Occurred!:", e)
Beispiel #8
0
def predictRouteClient():
    try:
        if request.json is not None:  # prection file access from Postman server

            path = request.json['filepath']  # Obtained file path

            pred_val = pred_validation(path)  # object initialization

            pred_val.prediction_validation(
            )  # calling the prediction_validation function

            pred = prediction(path)  # object initialization

            path = pred.predictionFromModel(
            )  # predicting for dataset using saved model

            return Response("Prediction File created at %s!!!" %
                            path)  # Predicted file path

        elif request.form is not None:  # prection file access from Web API

            path = request.form['filepath']  # Obtained file path

            pred_val = pred_validation(path)  # object initialization

            pred_val.prediction_validation(
            )  # calling the prediction_validation function

            pred = prediction(path)  # object initialization

            path = pred.predictionFromModel(
            )  # predicting for dataset using saved model

            return Response("Prediction File created at %s!!!" %
                            path)  # Predicted file path

    except ValueError:
        return Response("Error Occurred! %s" % ValueError)
    except KeyError:
        return Response("Error Occurred! %s" % KeyError)
    except Exception as e:
        return Response("Error Occurred! %s" % e)
def predictRouteClient():
    try:
        global glbPath
        print('Within predictRouteClient, glbpath:'+glbPath)

        if request.json is not None:
            path = request.json['filepath']

            pred_val = pred_validation(path)  # object initialization

            pred_val.prediction_validation()  # calling the prediction_validation function

            pred = prediction(path)  # object initialization

            # predicting for dataset present in database
            path = pred.predictionFromModel()
            glbPath=path
            return Response("Prediction File created at %s!!!" % path)
        elif request.form is not None:
            path = request.form['filepath']
            print(path)
            pred_val = pred_validation(path)  # object initialization
            print('Post Object initialization '+path)
            pred_val.prediction_validation()  # calling the prediction_validation function
            print('Post prediction_validation function ' + path)
            pred = prediction(path)  # object initialization
            print('Post prediction object initialization ' + path)
            # predicting for dataset present in database
            path = pred.predictionFromModel()
            glbPath = path
            print("Inside prediction code:"+path)
            return Response("Prediction File created at %s!!!" % path)

    except ValueError:
        print("Error Occurred! " + str(ValueError))
        return Response("Error Occurred! %s" % str(ValueError))
    except KeyError:
        print("Error Occurred! " + str(KeyError))
        return Response("Error Occurred! %s" % KeyError)
    except Exception as e:
        print("Error Occurred! " + str(e))
        return Response("Error Occurred! %s" % e)
Beispiel #10
0
        def common_operations(path):
            pred_val = pred_validation(path)  #object initialization

            pred_val.prediction_validation(
            )  #calling the prediction_validation function

            pred = prediction(path)  #object initialization

            # predicting for dataset present in database
            path, json_predictions = pred.predictionFromModel()
            return Response("Prediction File created at !!!" + str(path) +
                            'and few of the predictions are ' +
                            str(json.loads(json_predictions)))
Beispiel #11
0
def predictRouteClient():
    try:
        if request.json is not None:
            path = request.json['filepath']
            pred_val = pred_validation(path)
            pred_val.prediction_validation()
            pred = prediction(path)
            path = pred.predictionFromModel()
            return Response("Prediction File created at %s!!!" % path)
        else:
            return Response("invalid file path")
    except ValueError:
        return Response("Error occured {}".format(ValueError))
    except KeyError:
        return Response("Error occured {}".format(KeyError))
    except Exception as e:
        return Response("Error occured {}".format(e))
Beispiel #12
0
def predictRouteClient():

    a = Azure_Functions(
        connection_string=
        "DefaultEndpointsProtocol=https;AccountName=trainingbatchfiles;AccountKey=JPHQiUP+0kPN4UlfW+jXZm9EaPg0nsSUd9MZMLnhpjmJZnO7OXiemYqM+vosRjXA8MLOTqV2fsDEAmz6tIjGFw==;EndpointSuffix=core.windows.net"
    )
    b = a.gettingcsvfile("predictionbatchfiles")
    print(b)

    trainobj = pred_validation(b)
    trainobj.prediction_validation()

    pred = prediction(b)

    json_predictions = pred.predictionFromModel()
    return Response('and few of the predictions are ' +
                    str(json.loads(json_predictions)))
Beispiel #13
0
def predictionTest(path=None):
    try:
        az_blb_mgt = AzureBlobManagement()
        execution_id = str(uuid.uuid4())
        if path is None:
            path = 'prediction-batch-files'
        else:
            path = path
        pred_val = pred_validation(path, execution_id)  # object initialization

        pred_val.prediction_validation(
        )  # calling the prediction_validation function

        pred = prediction(path, execution_id)  # object initialization

        # predicting for dataset present in database
        path, json_predictions = pred.predictionFromModel()
        prediction_location = "prediction-output-file"
        file_list = "prediction-output-file"
        #selecting all failed file name
        bad_data_archived = "lap-" + execution_id
        directory = [
            container_name.name for container_name in
            az_blb_mgt.blob_service_client.list_containers()
        ]
        for dir in directory:
            if re.search('^' + bad_data_archived, dir):
                bad_data_archived = dir

        file_names = az_blb_mgt.getAllFileNameFromDirectory(bad_data_archived)

        message = "Hi Team,\n\n We have listed file name which was failed to process due to validation"
        i = 0
        for file in file_names:
            i = i + 1
            message = message + "\n" + str(i) + ") " + file
        message = message + "\n Thanks & regards\n Avnish Yadav"
        emailSender = EmailSender()
        emailSender.sendEmail(message, "Prediction failed file")
        print(path, json_predictions)
    except Exception as e:
        print(str(e))
Beispiel #14
0
def predictRouteClient():
    try:
        if request.json['folderPath'] is not None:
            path = request.json['folderPath']

            pred_val = pred_validation(path) #object initialization

            pred_val.prediction_validation() #calling the prediction_validation function

            pred = prediction(path) #object initialization

            # predicting for dataset present in database
            path = pred.predictionFromModel()
            s3.upload_file(Filename=path, Bucket='wafer-123', Key=f'Prediction_Output_File/Predictions-{datetime.now()}.csv')
            return Response("Prediction File created at %s!!!" % path)

    except ValueError:
        return Response("Error Occurred! %s" %ValueError)
    except KeyError:
        return Response("Error Occurred! %s" %KeyError)
    except Exception as e:
        return Response("Error Occurred! %s" %e)
Beispiel #15
0
from training_Validation_Insertion import train_validation
import flask_monitoringdashboard as dashboard
from predictFromModel import prediction

os.putenv('LANG', 'en_US.UTF-8')
os.putenv('LC_ALL', 'en_US.UTF-8')

try:
    path = 'Prediction_Batch_Files'

    pred_val = pred_validation(path)  #object initialization

    pred_val.prediction_validation(
    )  #calling the prediction_validation function

    pred = prediction(path)  #object initialization

    # predicting for dataset present in database
    path = pred.predictionFromModel()
    print("Prediction File created at %s!!!" % path)

except ValueError:
    print("Error Occurred! %s" % ValueError)
except KeyError:
    print("Error Occurred! %s" % KeyError)
except Exception as e:
    print("Error Occurred! %s" % e)
"""
try:

    path = 'Training_Batch_Files'
from wsgiref import simple_server