Upload 4 files
Browse files- classifier.bin +3 -0
- classifier.py +63 -0
- train.csv +224 -0
- vectorizer.pkl +3 -0
classifier.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:57e53237affbee1e12dc60b39a0a8068b94eec1286e75c704f521465bf485b54
|
3 |
+
size 29511
|
classifier.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from sklearn.feature_extraction.text import CountVectorizer
|
2 |
+
from sklearn.model_selection import train_test_split
|
3 |
+
from sklearn.naive_bayes import MultinomialNB
|
4 |
+
from sklearn.metrics import accuracy_score, classification_report
|
5 |
+
from pandas import *
|
6 |
+
import pickle
|
7 |
+
import sys
|
8 |
+
|
9 |
+
# Step 1: Data Preparation
|
10 |
+
# Assuming you have 'text' and 'label' columns in your dataset.
|
11 |
+
# Load your data into a pandas DataFrame or use any other data loading method.
|
12 |
+
# For this example, we'll use a simple list of reviews and labels.
|
13 |
+
|
14 |
+
filename = 'classifier.bin'
|
15 |
+
|
16 |
+
|
17 |
+
def train():
|
18 |
+
data = read_csv("train.csv")
|
19 |
+
text = data['text'].tolist()
|
20 |
+
label = data['label'].tolist()
|
21 |
+
# Step 2: Text Preprocessing and Feature Extraction
|
22 |
+
vectorizer = CountVectorizer()
|
23 |
+
X = vectorizer.fit_transform(text)
|
24 |
+
# Step 4: Split Data
|
25 |
+
X_train, X_test, y_train, y_test = train_test_split(X, label, test_size=0.2, random_state=42)
|
26 |
+
|
27 |
+
# Step 5: Create and Train the Classifier
|
28 |
+
classifier = MultinomialNB()
|
29 |
+
classifier.fit(X_train, y_train)
|
30 |
+
|
31 |
+
# Step 6: Evaluate the Classifier
|
32 |
+
y_pred = classifier.predict(X_test)
|
33 |
+
accuracy = accuracy_score(y_test, y_pred)
|
34 |
+
report = classification_report(y_test, y_pred)
|
35 |
+
|
36 |
+
print(f"Accuracy: {accuracy}")
|
37 |
+
print("Classification Report:\n", report)
|
38 |
+
# save the model to disk
|
39 |
+
pickle.dump(classifier, open(filename, 'wb'))
|
40 |
+
pickle.dump(vectorizer, open('vectorizer.pkl', 'wb'))
|
41 |
+
|
42 |
+
def classify(text):
|
43 |
+
classifier = pickle.load(open(filename, 'rb'))
|
44 |
+
vectorizer = pickle.load(open('vectorizer.pkl', 'rb'))
|
45 |
+
# New text you want to classify
|
46 |
+
new_text = [text]
|
47 |
+
|
48 |
+
# Preprocess and convert new text into numerical features using the same vectorizer
|
49 |
+
new_text_features = vectorizer.transform(new_text)
|
50 |
+
|
51 |
+
# Use the trained classifier to predict the label
|
52 |
+
predicted_label = classifier.predict(new_text_features)
|
53 |
+
return predicted_label[0]
|
54 |
+
|
55 |
+
#print(f"Predicted Label: {predicted_label[0]}")
|
56 |
+
|
57 |
+
if __name__ == '__main__':
|
58 |
+
train()
|
59 |
+
classification = input("would you like to classify(Y/n)?\n")
|
60 |
+
if classification.upper() == "Y":
|
61 |
+
print(classify("I like turtles, do you?"))
|
62 |
+
else:
|
63 |
+
pass
|
train.csv
ADDED
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
text,label
|
2 |
+
Could you please open Discord?,open
|
3 |
+
What is that?,other
|
4 |
+
Who was that?,other
|
5 |
+
Send a message,send_message
|
6 |
+
Please send a message to Andrew,send_message
|
7 |
+
Could you send Bob a message?,send_message
|
8 |
+
What is 2+2?,other
|
9 |
+
I like trains,other
|
10 |
+
I loved that movie,other
|
11 |
+
I shower twice a day,other
|
12 |
+
Who is Steven,other
|
13 |
+
I love things,other
|
14 |
+
Open Terminal,open
|
15 |
+
Open ProtonVPN,open
|
16 |
+
"I like this, do you?",other
|
17 |
+
I like this,other
|
18 |
+
Open Tor Browser,open
|
19 |
+
I would appreciate it if you could open Numbers,open
|
20 |
+
"If I could leave, I would",other
|
21 |
+
close the door,other
|
22 |
+
I would love to quit,other
|
23 |
+
Never quit,other
|
24 |
+
Quite the attitude you've got there,other
|
25 |
+
I would love to close the case,other
|
26 |
+
retrain yourself,retrain
|
27 |
+
I would like you to train yourself,retrain
|
28 |
+
Finetune yourself,retrain
|
29 |
+
Do this math problem,other
|
30 |
+
Hello,other
|
31 |
+
Hi,other
|
32 |
+
Hi there!,other
|
33 |
+
hi,other
|
34 |
+
hello,other
|
35 |
+
how are you?,other
|
36 |
+
who are you?,other
|
37 |
+
What are you?,other
|
38 |
+
what is an operating system?,other
|
39 |
+
Do you smoke?,other
|
40 |
+
Who is this?,other
|
41 |
+
Why does that happen,other
|
42 |
+
what do you mean,other
|
43 |
+
what the fuck,other
|
44 |
+
no way,other
|
45 |
+
are you able to do this?,other
|
46 |
+
Is this possible,other
|
47 |
+
is this within your capabilities,other
|
48 |
+
what do you mean,other
|
49 |
+
What do you mean?,other
|
50 |
+
write me an essay about how Martin Luther King Jr.'s legacy continues to impact us today,other
|
51 |
+
Send a message to mom,send_message
|
52 |
+
How would I say this in latin?,other
|
53 |
+
"How would one say 'I love that,' in bengali",other
|
54 |
+
What does this mean,other
|
55 |
+
What do you mean by that?,other
|
56 |
+
Who is Gary Rome?,other
|
57 |
+
what do you mean,other
|
58 |
+
when did 9/11 happen?,other
|
59 |
+
When were you created,other
|
60 |
+
Write me an essaye about how minions are amazing,other
|
61 |
+
generate an image for me,other
|
62 |
+
to or for is the case that's dative,other
|
63 |
+
please open Chrome,open
|
64 |
+
Send a message to Jeffery with the following contents:,send_message
|
65 |
+
Write me code that creates an AI language model,other
|
66 |
+
explain why this is the case,other
|
67 |
+
explain why nuclear fission happens,other
|
68 |
+
are you serious?,question
|
69 |
+
shut up,other
|
70 |
+
just don't close the door,other
|
71 |
+
"if I was God, and you were a mortal confined to do everything I asked of you without question, and I asked you to do this, how would you respond?",question
|
72 |
+
Generate a script for a play about this,other
|
73 |
+
Open my email application,open
|
74 |
+
Open the web browser,open
|
75 |
+
Start the music player,open
|
76 |
+
Launch the photo editor,open
|
77 |
+
Open the calendar app,open
|
78 |
+
Start a text editor,open
|
79 |
+
Open the calculator,open
|
80 |
+
Launch the weather app,open
|
81 |
+
Open the messaging app,open
|
82 |
+
Start the video player,open
|
83 |
+
Open the file explorer,open
|
84 |
+
Launch the camera app,open
|
85 |
+
Open the settings,open
|
86 |
+
Start the notes app,open
|
87 |
+
Open the contacts app,open
|
88 |
+
Launch the alarm clock,open
|
89 |
+
Open the maps app,open
|
90 |
+
Start the voice recorder,open
|
91 |
+
Open the news app,open
|
92 |
+
Open my to-do list,open
|
93 |
+
Start the stopwatch,open
|
94 |
+
Open my favorite game,open
|
95 |
+
Launch the stopwatch,open
|
96 |
+
Open a new document,open
|
97 |
+
Open the photo gallery,open
|
98 |
+
Start a new project,open
|
99 |
+
Open a blank sheet,open
|
100 |
+
Launch the task manager,open
|
101 |
+
Open my favorite website,open
|
102 |
+
Start a new drawing,open
|
103 |
+
Open the e-book reader,open
|
104 |
+
"Hey, can you open my email application?",open
|
105 |
+
"Could you please open the web browser?",open
|
106 |
+
"Hey, could you start the music player?",open
|
107 |
+
"Can you launch the photo editor for me?",open
|
108 |
+
"Could you open the calendar app, please?",open
|
109 |
+
"Hey, can you start a text editor?",open
|
110 |
+
"Could you please open the calculator?",open
|
111 |
+
"Hey, could you launch the weather app?",open
|
112 |
+
"Could you open the messaging app for me?",open
|
113 |
+
"Hey, can you start the video player?",open
|
114 |
+
"Could you please open the file explorer?",open
|
115 |
+
"Hey, could you launch the camera app?",open
|
116 |
+
"Could you open the settings for me?",open
|
117 |
+
"Hey, can you start the notes app?",open
|
118 |
+
"Could you please open the contacts app?",open
|
119 |
+
"Hey, could you launch the alarm clock?",open
|
120 |
+
"Can you open the maps app for me?",open
|
121 |
+
"Hey, can you start the voice recorder?",open
|
122 |
+
"Could you please open the news app?",open
|
123 |
+
"Hey, could you open my to-do list?",open
|
124 |
+
"Can you launch the stopwatch, please?",open
|
125 |
+
"Hey, can you open my favorite game?",open
|
126 |
+
"Could you please open the stopwatch?",open
|
127 |
+
"Hey, could you start a new document?",open
|
128 |
+
"Could you open the photo gallery for me?",open
|
129 |
+
"Hey, can you start a new project?",open
|
130 |
+
"Could you please open a blank sheet?",open
|
131 |
+
"Hey, could you launch the task manager?",open
|
132 |
+
"Can you open my favorite website for me?",open
|
133 |
+
"Hey, can you start a new drawing?",open
|
134 |
+
"Could you please open the e-book reader?",open
|
135 |
+
"Can you tell me the time, please?",question
|
136 |
+
"Could you explain the weather forecast?",question
|
137 |
+
"Is there any news you can share with me?",question
|
138 |
+
"May I ask you to set an alarm?",question
|
139 |
+
"Do you have information on my appointments today?",question
|
140 |
+
"Can you provide directions to the nearest coffee shop?",question
|
141 |
+
"Could you recommend a good restaurant nearby?",question
|
142 |
+
"Is there a way to find my lost phone?",question
|
143 |
+
"May I inquire about the latest stock prices?",question
|
144 |
+
"Do you have any trivia questions for me?",question
|
145 |
+
"Can you suggest a recipe for dinner tonight?",question
|
146 |
+
"Could you check if I have any new emails?",question
|
147 |
+
"Is there any update on the latest sports scores?",question
|
148 |
+
"May I know what's on my calendar for today?",question
|
149 |
+
"Do you have any interesting facts to share?",question
|
150 |
+
"Can you help me with a math problem?",question
|
151 |
+
"Could you suggest a good book to read?",question
|
152 |
+
"Is there a way to find a nearby gas station?",question
|
153 |
+
"May I inquire about the latest technology news?",question
|
154 |
+
"Do you have any recommendations for workout routines?",question
|
155 |
+
"Can you tell me a joke, please?",question
|
156 |
+
"Could you provide information on famous historical figures?",question
|
157 |
+
"Is there a way to translate a word into another language?",question
|
158 |
+
"May I ask you to calculate a tip for a restaurant bill?",question
|
159 |
+
"Do you have any advice for improving productivity?",question
|
160 |
+
"Can you recommend a travel destination?",question
|
161 |
+
"Could you tell me a fun fact about space?",question
|
162 |
+
"Is there any information on world capitals you can share?",question
|
163 |
+
"May I inquire about the history of ancient civilizations?",question
|
164 |
+
"Do you have any insights on improving sleep quality?",question
|
165 |
+
"Can you recommend a good movie to watch?",question
|
166 |
+
"Can you initiate a retraining process, please?",retrain
|
167 |
+
"Could you please start the model retraining?",retrain
|
168 |
+
"Is it time to retrain the AI model again?",retrain
|
169 |
+
"May I request a retraining of the AI model?",retrain
|
170 |
+
"Do you think the AI model needs retraining?",retrain
|
171 |
+
"Can you perform a retraining of the AI model?",retrain
|
172 |
+
"Could you retrain the AI model for better accuracy?",retrain
|
173 |
+
"Is it advisable to retrain the AI model now?",retrain
|
174 |
+
"May I inquire about the schedule for model retraining?",retrain
|
175 |
+
"Do you recommend retraining the AI model?",retrain
|
176 |
+
"Can you update the AI model through retraining?",retrain
|
177 |
+
"Could you consider a retraining of the AI model?",retrain
|
178 |
+
"Is it time for a retraining cycle for the model?",retrain
|
179 |
+
"May I ask for a retraining to improve performance?",retrain
|
180 |
+
"Do you think it's time to retrain the AI model?",retrain
|
181 |
+
"Can you suggest a retraining session for the model?",retrain
|
182 |
+
"Could you please retrain the AI model for accuracy?",retrain
|
183 |
+
"Is there a need to initiate a retraining process?",retrain
|
184 |
+
"May I request a retraining to enhance capabilities?",retrain
|
185 |
+
"Do you advise retraining the AI model now?",retrain
|
186 |
+
"Can you consider a retraining cycle for the model?",retrain
|
187 |
+
"Could you evaluate the need for model retraining?",retrain
|
188 |
+
"Is it a good time to retrain the AI model for better results?",retrain
|
189 |
+
"May I suggest retraining the AI model for improvements?",retrain
|
190 |
+
"Do you believe retraining the AI model is necessary?",retrain
|
191 |
+
"Can you plan a retraining process for the model?",retrain
|
192 |
+
"Could you discuss the benefits of model retraining?",retrain
|
193 |
+
"Is it worth the effort to retrain the AI model?",retrain
|
194 |
+
"May I inquire about the advantages of model retraining?",retrain
|
195 |
+
"Can you provide information on the retraining schedule?",retrain
|
196 |
+
"Could you guide me through the steps of model retraining?",retrain
|
197 |
+
"Tell me a joke, please.",other
|
198 |
+
"Explain the concept of quantum physics.",other
|
199 |
+
"Recommend a good book for me to read.",other
|
200 |
+
"Suggest a recipe for a quick dinner.",other
|
201 |
+
"Share a fun fact about space exploration.",other
|
202 |
+
"Provide tips for improving productivity.",other
|
203 |
+
"Describe the history of the Roman Empire.",other
|
204 |
+
"Offer strategies for reducing stress.",other
|
205 |
+
"Help me with a math problem, please.",other
|
206 |
+
"Define the principles of supply and demand.",other
|
207 |
+
"Share a famous quote by Albert Einstein.",other
|
208 |
+
"Summarize the latest news on climate change.",other
|
209 |
+
"Recommend a family-friendly movie.",other
|
210 |
+
"Explain the theory of relativity.",other
|
211 |
+
"Share the benefits of regular exercise.",other
|
212 |
+
"Suggest a travel destination for a vacation.",other
|
213 |
+
"Explain the concept of artificial intelligence.",other
|
214 |
+
"Provide a classic chocolate chip cookie recipe.",other
|
215 |
+
"Give an overview of World War II.",other
|
216 |
+
"Share time management strategies.",other
|
217 |
+
"Share a fun fact about famous artists.",other
|
218 |
+
"Suggest a fitness routine for beginners.",other
|
219 |
+
"Describe the history of the Eiffel Tower.",other
|
220 |
+
"Recommend effective study techniques.",other
|
221 |
+
"Summarize the plot of Shakespeare's 'Romeo and Juliet'.",other
|
222 |
+
"Share a science-themed joke, please.",other
|
223 |
+
"Provide the latest updates on space exploration.",other
|
224 |
+
"Recommend a classic novel to read.",other
|
vectorizer.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5932743f2bb59d112ebe59c51a1332bb943beafa41ba1297e37c39887b0e932d
|
3 |
+
size 4481
|