Ejemplo n.º 1
0
    def load(self, path):
        """ Load the model.

        Parameters
        ----------
        path : str
            a full path to a file from which a model will be loaded
        """
        self.estimator = pickle.load(path)
Ejemplo n.º 2
0
def modelpredict(text:str):
    try:
        model = joblib.load('pipeline_lr.pkl')
        if not text.endswith('txt'):
            string = [text]
            preds = model.predict(string)[0]
            pred_prb = round(model.predict_proba(string)[:,1][0], 2)
            return f'Verbatism: {text}\n Sentiment Value: {preds}\n Sentiment score: {pred_prb}%'
        else:
            df = pd.read_csv(text, names =['sentiment'], delimiter='\t', encoding='utf-8')
            df['predictions'] = model.predict(df['sentiment'])
            score = model.predict_proba(df['sentiment'])
            sentiment_score = [i[1] for i in score]
            df['sentiment_score'] = sentiment_score
            return df
    except ValueError as e:
        return f'Value error is {e}'
Ejemplo n.º 3
0
def load_model(file_path):
    """Loads a model that was saved with joblib."""
    return joblib.load(file_path)
Ejemplo n.º 4
0
def predict():
    pred = joblib.load('JUSL_RF_model.sav')
    result = pred.predict(
        [[33, 27, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
    return result