awaisrwp commited on
Commit
b1d6378
1 Parent(s): 01a8718

Uploaded all files

Browse files
Files changed (4) hide show
  1. Dockerfile +18 -0
  2. best_model.pkl +3 -0
  3. predict.py +46 -0
  4. requirements.txt +6 -0
Dockerfile ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FROM centos:latest
2
+ # Use the official Python base image with version 3.9
3
+ FROM python:3.9
4
+
5
+ WORKDIR /poem_classifier
6
+
7
+ # Copy the requirements file to the container
8
+ COPY requirements.txt .
9
+
10
+ # Install the dependencies
11
+ RUN pip install -r requirements.txt
12
+
13
+ # Copy the application code to the container
14
+ COPY . .
15
+ # ENTRYPOINT ["./predict.py"]
16
+
17
+ # Set the command to run the application
18
+ CMD ["python", "predict.py"]
best_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0444cb1014afab6ba7c00849d430d950e4273fe6e92e6638590a98982f4b9bfe
3
+ size 953531
predict.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/python3
2
+ import pickle
3
+ # import numpy as np # linear algebra
4
+ # import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
5
+ # import pandas as pd
6
+ # import numpy as np
7
+ # import re
8
+ # import nltk
9
+ # from nltk.corpus import stopwords
10
+ # from nltk.stem import WordNetLemmatizer
11
+ # from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer, TfidfTransformer
12
+ # from sklearn.decomposition import LatentDirichletAllocation
13
+ # from sklearn.model_selection import train_test_split
14
+ # from sklearn.naive_bayes import MultinomialNB
15
+ # from sklearn.metrics import accuracy_score, confusion_matrix
16
+ # from sklearn.linear_model import LogisticRegression
17
+ # from sklearn.tree import DecisionTreeClassifier
18
+ # from sklearn.ensemble import RandomForestClassifier
19
+ # from sklearn.pipeline import Pipeline
20
+ # from sklearn.model_selection import GridSearchCV
21
+ # from sklearn.metrics import classification_report
22
+ file_name = 'best_model.pkl'
23
+ with open(file_name, 'rb') as file:
24
+ model = pickle.load(file)
25
+ # ohe = joblib.load('state_ohe.pkl')
26
+ class_mapping = ['Music', 'Death', 'Environment', 'Affection']
27
+
28
+ class Profit:
29
+
30
+ def __init__(self,data):
31
+ self.data = data
32
+
33
+ def predict(self):
34
+ d_data = [data]
35
+ predict = model.predict(d_data)[0]
36
+
37
+ print(f"This prediction is: {class_mapping[predict-1]}\n")
38
+
39
+ if __name__ == "__main__":
40
+ print("************************")
41
+ print("Poem prediction")
42
+ print("************************\n\n")
43
+ data = input('Enter Poem: ')
44
+
45
+ obj = Profit(data)
46
+ obj.predict()
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ pandas==2.0.2
2
+ numpy==1.24.3
3
+ nltk==3.8.1
4
+ scikit-learn==1.3.0
5
+ cloudpickle==2.2.1
6
+ pickleshare==0.7.5