ai-venkat-r commited on
Commit
54eddc8
•
1 Parent(s): 7b0dad3

changes for uploading the model (#13)

Browse files

- tech: model deploy (84b39ace0441cfe6fc3507689ef967c9bd88096b)

LSTM_model.py CHANGED
@@ -20,7 +20,7 @@ def build_lstm_model(vocab_size, embedding_dim=64, max_len=10, lstm_units=128, d
20
  # Main function to execute the training process
21
  def main():
22
  # Path to your data file
23
- data_path = r"E:\transactify\transactify\Dataset\transaction_data.csv"
24
 
25
  # Preprocess the data
26
  sequences, labels, tokenizer, label_encoder = preprocess_data(data_path)
 
20
  # Main function to execute the training process
21
  def main():
22
  # Path to your data file
23
+ data_path = r"E:\transactify\transactify\transactify\transactify\transactify\data_set\transaction_data.csv"
24
 
25
  # Preprocess the data
26
  sequences, labels, tokenizer, label_encoder = preprocess_data(data_path)
__pycache__/data_preprocessing.cpython-312.pyc ADDED
Binary file (3.55 kB). View file
 
__pycache__/inference.cpython-312.pyc ADDED
Binary file (2.21 kB). View file
 
{Dataset → data_set}/transaction_data.csv RENAMED
File without changes
prediction.py → main.py RENAMED
@@ -1,4 +1,4 @@
1
- # prediction.py
2
  import numpy as np
3
  import pandas as pd
4
  from tensorflow.keras.models import load_model
 
1
+ # main.py
2
  import numpy as np
3
  import pandas as pd
4
  from tensorflow.keras.models import load_model
model.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tensorflow.keras.models import load_model
2
+ import joblib
3
+ from tensorflow.keras.preprocessing.sequence import pad_sequences
4
+ import numpy as np
5
+ import re
6
+
7
+ # Load the model, tokenizer, and label encoder
8
+ model = load_model("transactify.h5")
9
+ tokenizer = joblib.load("tokenizer.joblib")
10
+ label_encoder = joblib.load("label_encoder.joblib")
11
+
12
+ def clean_text(text):
13
+ text = text.lower()
14
+ text = re.sub(r"\d+", "", text)
15
+ text = re.sub(r"[^\w\s]", "", text)
16
+ return text.strip()
17
+
18
+ def predict(text):
19
+ cleaned_text = clean_text(text)
20
+ sequence = tokenizer.texts_to_sequences([cleaned_text])
21
+ padded_sequence = pad_sequences(sequence, maxlen=100)
22
+ prediction = model.predict(padded_sequence)
23
+ predicted_label = np.argmax(prediction, axis=1)
24
+ category = label_encoder.inverse_transform(predicted_label)
25
+ return {"category": category[0]}
setup.md CHANGED
@@ -47,7 +47,7 @@
47
  8. **Run the Prediction Code**:
48
  To make predictions using the trained model, type:
49
  ```bash
50
- python prediction.py
51
  ```
52
 
53
  Following these steps will set up and run the Transactify model for predicting transaction categories based on descriptions.
 
47
  8. **Run the Prediction Code**:
48
  To make predictions using the trained model, type:
49
  ```bash
50
+ python main.py
51
  ```
52
 
53
  Following these steps will set up and run the Transactify model for predicting transaction categories based on descriptions.