Giter VIP home page Giter VIP logo

entertainment_spend_prediction's People

Contributors

osemuaimiosior avatar

Watchers

 avatar

entertainment_spend_prediction's Issues

I am unable to find any clusters

scaler = StandardScaler()
clean_std = scaler.fit_transform(clean_df)
    hier_clust = linkage(clean_df, method = 'ward')

After I applied the hierarchical function I then plotted it using the below code, and it showed two clusters, ok.

plt.figure(figsize = (12,9))
plt.title('Hierarchical clustering Dendrogram')
plt.xlabel('Observations')
plt.ylabel('Distance')
dendrogram(hier_clust,truncate_mode ='level',p = 5, show_leaf_counts = False, no_labels = True)
plt.show()

I then carried out a kmean clustering

kmeans = KMeans(n_clusters = 2,init='k-means++', random_state = 42)
Kmeans.fit(clean_df)
kmeans_segm_df['segment K-means'] = kmeans.labels_

I got the below error message


    AttributeError: 'KMeans' object has no attribute 'labels_'

Then tried using PCA

    pca = PCA()

pca.fit(clean_df)

PCA(copy=True, iterated_power='auto', n_components=None, random_state=None,
svd_solver='auto', tol=0.0, whiten=False)

pca.explained_variance_ratio_

The first few output lines

array([5.17864405e-01, 6.74883092e-02, 2.49671158e-02, 2.05556330e-02,
1.91532089e-02, 1.61175412e-02, 1.25663312e-02, 1.09884435e-02,
9.36794595e-03, 9.22968228e-03, 8.21092225e-03, 7.39649721e-03,
7.05544735e-03, 6.74900236e-03, 6.45469976e-03, 6.17330989e-03,
5.57049810e-03, 5.30600080e-03, 5.22280969e-03, 5.11097471e-03,
4.90707043e-03, 4.80062520e-03, 4.69583601e-03, 4.58244771e-03,
4.48671555e-03, 4.29199027e-03, 4.14526774e-03, 3.91812788e-03,
3.80673185e-03, 3.73175901e-03, 3.65626264e-03, 3.62656430e-03,
3.54079343e-03, 3.50403189e-03, 3.46612626e-03, 3.38438216e-03,
3.26869506e-03, 3.22061465e-03, 3.16429234e-03, 3.09223696e-03,
3.03787507e-03, 2.99534848e-03, 2.95222565e-03, 2.86314206e-03,
2.81660442e-03, 2.78368435e-03, 2.77057938e-03, 2.67184454e-03,
2.64679986e-03, 2.60115606e-03, 2.52604480e-03, 2.47816159e-03,
2.44490870e-03, 2.43491443e-03, 2.40074828e-03, 2.33885752e-03,
2.32547328e-03, 2.26873033e-03, 2.22908313e-03, 2.20986051e-03,

pca = PCA(n_components = 12)
pca.fit(clean_df)

PCA(copy=True, iterated_power='auto', n_components=12, random_state=None,
svd_solver='auto', tol=0.0, whiten=False

pca.transform(clean_std)

scores_pca = pca.transform(clean_std)

wcss = []
for i in range(1,180):
    kmeans_pca = KMeans(n_clusters = i, init = 'k-means++', random_state = 42)
    kmeans_pca.fit(scores_pca)
    wcss.append(kmeans_pca.inertia_)
plt.figure(figsize=(30,50))
plt.plot(range(1,180), wcss, marker = 'o',linestyle= '--')
plt.xlabel('Number of Clusters')
plt.ylabel('WCSS')
plt.title('K-means with PCA Clustering')
plt.show()
db = DBSCAN(eps=50, min_samples=60)
db.fit(clean_df)

DBSCAN(algorithm='auto', eps=50, leaf_size=30, metric='euclidean',
metric_params=None, min_samples=60, n_jobs=None, p=None)

y_pred = db.fit_predict(clean_df)
plt.figure(figsize=(10,9))
plt.scatter(clean_std[:,0],clean_std[:,1], c = y_pred, cmap ='Paired')
plt.title('Estimated number of clusters')
plt.show()

I used three different techniques I still couldn't fine any clusters

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.