File size: 1,582 Bytes
b1d6378
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python3
import pickle
# import numpy as np # linear algebra
# import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
# import pandas as pd
# import numpy as np
# import re
# import nltk
# from nltk.corpus import stopwords
# from nltk.stem import WordNetLemmatizer
# from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer, TfidfTransformer
# from sklearn.decomposition import LatentDirichletAllocation
# from sklearn.model_selection import train_test_split
# from sklearn.naive_bayes import MultinomialNB
# from sklearn.metrics import accuracy_score, confusion_matrix
# from sklearn.linear_model import LogisticRegression
# from sklearn.tree import DecisionTreeClassifier
# from sklearn.ensemble import RandomForestClassifier
# from sklearn.pipeline import Pipeline
# from sklearn.model_selection import GridSearchCV
# from sklearn.metrics import classification_report
file_name = 'best_model.pkl'
with open(file_name, 'rb') as file:
    model = pickle.load(file)
# ohe = joblib.load('state_ohe.pkl')
class_mapping = ['Music', 'Death', 'Environment', 'Affection']

class Profit:
      
    def __init__(self,data):
        self.data = data
        
    def predict(self):
        d_data = [data]
        predict = model.predict(d_data)[0]

        print(f"This prediction is: {class_mapping[predict-1]}\n")
                
if __name__ == "__main__":
    print("************************")
    print("Poem prediction")
    print("************************\n\n")
    data = input('Enter Poem: ')

    obj = Profit(data)
    obj.predict()