Skip to content

Instantly share code, notes, and snippets.

View Soumi7's full-sized avatar

Soumi Bardhan Soumi7

View GitHub Profile
result, model_outputs, predictions = model.eval_model(test_df)
predictions, raw_outputs = model1.predict(["Tax Rate"])
print(predictions)
result, model_outputs, predictions = model.eval_model(test_df)
@Soumi7
Soumi7 / train.py
Created June 23, 2020 12:24
Training model for named entity recogntion
from simpletransformers.ner import NERModel
import logging
logging.basicConfig(level=logging.INFO)
transformers_logger = logging.getLogger("transformers")
transformers_logger.setLevel(logging.WARNING)
train_df = pd.DataFrame(traindata, columns=['sentence_id', 'words', 'labels'])
test_df = pd.DataFrame(testdata, columns=['sentence_id', 'words', 'labels'])
model = NERModel('bert', 'bert-base-cased',
labels=[ENTER YOUR LIST OF UNIQUE LABELS IN YOUR DATA],
@Soumi7
Soumi7 / parser.py
Created June 23, 2020 12:20
Parser
import pandas as pd
df=pd.read_csv("drive/My Drive/Data.csv")
Sentences=df['Text']
df['Labels'] = df['Unnamed: 1'].astype(str) +" "+ df['Unnamed: 2'].astype(str)+" "+ df['Unnamed: 3'].astype(str)+" "+ df['Unnamed: 4'].astype(str)+" "+ df['Unnamed: 5'].astype(str)+" "+ df['Unnamed: 6'].astype(str)+" "+ df['Unnamed: 7'].astype(str)+" "+ df['Unnamed: 8'].astype(str)+" "+ df['Unnamed: 9'].astype(str)+" "+ df['Unnamed: 10'].astype(str)+" "+ df['Unnamed: 11'].astype(str)
df=df.drop(columns=['Unnamed: 1', 'Unnamed: 2', 'Unnamed: 3', 'Unnamed: 4',
'Unnamed: 5', 'Unnamed: 6', 'Unnamed: 7', 'Unnamed: 8', 'Unnamed: 9',
'Unnamed: 10', 'Unnamed: 11'],axis=1)
Labels=df['Labels']
traindata=[]
for i in range(0,len(Sentences[:95])):
@Soumi7
Soumi7 / inference.py
Created May 26, 2020 05:24
inference file for PG stock management
from datetime import datetime , timedelta
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pycaret.regression import *
import requests
from wwo_hist import retrieve_hist_data
date=(input("enter the month and year for which you want to predict the sales of the product [EXAMPLE : 02-2020 (FEB 2020)]: "))
print("The Products are : \n ALCOHOL , BREAD , CHEMISTRY , CHEWING_GUM_LOLIPOPS \n CHIPS_FLAKES , CIGARETTES , COFFEE TEA \n DAIRY_CHESSE , DRINK_JUICE , GENERAL , GENERAL_FOOD \n GENERAL_ITEMS , GROATS_RICE_PASTA , ICE_CREAMS_FROZEN, KETCH_CONCETRATE_MUSTARD_MAJO_HORSERADISH \n OCCASIONAL , POULTRY , SPICES , SWEETS , TABLETS , VEGETABLES")
@Soumi7
Soumi7 / loading.py
Created May 26, 2020 04:31
Inference file for PG-Stock prediction
from datetime import datetime , timedelta
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pycaret.regression import *
import requests
from wwo_hist import retrieve_hist_data
date=(input("enter the month and year for which you want to predict the sales of the product [EXAMPLE : 02-2020 (FEB 2020)]: "))
print("The Products are : \n ALCOHOL , BREAD , CHEMISTRY , CHEWING_GUM_LOLIPOPS \n CHIPS_FLAKES , CIGARETTES , COFFEE TEA \n DAIRY_CHESSE , DRINK_JUICE , GENERAL , GENERAL_FOOD \n GENERAL_ITEMS , GROATS_RICE_PASTA , ICE_CREAMS_FROZEN, KETCH_CONCETRATE_MUSTARD_MAJO_HORSERADISH \n OCCASIONAL , POULTRY , SPICES , SWEETS , TABLETS , VEGETABLES")
@Soumi7
Soumi7 / app.py
Last active May 26, 2020 04:29
The app file for the PG-Stock-Prediction Web App
import numpy as np
from flask import Flask, request, jsonify, render_template
import pickle
from datetime import datetime , timedelta
import pandas as pd
import pycaret
import requests
from wwo_hist import retrieve_hist_data
from pycaret.regression import *
import matplotlib.pyplot as plt
from importlib import import_module
import os
import jsonpickle
from flask import Flask,Response , request , flash , url_for,jsonify
import logging
from logging.config import dictConfig
import numpy as np
from PIL import Image
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.image import load_img, img_to_array
@Soumi7
Soumi7 / tfinference.py
Created May 1, 2020 10:41
Inference file
import numpy as np
import cv2
import h5py
import matplotlib.pyplot as plt
from tensorflow.keras.preprocessing import image
from tensorflow.keras.models import load_model
IMG_SIZE=224
model = load_model('/home/soumi/Downloads/best1.h5')