Beispiel #1
0
data_frame = principalDf.copy()

for name, model in models:

    principalDf= data_frame.copy()
    model.fit(principalDf)
    labels = model.labels_
    n_clusters_ = len(set(labels)) - (1 if -1 in labels else 0)
    n_noise_ = list(labels).count(-1)
    print("CLUSTERS:", n_clusters_)
    principalDf["Clusters"] = labels
    principalDf["Koppen_labels"]= koppen_labels
    principalDf = principalDf[principalDf['Clusters'] != -1]
    k = max(unique(principalDf["Clusters"]))
    df = principalDf.copy()
    plot_map('OPTICS',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
    principalDf = principalDf[principalDf['Clusters'] != -1]

    k1 = max(principalDf['veg_encoded']) + 1
    I1 = principalDf['veg_encoded'].replace({0: k1})
    k2 = max(principalDf['Koppen_labels']) + 1
    I2 = principalDf["Clusters"]
data_frame = principalDf.copy()

for name, model in models:

    principalDf= data_frame.copy()
    model.fit(principalDf)
    labels = model.labels_
    n_clusters_ = len(set(labels)) - (1 if -1 in labels else 0)
    n_noise_ = list(labels).count(-1)
    print("CLUSTERS:", n_clusters_)
    principalDf["Clusters"] = labels
    principalDf["Koppen_labels"]= koppen_labels
    principalDf = principalDf[principalDf['Clusters'] != -1]
    k = max(unique(principalDf["Clusters"]))
    df = principalDf.copy()
    plot_map('AffinityPropagation',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
    principalDf = principalDf[principalDf['Clusters'] != -1]

    k1 = max(principalDf['veg_encoded']) + 1
    I1 = principalDf['veg_encoded'].replace({0: k1})
    k2 = max(principalDf['Koppen_labels']) + 1
    I2 = principalDf["Clusters"]
Beispiel #3
0
    ('Agglomerative Clustering29', AgglomerativeClustering(n_clusters=29), 29))
models.append(
    ('Agglomerative Clustering30', AgglomerativeClustering(n_clusters=30), 30))

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']
models.append(('BIRCH26', Birch(n_clusters=26), 26))
models.append(('BIRCH29', Birch(n_clusters=29), 29))
models.append(('BIRCH30', Birch(n_clusters=30), 30))

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
models.append(
    ('Gaussian Mixture30', GaussianMixture(n_components=30,
                                           random_state=1), 30))

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
models.append(('Kmeans30', KMeans(n_clusters=30, random_state=1), 30))

data_frame = principalDf.copy()

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']
Beispiel #7
0
models.append(('MiniBatchKMeans26', MiniBatchKMeans(n_clusters=26), 26))
models.append(('MiniBatchKMeans29', MiniBatchKMeans(n_clusters=29), 29))
models.append(('MiniBatchKMeans30', MiniBatchKMeans(n_clusters=30), 30))

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