Skip to content

Instantly share code, notes, and snippets.

View 3liud's full-sized avatar
💭
Learning

Eliud Nduati 3liud

💭
Learning
View GitHub Profile
@3liud
3liud / 6caeadb1-78af-4fa5-8cc9-8dd00906de65.py
Created March 21, 2022 09:50
week_#7_in_machine learning7
from sklearn.cluster import KMeans
errors = []
for i in range(1, 11):
kmeans = KMeans(n_clusters=i)
kmeans.fit(df1)
errors.append(kmeans.inertia_)
@3liud
3liud / 6af901ca-2310-471b-b5b1-c38d9b0c99ee.py
Created March 21, 2022 09:50
week_#7_in_machine learning6
# Scatter Plot
sns.scatterplot(df1['Annual Income (k$)'], df1['Spending Score (1-100)']);
@3liud
3liud / 4df220a4-1ecb-4012-b609-47e40cb8e6dd.py
Created March 21, 2022 09:50
week_#7_in_machine learning5
df1 = df[['Annual Income (k$)', 'Spending Score (1-100)']]
df1.head()
@3liud
3liud / cef4f252-0300-4ac8-b32f-cb00d7b9b4fa.py
Created March 21, 2022 09:50
week_#7_in_machine learning4
corr = df.corr()
sns.heatmap(corr, annot=True, cmap="YlGnBu_r")
@3liud
3liud / 8f927d05-82e7-4820-aa0c-b475b44a26f5.py
Created March 21, 2022 09:50
week_#7_in_machine learning3
Females, Males = df['Gender'].value_counts()
print(f'There are {Females} Female customers and {Males} Male customers in the dataset')
@3liud
3liud / 289d66e4-2559-4fd0-a7f8-73446a885b3a.py
Created March 21, 2022 09:50
week_#7_in_machine learning2
nRows, nColumns = df.shape
print(f"There are {nRows} rows and {nColumns} columns in our dataset")
@3liud
3liud / 65e625c1-fd35-4048-a729-75ea6a36fcc5.py
Created March 21, 2022 09:50
week_#7_in_machine learning1
# Loading in the Data
df = pd.read_csv('Mall_Customers.csv')
df.head()
@3liud
3liud / 6c45160a-3373-4b18-8313-24af8a17b63e.py
Created March 21, 2022 09:50
week_#7_in_machine learning0
# importing libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.preprocessing import StandardScaler
@3liud
3liud / 7b2a09a3-4b4a-423d-9703-3ce402c1a232.py
Created March 21, 2022 09:16
week_#7_in_machine learning17
fig = plt.figure(figsize=(20,15))
ax = fig.add_subplot(111, projection='3d')
ax.scatter(df2['Age'][df2['Label']==0], df2['Annual Income (k$)'][df2['Label']==0],
df2['Spending Score (1-100)'][df2['Label']==0], c='green', s=50)
ax.scatter(df2['Age'][df2['Label']==1], df2['Annual Income (k$)'][df2['Label']==1],
df2['Spending Score (1-100)'][df2['Label']==1], c='blue', s=50)
ax.scatter(df2['Age'][df2['Label']==2], df2['Annual Income (k$)'][df2['Label']==2],
df2['Spending Score (1-100)'][df2['Label']==2], c='black', s=50)
ax.scatter(df2['Age'][df2['Label']==3], df2['Annual Income (k$)'][df2['Label']==3],
@3liud
3liud / 7049dfe2-46f7-4e04-b4f1-76c48556503b.py
Created March 21, 2022 09:16
week_#7_in_machine learning16
df2_clusters = df2['Label'].value_counts()
df2_clusters