data_frame = principalDf.copy() for name, model, k in models: principalDf = data_frame.copy() model.fit(principalDf) labels = model.labels_ principalDf["Clusters"] = labels principalDf["Koppen_labels"] = koppen_labels df = principalDf.copy() plot_map('Agglomerative', k, df, lonSeries, latSeries) if k == 29: plot_maps('Agglomerative', k, df, lonSeries, latSeries) principalDf['veg_type'] = mapped_dataset['veg_type'] principalDf = principalDf.loc[~(principalDf.veg_type == '0')] sil_df = principalDf.drop(['Clusters', 'veg_type', 'Koppen_labels'], axis=1) sil_pred = principalDf['Clusters'] label_encoder = LabelEncoder() y = label_encoder.fit_transform(principalDf['veg_type']) principalDf['veg_encoded'] = y I1 = principalDf['veg_encoded'] I2 = principalDf["Clusters"] I3 = principalDf['Koppen_labels']
data_frame = principalDf.copy() for name, model, k in models: principalDf = data_frame.copy() model.fit(principalDf) labels = model.predict(principalDf) principalDf["Clusters"] = labels principalDf["Koppen_labels"] = koppen_labels df = principalDf.copy() plot_map('BIRCH', k, df, lonSeries, latSeries) if k == 29: plot_maps('BIRCH', k, df, lonSeries, latSeries) principalDf['veg_type'] = mapped_dataset['veg_type'] principalDf = principalDf.loc[~(principalDf.veg_type == '0')] sil_df = principalDf.drop(['Clusters', 'veg_type', 'Koppen_labels'], axis=1) sil_pred = principalDf['Clusters'] label_encoder = LabelEncoder() y = label_encoder.fit_transform(principalDf['veg_type']) principalDf['veg_encoded'] = y k1 = max(principalDf['veg_encoded']) + 1 I1 = principalDf['veg_encoded'].replace({0: k1 + 1}) k2 = max(principalDf['Koppen_labels']) + 1 I2 = principalDf["Clusters"]
for name, model, k in models: principalDf = data_frame.copy() model.fit(principalDf) labels = model.labels_ principalDf["Clusters"] = labels principalDf.to_csv('/Users/bilalhussain/Downloads/Plotly CSV/kmeans.csv', index=False) principalDf["Koppen_labels"] = koppen_labels df = principalDf.copy() plot_map('KMeans', k, df, lonSeries, latSeries) if k == 29: plot_maps('KMeans', k, df, lonSeries, latSeries) principalDf['veg_type'] = mapped_dataset['veg_type'] principalDf = principalDf.loc[~(principalDf.veg_type == '0')] sil_df = principalDf.drop(['Clusters', 'veg_type', 'Koppen_labels'], axis=1) sil_pred = principalDf['Clusters'] label_encoder = LabelEncoder() y = label_encoder.fit_transform(principalDf['veg_type']) principalDf['veg_encoded'] = y I1 = principalDf['veg_encoded'] I2 = principalDf["Clusters"] I3 = principalDf['Koppen_labels']
data_frame = principalDf.copy() for name, model, k in models: principalDf = data_frame.copy() model.fit(principalDf) labels = model.predict(principalDf) principalDf["Clusters"] = labels principalDf["Koppen_labels"] = koppen_labels df = principalDf.copy() plot_map('Gaussian Mixture', k, df, lonSeries, latSeries) if k == 29: plot_maps('Gaussian Mixture', k, df, lonSeries, latSeries) principalDf['veg_type'] = mapped_dataset['veg_type'] principalDf = principalDf.loc[~(principalDf.veg_type == '0')] sil_df = principalDf.drop(['Clusters', 'veg_type', 'Koppen_labels'], axis=1) sil_pred = principalDf['Clusters'] label_encoder = LabelEncoder() y = label_encoder.fit_transform(principalDf['veg_type']) principalDf['veg_encoded'] = y k1 = max(principalDf['veg_encoded']) + 1 I1 = principalDf['veg_encoded'].replace({0: k1 + 1}) k2 = max(principalDf['Koppen_labels']) + 1 I2 = principalDf["Clusters"]
data_frame = principalDf.copy() for name, model, k in models: principalDf = data_frame.copy() model.fit(principalDf) labels = model.predict(principalDf) principalDf["Clusters"] = labels principalDf["Koppen_labels"] = koppen_labels df = principalDf.copy() plot_map('MinBKmeans', k, df, lonSeries, latSeries) if k == 29: plot_maps('MinBKmeans', k, df, lonSeries, latSeries) principalDf['veg_type'] = mapped_dataset['veg_type'] principalDf = principalDf.loc[~(principalDf.veg_type == '0')] sil_df = principalDf.drop(['Clusters', 'veg_type', 'Koppen_labels'], axis=1) sil_pred = principalDf['Clusters'] label_encoder = LabelEncoder() y = label_encoder.fit_transform(principalDf['veg_type']) principalDf['veg_encoded'] = y k1 = max(principalDf['veg_encoded']) + 1 I1 = principalDf['veg_encoded'].replace({0: k1 + 1}) k2 = max(principalDf['Koppen_labels']) + 1 I2 = principalDf["Clusters"]