#### 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: Determining the trend for Bitcoin prices:

a) We are given a table containing Bitcoin prices in USD for the years 2010-2017. Determine a linear trend line for these prices. The monthly price is taken from the first day in each month:

 Date: year-month-day Bitcoin price in USD 2010-12-01 0.23 2011-06-01 9.57 2011-12-01 3.06 2012-06-01 5.27 2012-12-01 12.56 2013-06-01 129.3 2013-12-01 946.92 2014-06-01 629.02 2014-12-01 378.64 2015-06-01 223.31 2015-12-01 362.73 2016-06-01 536.42 2016-12-01 753.25 2017-06-01 2,452.18

b) As per the linear trend line from part a), what is the expected price of Bitcoin in 2020?

c) Discuss whether a linear line is a good indicator for the future price of Bitcoin.

Problem 2: Electronics shop's sales: Using the data in the electronics shop's sales example, predict the sales for every month of the year 2019.

### Analysis

Problem 1:

Input:

```source_code/7/year_bitcoin.py
#Determining a linear trend line for Bitcoin
import numpy as np
from scipy.linalg import lstsq

year = np.array([2010.91666666666...```