changes for uploading the model (#13)
Browse files- tech: model deploy (84b39ace0441cfe6fc3507689ef967c9bd88096b)
Files changed (7)
19 unmodified lines2021222324252619 unmodified lines# Main function to execute the training processdef main():# Path to your data filedata_path = r"E:\transactify\transactify\Dataset\transaction_data.csv"# Preprocess the datasequences, labels, tokenizer, label_encoder = preprocess_data(data_path)19 unmodified lines2021222324252619 unmodified lines# Main function to execute the training processdef main():# Path to your data filedata_path = r"E:\transactify\transactify\transactify\transactify\transactify\data_set\transaction_data.csv"# Preprocess the datasequences, labels, tokenizer, label_encoder = preprocess_data(data_path)
1234# prediction.pyimport numpy as npimport pandas as pdfrom tensorflow.keras.models import load_model1234# main.pyimport numpy as npimport pandas as pdfrom tensorflow.keras.models import load_model
12345678910111213141516171819202122232425from tensorflow.keras.models import load_modelimport joblibfrom tensorflow.keras.preprocessing.sequence import pad_sequencesimport numpy as npimport re
# Load the model, tokenizer, and label encodermodel = load_model("transactify.h5")tokenizer = joblib.load("tokenizer.joblib")label_encoder = joblib.load("label_encoder.joblib")
def clean_text(text): text = text.lower() text = re.sub(r"\d+", "", text) text = re.sub(r"[^\w\s]", "", text) return text.strip()
def predict(text): cleaned_text = clean_text(text) sequence = tokenizer.texts_to_sequences([cleaned_text]) padded_sequence = pad_sequences(sequence, maxlen=100) prediction = model.predict(padded_sequence) predicted_label = np.argmax(prediction, axis=1) category = label_encoder.inverse_transform(predicted_label) return {"category": category[0]}46 unmodified lines4748495051525346 unmodified lines8. **Run the Prediction Code**:To make predictions using the trained model, type:```bashpython prediction.py```Following these steps will set up and run the Transactify model for predicting transaction categories based on descriptions.46 unmodified lines4748495051525346 unmodified lines8. **Run the Prediction Code**:To make predictions using the trained model, type:```bashpython main.py```Following these steps will set up and run the Transactify model for predicting transaction categories based on descriptions.
LSTM_model.py+1-1
__pycache__/data_preprocessing.cpython-312.pycAdded
__pycache__/inference.cpython-312.pycAdded
Dataset/transaction_data.csv → data_set/transaction_data.csvRenamed
prediction.py → main.pyRenamed+1-1
model.pyAdded+25
setup.md+1-1