AI Phase 4
AI Phase 4
College Code:5113
Team Members:
D.Aakash (511321106001)
S.Chandrsekran (511321106005)
A.Dinesh (511321106010)
J.Yukendiran (511321106306)
Phase 4 submission:
Devlopment Part 2
Necessary Steps:
Step 1: Install Required Libraries
to install NLTK if you haven't already. You can do this using
pip:
pip install nltk
Step 2: Import Required Libraries
import nltk
from nltk.chat.util import Chat, reflections
Step 3: Define Chat Patterns and Responses
Create patterns and responses for your chatbot. You can customize
these based on your chatbot's purpose. For this example, we'll
create a simple chatbot that responds to greetings and questions.
# Define chat patterns and responses
patterns = [
(r'hi|hello|hey', ['Hello!', 'Hi there!']),
(r'how are you', ['I am just a chatbot, but thanks for asking!']),
(r'what is your name', ['I am a chatbot. You can call me
ChatGPT.']),
(r'bye|goodbye', ['Goodbye!', 'See you later!']),
]
# Create a chatbot using patterns and reflections
chatbot = Chat(patterns, reflections)
Step 4: Test the Chatbot
Now, you can test your chatbot by taking user input and generating
responses using the patterns and responses you defined earlier.
print("ChatGPT: Hello! I'm your chatbot. You can start a
conversation, or type 'bye' to exit.")
while True:
user_input = input("You: ")
if user_input.lower() == 'bye':
print("ChatGPT: Goodbye!")
break
response = chatbot.respond(user_input)
print("ChatGPT:", response)
Step 5: Evaluation
Evaluating the performance of a chatbot is critical to ensuring it
meets the intended goals and provides a satisfying user experience.
Several evaluation metrics can be used to assess the chatbot's
performance, including accuracy, precision, recall, and F1 score.
Moreover, user-centric metrics such as user satisfaction, response time,
and conversation coherence play a pivotal role in determining the
chatbot's success. Python libraries like NLTK, spaCy, and scikit-learn can
assist in calculating these metrics. Continuous evaluation and
improvement are essential as chatbots interact with users and adapt to
their evolving needs.
Devlopment of Chatbot:
The chatbot market is estimated to grow from USD 5.27
billion in 2023 and is likely to grow at a CAGR of 23.28% during
2023-2028 to reach USD 14.95 billion by 2028.
# Define responses
responses = {
"how are you": ["I'm just a bot, but I'm doing fine.", "I don't have
feelings, but I'm here to help!"],
def get_response(message):
message = message.lower()
if message in responses:
return random.choice(responses[message])
else:
return random.choice(responses["default"])
# Main loop
while True:
if user_input.lower() == "bye":
print("Chatbot: Goodbye!")
break
response = get_response(user_input)
print("Chatbot:", response)
SAMPLE OUTPUT FOR CHATBOT:
Conclusion:
In this pahse we started To building the project by
performing different activities like feature engineering, model training,
evaluation Compared to Previous Phases.Upcoming Phases we are
going to fully devlop it into advanced level.