Skip to content

Instantly share code, notes, and snippets.

View tejaschechar's full-sized avatar

Tejas Chechar tejaschechar

View GitHub Profile
@tejaschechar
tejaschechar / building_kmeans.py
Created June 28, 2023 04:57 — forked from aishwarya-singh25/building_kmeans.py
Gaussian Mixture Models Implementation
#training k-means model
from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters=4)
kmeans.fit(data)
#predictions from kmeans
pred = kmeans.predict(data)
frame = pd.DataFrame(data)
frame['cluster'] = pred
frame.columns = ['Weight', 'Height', 'cluster']
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#Loading dataset – User_Data
dataset = pd.read_csv('...\\User_Data.csv')
#Now, to predict whether a user will purchase the product or not, one needs to find out the relationship between Age and Estimated Salary. Here User ID and Gender are not important factors for finding out this.
# input
x = dataset.iloc[:, [2, 3]].values
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#Loading dataset – User_Data
dataset = pd.read_csv('...\\User_Data.csv')
#Now, to predict whether a user will purchase the product or not, one needs to find out the relationship between Age and Estimated Salary. Here User ID and Gender are not important factors for finding out this.
# input
x = dataset.iloc[:, [2, 3]].values