K-Means Clustering Algorithm with Python Tutorial

  Рет қаралды 116,385

Andy McDonald

Andy McDonald

Күн бұрын

Пікірлер: 103
@chromepunk-mm5up
@chromepunk-mm5up Ай бұрын
criminally underrated channel! Your explanations are superb
@abdoulazizmahamadouhamidou2244
@abdoulazizmahamadouhamidou2244 2 жыл бұрын
Thanks ! I am geoscientist just starting my data sciences journey and I find your videos very helpful
@JosuéEstevane
@JosuéEstevane 6 ай бұрын
Please can you help me I want to know more about data sciences applying in geosciences
@letsjoinhands
@letsjoinhands 2 жыл бұрын
Your fluency and skill, simply superb! Keep it up!
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
Thank you! 😃
@beyzamutlu7379
@beyzamutlu7379 Жыл бұрын
That was the best explanation what i watch for KClustering thank you 😊
@JeanLouisKali
@JeanLouisKali 5 ай бұрын
Great presentation. The clearest I've seen on KZbin, to date. 👍
@moaiedbetamour6078
@moaiedbetamour6078 Жыл бұрын
Very nice, simple, clear and to the point. Thank you for sharing.
@AaromGuillaume-er8pe
@AaromGuillaume-er8pe Жыл бұрын
Explained this better than my professor. Big W
@ahmetatasever8315
@ahmetatasever8315 Жыл бұрын
Hi, I have one question about scettering in 13:21. Why were 'NHPI' and 'RHOB' written in 'plt.scatter()' when all calculations were done according to scaled data (I mean 'NHPI_T' and 'RHOB_T')? I am just trying to learn it. Could you please help me?
@AndyMcDonald42
@AndyMcDonald42 Жыл бұрын
Using the scaled data within certain algorithms can reduce the effect of different data ranges (e.g feature1 ranges from 0 to 1, and feature2 ranges from 0.1 to 10,000), and scaling can also help speed things up. Some algorithms such as decision trees/random forests don't really need scaling whereas Neural Networks and even clustering can benefit from this process. Plotting the data using the original curves allows us to see how the calculated clusters align with the original data. If we were using scaled data, then the numbers on the axes wouldn't make too much sense for petrophysical interpretation. Hope that helps :)
@ahmetatasever8315
@ahmetatasever8315 Жыл бұрын
@@AndyMcDonald42 Yes. It helps. :) Thank you very much. Also I have other question. Is there any way to get information about point in the graph by click using mouse to see which point belongs to which data?
@AndyMcDonald42
@AndyMcDonald42 Жыл бұрын
@@ahmetatasever8315 Yes, there certainly us, The plot shown in this video was done with matplotlib, which is used to create a basic and static figure. You could easily swap that out for Plotly, which will have the extra interactivity and give extra info on hover.
@ahmetatasever8315
@ahmetatasever8315 Жыл бұрын
@@AndyMcDonald42 Thank you again :)
@SouthwestStet
@SouthwestStet Жыл бұрын
This was such a fantastic tutorial, thank you for putting quality content out there.
@AndyMcDonald42
@AndyMcDonald42 Жыл бұрын
Glad you liked it!
@AntonyJudeDMello
@AntonyJudeDMello Жыл бұрын
Thank you! The example script is a huge help
@bb3132
@bb3132 3 жыл бұрын
Andy - Your videos are very helpful and informative! Thank you!
@AndyMcDonald42
@AndyMcDonald42 3 жыл бұрын
Glad you like them! Thanks!
@MultiDrag90
@MultiDrag90 Жыл бұрын
Excellent tutorial! Thank you very much for your time
@elife9508
@elife9508 20 күн бұрын
What an amazing tutorial! Thank you!
@Leopar525
@Leopar525 Ай бұрын
You’re a star. Thank you. Subscribed… very well explained
@tylerpargiter642
@tylerpargiter642 2 жыл бұрын
very useful thank you! I'm midway through a data analysis apprenticeship and this helped me alot!
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
You're very welcome! I am glad to hear it has been helpful.
@calfredie0170
@calfredie0170 2 жыл бұрын
Amazing video you have put together here. I enjoyed how clear you were as well as the pace you took to go through the steps and explain everything. I am new to this kind of thing so does anyone have resources on where I can learn how to interpret cluster graphs
@guanyilu5498
@guanyilu5498 Жыл бұрын
hi , thanks for the video, but could you please direct me that which file in your github is the jupyter notebook for this video? I could not find it. thanks
@allansalles8895
@allansalles8895 2 жыл бұрын
Thanks again for the content, Andy! You're a great teacher!
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
Thanks Allan. Glad to hear you are enjoying the content.
@nekohanhanrin
@nekohanhanrin 4 ай бұрын
Thanks buddy, your lesson helped me a lot
@timothysham6409
@timothysham6409 2 жыл бұрын
Andy, thanks for sharing. I can’t find the notebook for this specific exercise. I am trying to follow along with a different dataset but I am getting an error “name ‘means’ is not defined” when trying to determine the number of clusters.
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
Hi Timothy, did you manage to resolve this? If not, I would go back and check you have ran all of the cells before trying to determine the number of clusters.
@olaal-najjar7391
@olaal-najjar7391 3 жыл бұрын
Absolutely useful. Thank you Andy
@AndyMcDonald42
@AndyMcDonald42 3 жыл бұрын
Great to hear!
@kkamalpha
@kkamalpha 2 жыл бұрын
Thanks! I have been doing this on resistivity and seismic values on different profiles in a catchment. However, everytime I get same trend but clusters change in their places. Would like to know about this issue...
@craigsmith941
@craigsmith941 7 ай бұрын
Hi Andy, this was a great tutorial as it's something I would like to try on a csv file with various metrics in the design of a pharmaceutical. I have one question though: I will be wanting to use 5-7 columns on the csv file for clustering - how do you go about visually representing this? I can't think of a good way to do it. Thanks!
@789Moonlight
@789Moonlight 2 ай бұрын
hi. thank you for this wonderful tutorial. where do you recommend choosing data sets from?
@josedavidbastoaguirre2099
@josedavidbastoaguirre2099 3 жыл бұрын
pretty cool. I have used K-means and DBSCAN to identify electrofacies, but I am still working on a way to optimize this task. It would be grade to see the Well Plots (depth Vs logs) with each point identified by its own cluster.
@AndyMcDonald42
@AndyMcDonald42 3 жыл бұрын
Thanks Jose. I did have a section of code for displaying the facies data on a log plot but I did not include it in the video. The full plotting code can be found here: towardsdatascience.com/how-to-use-unsupervised-learning-to-cluster-well-log-data-using-python-a552713748b5
@laveshagrawal4241
@laveshagrawal4241 10 ай бұрын
Excellent presentation and explanation is there a place from where I see the code you have written for this as that would help me in learning. Thanks
@mohammadkeshtkar9655
@mohammadkeshtkar9655 3 жыл бұрын
Hi Andy I think you start machine learning topic and it's my favorite topic thank you 🙏🙏
@AndyMcDonald42
@AndyMcDonald42 3 жыл бұрын
I will be jumping between some Python topics and machine learning topics over the future episodes. Is there any particular algorithms you would like to see covered?
@aboodfal4780
@aboodfal4780 Жыл бұрын
I’ve searched for this file in the github repository and I didn’t find this tutorial’s code file
@yesicamagnoli651
@yesicamagnoli651 2 жыл бұрын
Thank you Andy! I just want to ask you where can I find this notebook to download and work with it? Thanks again!
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
Sorry for the late reply. I realised I hadn't uploaded the file to the repo. You can find it here: github.com/andymcdgeo/Petrophysics-Python-Series It is Notebook 18.
@yesicamagnoli651
@yesicamagnoli651 2 жыл бұрын
@@AndyMcDonald42 thank you!! Please, keep on doing videos like this, I've been learning a lot!
@TeeFat
@TeeFat Жыл бұрын
Thank you so much for this video. I downloaded the data you used and found a negative relationship between RHOB and NPHI. Can tell me how your scatterplot shows a positive relationship between them? Thank you.
@AndyMcDonald42
@AndyMcDonald42 Жыл бұрын
No problem. You are correct that NPHI and RHOB are usually anti-correlated. In petrophysics, we normally display RHOB on an inverted scale, often on the Y-axis. As RHOB values get lower, we likely have a higher porosity, and the values will plot higher up on the y-axis. For higher NPHI (neutron porosity) values, the points will plot further to the right. If we have a case where both NPHI and RHOB are high, they will then plot in the top right. It's a nice and easy way to visualise and identify potential reservoir intervals.
@TeeFat
@TeeFat Жыл бұрын
@@AndyMcDonald42 Thank you so much. I am using it to cluster customer data, but I wanted to make sure I could replicate yours before trying. Thank you again for the explanation and such an awesome tutorial.
@TheWraithkiller
@TheWraithkiller 2 ай бұрын
Has anyone had an issue with In[9] when running from Jupyter Lab? Have fully checked for any spelling errors. The assignment and new columns seems to try to access. KeyError: "None of [Index(['RHOB_T', 'GR_T'. 'NPHI_T', 'PEF_T', 'DTC_T'], dtype='object')] are in the [columns]"
@tanishqrastogi1011
@tanishqrastogi1011 5 ай бұрын
do we only use 2 features of a data while using k means clustering or did you do it for visualization purposes?
@shahzaibkhan7215
@shahzaibkhan7215 Жыл бұрын
Precise and clear👍👍plz explain naive based, Support vector machine & decision tree as well
@alopix5468
@alopix5468 2 жыл бұрын
Hey! great video, only one question. What if I want to set my own centroids?
@jialicai6096
@jialicai6096 2 жыл бұрын
Thank you Andy, great video! What if I want to cluster more than 2 variables?
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
In the .fit() call at 12:00 you would pass in more variables. I have just used 2 for this example to illustrate what the output is like. Hope that helps :)
@cocoshih2948
@cocoshih2948 Жыл бұрын
I have trouble using kemans.labels_ at the end it keeps showing this error: 'numpy.ndarray' object has no attribute 'labels_' can someone help me with this? Thank you!
@akande88
@akande88 2 ай бұрын
great tutorial, thank you.
@abdolkarimmehrparvar6583
@abdolkarimmehrparvar6583 11 ай бұрын
I cannot find notebook file of this video in your git
@압둘하미드이드리스
@압둘하미드이드리스 9 ай бұрын
Could you please share the link to get the dataset?
@tsarm___
@tsarm___ Жыл бұрын
I have problem when trying calculate using excel, the result is different with code, what can i do to fix it?
@pattylu8568
@pattylu8568 2 жыл бұрын
Thank you so much, Andy! I really find your video helpful. I am just wondering whether it would be possible for us to draw the scatter plot in multi-dimensions? Cuz I followed all of your steps but could not continue the step after the elbow plot when using my 500 columns dataframe.
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
Thanks Patty. You would only be able to draw the scatter plot up to 3 dimensions (X, Y and Z). However, you could look at using Seaborn's Pairplot to view 2d scatter plots of each of the variables versus the others: kzbin.info/www/bejne/emangY2vnMpmZ8k I would be wary though of using 500 features with this plot as it will become unwieldy. I would be asking myself the following in your situation: - Do I require all 500 columns? - Are all of the columns relevant? - Can I reduce them manually or look at algorithms such as PCA to reduce the dimensionality of the dataset.
@mostafakhalid8332
@mostafakhalid8332 Жыл бұрын
An error is raised after writing (kmeans_3) while plotting (NPHI vs. RHOB)
@mominabdlhamed2098
@mominabdlhamed2098 2 жыл бұрын
What a great tutorial, thanks a lot🥰🥰
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
Glad you like it!
@ajithkhan7314
@ajithkhan7314 2 жыл бұрын
Okay. So how to draw conclusion from these clusters ? I mean, what are your insights from this model ?
@dragster100
@dragster100 Жыл бұрын
Can I say that at the end of the day, the way of interpreting the clusters is kind of subjective especially when the dataset gets more complex? Since the results could vary quite a lot as you apply different clustering algorithms or tuning some of their parameters. So it could be quite subjective, no?
@AndyMcDonald42
@AndyMcDonald42 Жыл бұрын
Yes. That is very true. It is down to you or the person doing the interpretation to understand what the cluster may represent. If another person does there own interpretation they may have their own understanding of what the clusters represent
@youkendoit123
@youkendoit123 Жыл бұрын
Amazing video, thank you Sir
@robikurniawan8507
@robikurniawan8507 3 жыл бұрын
thank you andy for your sharing 🙏🙏
@AndyMcDonald42
@AndyMcDonald42 3 жыл бұрын
My pleasure
@abdullah.montasheri
@abdullah.montasheri Жыл бұрын
Thank you, Andy, I could not find the notebook in your github.
@AndyMcDonald42
@AndyMcDonald42 Жыл бұрын
I believe this may have been my original notebook. It contains much more detail than what I covered in the video. I hope this helps. github.com/andymcdgeo/Petrophysics-Python-Series/blob/master/18%20-%20Unsupervised%20Clustering%20for%20Lithofacies.ipynb
@Joud3011
@Joud3011 27 күн бұрын
I'm using k-means for the first time. my dataset has more than 400,000 rows and 11 columns, I run the k-means for k= 3, 5, 7, 9, and 10. it took more than 3 hours and still no output. is that normal?
@lorenzos785
@lorenzos785 2 жыл бұрын
I'm working on clustering energy consumption profiles of a group of households, how should the starting dataset be structured? For each apartment I'm given the annual energy consumption profile (15 minutes frequency for 1 year), the number of appliances and the number of rooms
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
Sounds like an interesting task 🙂 If I understand correctly, you have a continuous variable for the energy consumption and then fixed variables for the rest? Have you considered clustering based on the profiles alone and grouping them into something like high energy users and low energy users or early birds and night owls? After that you could then try to use the other properties to gain more insights
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
Maybe have a look at time series clustering techniques for grouping the profiles
@hieunguyenminh1558
@hieunguyenminh1558 Жыл бұрын
how to create input and output lines? pls help
@chottomtaki
@chottomtaki 2 жыл бұрын
hello Andy, thanks for well-explained session,but on the final part can you assist to explain as to which features or measures differentiate one cluster from other,Thanks again
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
Thanks Dominic. One way would be to use a facet grid plot from seaborn and split by the clusters. You could then view the data by histograms, scatter plots and other plot types. That way you can see how the data features vary per cluster
@chottomtaki
@chottomtaki 2 жыл бұрын
@@AndyMcDonald42 thank Andy,this is useful,I real appriciate
@luisnazareth9193
@luisnazareth9193 2 жыл бұрын
Andy, i get some NaN value on the datasets.. and then when i try to run the "df.dropna(inplace = True)", all of the datasets become empty (zero). How to handle this? Thankyou
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
I would check if one or more columns are entirely nan.
@rokaskrisciunas6015
@rokaskrisciunas6015 23 күн бұрын
Why are they useful? Do we know what qualities does these clusters have? Are they meaningful if we have lots of variables?
@DIRECTORZ-BOX
@DIRECTORZ-BOX 9 ай бұрын
i liked it, had to hit that belllll
@vitorcastro42
@vitorcastro42 Жыл бұрын
Solid video :) Btw, where is your accent from?
@fiqihnurhadi1266
@fiqihnurhadi1266 6 ай бұрын
sir, how to clustering data 2d with size(512,512), please help me sir tq
@youorgan2361
@youorgan2361 5 ай бұрын
You are a hero!
@Kittys_life0
@Kittys_life0 2 жыл бұрын
Thanks alot for your helpful videos..
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
Glad you like them!
@mafaldanunes774
@mafaldanunes774 11 ай бұрын
THANKS YOUUUUU AHHHHH SO HAPPY I DID IT
@syifasyuhaidahazman2384
@syifasyuhaidahazman2384 2 жыл бұрын
very helpful . If you could use example that can be easily understandable for non-science community would be extra helpful!!!
@katieweir4166
@katieweir4166 Жыл бұрын
Yasss! A fellow Scot!!!
@katieweir4166
@katieweir4166 Жыл бұрын
It keeps saying name means not defined :(
@eyo3303
@eyo3303 2 жыл бұрын
great content
@thirteen174
@thirteen174 2 жыл бұрын
Thank you so much !!
@stephenmackenzie9016
@stephenmackenzie9016 2 жыл бұрын
Excellent thanks
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
You are welcome
@deividbejarano2386
@deividbejarano2386 Ай бұрын
Where is the meaning the columns of Data?
@dayansaynes6691
@dayansaynes6691 2 жыл бұрын
Thanks a lot!
@AndyMcDonald42
@AndyMcDonald42 2 жыл бұрын
No problem 👍
@caothuydung
@caothuydung Жыл бұрын
thanks a lot
@pixelkeckleon1171
@pixelkeckleon1171 2 жыл бұрын
Too good
@luckyramadhan346
@luckyramadhan346 2 жыл бұрын
finally, a non-indian accent speaker
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 695 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
How to implement K-Means from scratch with Python
23:42
AssemblyAI
Рет қаралды 17 М.
StatQuest: K-means clustering
8:31
StatQuest with Josh Starmer
Рет қаралды 1,7 МЛН
Applied K-Means Clustering in R
16:54
Spencer Pao
Рет қаралды 56 М.
ML with Python | Text Clustering | K-Means (Movies)
16:07
Code with Marcus
Рет қаралды 21 М.
Data Quality Considerations for Petrophysical Machine Learning Models
23:44
K-Means Clustering From Scratch in Python (Mathematical)
33:10
NeuralNine
Рет қаралды 36 М.
Clustering: K-means and Hierarchical
17:23
Serrano.Academy
Рет қаралды 205 М.
12. Clustering
50:40
MIT OpenCourseWare
Рет қаралды 307 М.
All Learning Algorithms Explained in 14 Minutes
14:10
CinemaGuess
Рет қаралды 282 М.
Clustering with DBSCAN, Clearly Explained!!!
9:30
StatQuest with Josh Starmer
Рет қаралды 339 М.
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 695 М.