Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TMP-23-074
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TMP-23-074
TMP-23-074
Commits
60e83747
Commit
60e83747
authored
May 14, 2023
by
Maneka Wijesundara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first commit.can input rating and see vet clinics.
parent
29a98757
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
582 additions
and
0 deletions
+582
-0
IT19980782(001).py
IT19980782(001).py
+46
-0
vetClinics.csv
vetClinics.csv
+536
-0
No files found.
IT19980782(001).py
0 → 100644
View file @
60e83747
import
pandas
as
pd
from
sklearn.cluster
import
KMeans
from
sklearn.preprocessing
import
StandardScaler
# Step 1: Collect data (example data)
#data = {
# 'Clinic': ['Clinic A', 'Clinic B', 'Clinic C', 'Clinic D', 'Clinic E'],
# 'Location': [1, 3, 2, 1, 3], # Example feature: Location (1=City, 2=Suburb, 3=Rural)
# 'Rating': [4.5, 3.8, 4.2, 4.9, 3.6] # Example feature: Rating (1-5 scale)
#}
mydf
=
pd
.
read_csv
(
'vetClinics.csv'
,
encoding
=
'cp1252'
)
df
=
mydf
.
dropna
()
#df = pd.DataFrame(data)
# Step 2: Preprocess the data
features
=
[
'rating'
]
df_features
=
df
[
features
]
# Selecting relevant features
# Standardize the features
scaler
=
StandardScaler
()
df_features_scaled
=
scaler
.
fit_transform
(
df_features
)
# Step 3: Apply K-means clustering
k
=
2
# Number of clusters
kmeans
=
KMeans
(
n_clusters
=
k
,
random_state
=
42
)
kmeans
.
fit
(
df_features_scaled
)
# Step 4: Evaluate and interpret the clusters
df
[
'Cluster'
]
=
kmeans
.
labels_
# Step 5: Make recommendations
#user_location = int(input("Enter your location (1=City, 2=Suburb, 3=Rural): "))
user_rating
=
float
(
input
(
"Enter your preferred rating (1-5 scale): "
))
# Scale the user input features
user_input
=
scaler
.
transform
([[
user_rating
]])
# Assign the user input to a cluster
user_cluster
=
kmeans
.
predict
(
user_input
)[
0
]
# Find the unique best clinics in the user's cluster
best_clinics
=
set
(
df
[
df
[
'Cluster'
]
==
user_cluster
][
'veterinary clinic name'
])
print
(
"The suggested vet clinic(s) based on your input are:"
)
for
clinic
in
best_clinics
:
print
(
clinic
)
\ No newline at end of file
vetClinics.csv
0 → 100644
View file @
60e83747
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment