Professional Documents
Culture Documents
RA2111003011432
RA2111003011432
kernel_name=python3
data = pd.read_excel(r"C:\Users\Admin\Desktop\Datasets\Datasets\Prediction_diabetes.xl
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
def calculate_wcss(data):
wcss = []
for n_clusters in range(1, 11):
kmeans = KMeans(n_clusters=n_clusters, init='k-means++', random_state=
kmeans.fit(data)
wcss.append(kmeans.inertia_)
return wcss
def plot_elbow(wcss):
plt.figure(figsize=(8, 6))
plt.plot(range(1, 11), wcss, marker='o', linestyle='--')
plt.title('Elbow Method')
plt.xlabel('Number of Clusters')
plt.ylabel('WCSS')
plt.xticks(np.arange(1, 11, 1))
plt.grid(True)
plt.show()
wcss = calculate_wcss(X_scaled)
plot_elbow(wcss)
optimal_clusters = 3
1 of 5 05-04-2024, 15:46
Untitled23 - Jupyter Notebook http://localhost:8888/notebooks/Untitled23.ipynb?kernel_name=python3
data['Cluster'] = labels
print(data.head())
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:870: Fu
tureWarning: The default value of `n_init` will change from 10 to 'auto' in 1
.4. Set the value of `n_init` explicitly to suppress the warning
warnings.warn(
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:1382: U
serWarning: KMeans is known to have a memory leak on Windows with MKL, when t
here are less chunks than available threads. You can avoid it by setting the
environment variable OMP_NUM_THREADS=2.
warnings.warn(
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:870: Fu
tureWarning: The default value of `n_init` will change from 10 to 'auto' in 1
.4. Set the value of `n_init` explicitly to suppress the warning
warnings.warn(
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:1382: U
serWarning: KMeans is known to have a memory leak on Windows with MKL, when t
here are less chunks than available threads. You can avoid it by setting the
environment variable OMP_NUM_THREADS=2.
warnings.warn(
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:870: Fu
tureWarning: The default value of `n_init` will change from 10 to 'auto' in 1
.4. Set the value of `n_init` explicitly to suppress the warning
warnings.warn(
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:1382: U
serWarning: KMeans is known to have a memory leak on Windows with MKL, when t
here are less chunks than available threads. You can avoid it by setting the
environment variable OMP_NUM_THREADS=2.
warnings.warn(
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:870: Fu
tureWarning: The default value of `n_init` will change from 10 to 'auto' in 1
.4. Set the value of `n_init` explicitly to suppress the warning
warnings.warn(
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:1382: U
serWarning: KMeans is known to have a memory leak on Windows with MKL, when t
here are less chunks than available threads. You can avoid it by setting the
environment variable OMP_NUM_THREADS=2.
warnings.warn(
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:870: Fu
tureWarning: The default value of `n_init` will change from 10 to 'auto' in 1
.4. Set the value of `n_init` explicitly to suppress the warning
warnings.warn(
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:1382: U
serWarning: KMeans is known to have a memory leak on Windows with MKL, when t
here are less chunks than available threads. You can avoid it by setting the
environment variable OMP_NUM_THREADS=2.
warnings.warn(
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:870: Fu
tureWarning: The default value of `n_init` will change from 10 to 'auto' in 1
.4. Set the value of `n_init` explicitly to suppress the warning
2 of 5 05-04-2024, 15:46
Untitled23 - Jupyter Notebook http://localhost:8888/notebooks/Untitled23.ipynb?kernel_name=python3
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:870: Fu
tureWarning: The default value of `n_init` will change from 10 to 'auto' in 1
.4. Set the value of `n_init` explicitly to suppress the warning
warnings.warn(
C:\ProgramData\anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:1382: U
serWarning: KMeans is known to have a memory leak on Windows with MKL, when t
here are less chunks than available threads. You can avoid it by setting the
environment variable OMP_NUM_THREADS=2.
warnings.warn(
In [ ]:
4 of 5 05-04-2024, 15:46