Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Airline Dataset
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dhruvang Patel
Airline Dataset
Commits
0c40ab95
Commit
0c40ab95
authored
2 months ago
by
jevin3107
Browse files
Options
Downloads
Patches
Plain Diff
Main Streamlit app file
parent
d0d528e0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app.py
+72
-33
72 additions, 33 deletions
app.py
bot_image.png
+0
-0
0 additions, 0 deletions
bot_image.png
with
72 additions
and
33 deletions
app.py
+
72
−
33
View file @
0c40ab95
import
pandas
as
pd
import
streamlit
as
st
from
rasa.core.agent
import
Agent
from
rasa.core.tracker_store
import
InMemoryTrackerStore
import
matplotlib.pyplot
as
plt
# Load the dataset
df
=
pd
.
read_csv
(
'
FakeDataset.csv
'
)
df
=
pd
.
read_csv
(
"
FakeDataset.csv
"
)
# Initialize Streamlit
st
.
title
(
"
Airline Chatbot
"
)
# Load an image for display
#st.image("bot_image.png", caption="Welcome to the Airline Chatbot")
# Greet the user
if
"
greeted
"
not
in
st
.
session_state
:
st
.
session_state
.
greeted
=
False
if
not
st
.
session_state
.
greeted
:
st
.
write
(
"
Hello! I am here to assist you with flight details.
"
)
st
.
session_state
.
greeted
=
True
# Get user inputs
passenger_id
=
st
.
text_input
(
"
Please enter your Passenger ID:
"
)
# Respond to the query
if
st
.
button
(
"
Get Flight Details
"
):
if
passenger_id
:
result
=
df
[
df
.
applymap
(
lambda
x
:
passenger_id
.
lower
()
in
str
(
x
).
lower
()
if
pd
.
notnull
(
x
)
else
False
).
any
(
axis
=
1
)]
if
not
result
.
empty
:
st
.
write
(
"
Here are your flight details:
"
)
st
.
dataframe
(
result
)
st
.
title
(
"
Airline Chatbot & Data Explorer
"
)
#Adding the Bot image
st
.
image
(
"
Chatbot_image.jpg
"
,
caption
=
"
Welcome to the Airline Chatbot & Data Explorer!
"
,
use_container_width
=
True
)
# Add navigation
menu
=
st
.
sidebar
.
selectbox
(
"
Select a Feature
"
,
[
"
Chatbot
"
,
"
Data Explorer
"
,
"
Visualizations
"
])
if
menu
==
"
Chatbot
"
:
# Chatbot Section
st
.
subheader
(
"
Chat with Airline Assistant
"
)
if
"
greeted
"
not
in
st
.
session_state
:
st
.
session_state
.
greeted
=
False
if
not
st
.
session_state
.
greeted
:
st
.
write
(
"
Hello! I am here to assist you with flight details.
"
)
st
.
session_state
.
greeted
=
True
passenger_id
=
st
.
text_input
(
"
Please enter your Passenger ID:
"
)
if
st
.
button
(
"
Get Flight Details
"
):
if
passenger_id
:
result
=
df
[
df
.
applymap
(
lambda
x
:
passenger_id
.
lower
()
in
str
(
x
).
lower
()
if
pd
.
notnull
(
x
)
else
False
).
any
(
axis
=
1
)]
if
not
result
.
empty
:
st
.
write
(
"
Here are your flight details:
"
)
st
.
dataframe
(
result
)
else
:
st
.
write
(
"
No details found for the given information. Please try again.
"
)
else
:
st
.
write
(
"
No details found for the given information. Please try again.
"
)
else
:
st
.
write
(
"
Please provide all the required details.
"
)
# Goodbye message
user_message
=
st
.
text_input
(
"
Anything else you
'
d like to know?
"
)
if
user_message
.
lower
()
in
[
"
good
"
,
"
thank you
"
,
"
bye
"
]:
st
.
write
(
"
Happy to assist you!
"
)
st
.
write
(
"
Please provide all the required details.
"
)
user_message
=
st
.
text_input
(
"
Anything else you
'
d like to know?
"
)
if
user_message
.
lower
()
in
[
"
good
"
,
"
thank you
"
,
"
bye
"
]:
st
.
write
(
"
Happy to assist you!
"
)
elif
menu
==
"
Data Explorer
"
:
# Data Explorer Section
st
.
subheader
(
"
Explore the Airline Dataset
"
)
# Display dataset columns
columns
=
st
.
multiselect
(
"
Select columns to view:
"
,
options
=
df
.
columns
.
tolist
(),
default
=
df
.
columns
.
tolist
())
st
.
dataframe
(
df
[
columns
])
# Filter by Flight Status
flight_status
=
st
.
selectbox
(
"
Filter by Flight Status:
"
,
options
=
[
"
All
"
]
+
df
[
"
Flight Status
"
].
unique
().
tolist
())
if
flight_status
!=
"
All
"
:
st
.
dataframe
(
df
[
df
[
"
Flight Status
"
]
==
flight_status
])
elif
menu
==
"
Visualizations
"
:
# Visualizations Section
st
.
subheader
(
"
Visualize the Data
"
)
# Bar chart for flight statuses
st
.
write
(
"
Flight Status Distribution
"
)
status_counts
=
df
[
"
Flight Status
"
].
value_counts
()
fig
,
ax
=
plt
.
subplots
()
status_counts
.
plot
(
kind
=
"
bar
"
,
ax
=
ax
)
ax
.
set_title
(
"
Flight Status Distribution
"
)
ax
.
set_xlabel
(
"
Flight Status
"
)
ax
.
set_ylabel
(
"
Count
"
)
st
.
pyplot
(
fig
)
# Pie chart for passenger nationality distribution
st
.
write
(
"
Passenger Nationality Distribution
"
)
nationality_counts
=
df
[
"
Nationality
"
].
value_counts
().
head
(
10
)
# Top 10 nationalities
fig
,
ax
=
plt
.
subplots
()
nationality_counts
.
plot
(
kind
=
"
pie
"
,
autopct
=
"
%1.1f%%
"
,
ax
=
ax
)
ax
.
set_ylabel
(
""
)
ax
.
set_title
(
"
Top 10 Passenger Nationalities
"
)
st
.
pyplot
(
fig
)
This diff is collapsed.
Click to expand it.
bot_image.png
deleted
100644 → 0
+
0
−
0
View file @
d0d528e0
5.17 KiB
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment