Book Image

Python Machine Learning Workbook for Beginners

By : AI Sciences
Book Image

Python Machine Learning Workbook for Beginners

By: AI Sciences

Overview of this book

<p>Machine Learning (ML) is the lifeblood of businesses worldwide. ML tools empower organizations to identify profitable opportunities fast and help them to better understand potential risks. The ever-expanding data, cost-effective data storage, and competitively priced powerful processing continue to drive the growth of ML. </p><p> </p><p>This is the best time you could enter the exciting machine learning universe. Industries are reinventing themselves constantly by developing more advanced data analysis models. These models analyze larger and more complex data than ever while delivering instantaneous and more accurate results on enormous scales. </p><p>In this backdrop, it is evident that hands-on practice is everything in machine learning. Tons of theory will amount to nothing if you don’t have enough hands-on practice. Textbooks and online classes mislead you into a false sense of mastery. The easy availability of learning resources tricks you and you become overconfident. But when you try to apply the theoretical concepts you have learned, you realize it’s not that simple. </p><p> </p><p>This is where projects play a crucial role in your learning journey. Projects are doubtless the best investment of your time. You’ll not only enjoy learning but you’ll also make quick progress. And unlike studying boring theoretical concepts, you’ll find that working on projects is easier to stay motivated. </p><p> </p><p>The projects in this book cover ten different interesting topics. Each project will help you refine your ML skills and apply them in the real world. These projects also present you with an opportunity to enrich your portfolio, making it simpler to find a great job, explore interesting career paths, and even negotiate a higher pay package. Overall, this learning-by-doing book will help you accomplish your machine learning career goals faster. </p><p> </p><p>The code bundle for this course is available at https://www.aispublishing.net/ai-sciences-book</p>
Table of Contents (15 chapters)
1
About the Author

10.7. Finding Customers to Target for Marketing

The last step is to find the customers that belong to the sky blue cluster. To do so, we will first plot the centers of the clusters.

Script 17:

1. #printing centroid values

2. print(km_model.cluster_centers_)

Here is the output. From the output, it seems that the coordinates of the centroid for the top right cluster are 86.53 and 82.12. The centroid values are located at index 1, which is also the Id of the cluster.

Output

[[55.2962963 49.51851852]

[86.53846154 82.12820513]

[25.72727273 79.36363636]

[88.2    17.11428571]

[26.30434783 20.91304348]]

To fetch all the records from the cluster with id 1, we will first create a dataframe containing index values of all the records in the dataset and their corresponding cluster labels, as shown below.

Script 18:

1. cluster_map = pd.DataFrame()

2. cluster_map[‘data_index’] = dataset.index.values

3. cluster_map[‘cluster’] = km_model.labels_

4. cluster_map...