Book Image

Hands-On Data Science with Anaconda

By : Yuxing Yan, James Yan
Book Image

Hands-On Data Science with Anaconda

By: Yuxing Yan, James Yan

Overview of this book

Anaconda is an open source platform that brings together the best tools for data science professionals with more than 100 popular packages supporting Python, Scala, and R languages. Hands-On Data Science with Anaconda gets you started with Anaconda and demonstrates how you can use it to perform data science operations in the real world. The book begins with setting up the environment for Anaconda platform in order to make it accessible for tools and frameworks such as Jupyter, pandas, matplotlib, Python, R, Julia, and more. You’ll walk through package manager Conda, through which you can automatically manage all packages including cross-language dependencies, and work across Linux, macOS, and Windows. You’ll explore all the essentials of data science and linear algebra to perform data science tasks using packages such as SciPy, contrastive, scikit-learn, Rattle, and Rmixmod. Once you’re accustomed to all this, you’ll start with operations in data science such as cleaning, sorting, and data classification. You’ll move on to learning how to perform tasks such as clustering, regression, prediction, and building machine learning models and optimizing them. In addition to this, you’ll learn how to visualize data using the packages available for Julia, Python, and R.
Table of Contents (15 chapters)

Quadratic optimization

If the highest power is 1, then we call it a linear model. On the other hand, if the highest power is 2, we call it a quadratic function. The R optim() function can be used to find a solution for a minimization problem. For example, we have the following objective function:

Since there is only one variable, we can solve it manually. Take the first-order derivative and set it to:

x<-seq(-10,10,0.1) 
a<--2 
b<-10 
c<-5 
y<-a*x^2+b*x+c 
plot(x,y,type='l') 

The related graph is shown here:

From the graph, we know that we could get a maximum y value when x is zero:

y<-20-3.5*x^2 
a<--2 
b<-10 
c<-5 
f<-function(x)-(a*x^2+b*x+c) 

In the preceding formula, we use a negative function since the R optim() function would get a minimum value instead of a maximum one:

> optim(0.3,f) 
$par 
[1] 2.500078 
$value 
[1] -17.5 ...