#### Overview of this book

Machine learning applications are highly automated and self-modifying, and continue to improve over time with minimal human intervention, as they learn from the trained data. To address the complex nature of various real-world data problems, specialized machine learning algorithms have been developed. Through algorithmic and statistical analysis, these models can be leveraged to gain new knowledge from existing data as well. Data Science Algorithms in a Week addresses all problems related to accurate and efficient data classification and prediction. Over the course of seven days, you will be introduced to seven algorithms, along with exercises that will help you understand different aspects of machine learning. You will see how to pre-cluster your data to optimize and classify it for large datasets. This book also guides you in predicting data based on existing trends in your dataset. This book covers algorithms such as k-nearest neighbors, Naive Bayes, decision trees, random forest, k-means, regression, and time-series analysis. By the end of this book, you will understand how to choose machine learning algorithms for clustering, classification, and regression and know which is best suited for your problem
Title Page
Packt Upsell
Contributors
Preface
Free Chapter
Classification Using K-Nearest Neighbors
Time Series Analysis
Python Reference
Statistics
Glossary of Algorithms and Methods in Data Science
Other Books You May Enjoy
Index

## Problems

Problem 1: Compute the centroid of the following clusters:

a) 2, 3, 4

b) USD 100, USD 400, USD 1,000

c) (10,20), (40, 60), (0, 40)

d) (USD 200, 40 km), (USD 300, 60 km), (USD 500, 100 km), (USD 250, 200 km)

e) (1,2,4), (0,0,3), (10,20,5), (4,8,2), (5,0,1)

Problem 2: Cluster the following datasets into two, three, and four clusters using the k-means clustering algorithm:

a) 0, 2, 5, 4, 8, 10, 12, 11

b) (2,2), (2,5), (10,4), (3,5), (7,3), (5,9), (2,8), (4,10), (7,4), (4,4), (5,8), (9,3)

Problem 3: We are given the ages of the couples and the number of children they have:

 Couple number Wife's age Husband's age Number of children 1 48 49 5 2 40 43 2 3 24 28 1 4 49 42 3 5 32 34 0 6 24 27 0 7 29 32 2 8 35 35 2 9 33 36 1 10 42 47 3 11 22 27 2 12 41 45 4 13 39 43 4 14 36 38 2 15 30 32 1 16 36 38 0 17 36 39 3 18 37 38 ?

We would like to guess, using clustering, how many children a couple has where the age of the husband is 37 and the age of the wife is 38.

### Analysis

Problem 1:  a)

b)

c)

d)

e)

Problem 2: a) We add a second coordinate and set it to `0` for all the features...