Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
Julia Programming Projects
Julia Programming Projects

Julia Programming Projects: Learn Julia 1.x by building apps for data analysis, visualization, machine learning, and the web

eBook
R$49.99 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Julia Programming Projects

Creating Our First Julia App

Now that you have a working Julia installation and your IDE of choice is ready to run, it's time to put them to some good use. In this chapter, you'll learn how to apply Julia for data analysis—a domain that is central to the language, so expect to be impressed!

We will learn to perform exploratory data analysis with Julia. In the process, we'll take a look at RDatasets, a package that provides access to over 700 learning datasets. We'll load one of them, the Iris flowers dataset, and we'll manipulate it using standard data analysis functions. Then we'll look more closely at the data by employing common visualization techniques. And finally, we'll see how to persist and (re)load our data.

But, in order to do that, first we need to take a look at some of the language's most important building blocks.

We...

Technical requirements

The Julia package ecosystem is under continuous development and new package versions are released on a daily basis. Most of the times this is great news, as new releases bring new features and bug fixes. However, since many of the packages are still in beta (version 0.x), any new release can introduce breaking changes. As a result, the code presented in the book can stop working. In order to ensure that your code will produce the same results as described in the book, it is recommended to use the same package versions. Here are the external packages used in this chapter and their specific versions:

CSV@v0.4.3
DataFrames@v0.15.2
Feather@v0.5.1
Gadfly@v1.0.1
IJulia@v1.14.1
JSON@v0.20.0
RDatasets@v0.6.1

In order to install a specific version of a package you need to run:

pkg> add PackageName@vX.Y.Z 

For example:

pkg> add IJulia@v1.14.1

Alternatively you can...

Defining variables

We have seen in the previous chapter how to use the REPL in order to execute computations and have the result displayed back to us. Julia even lends a helping hand by setting up the ans variable, which automatically holds the last computed value.

But, if we want to write anything but the most trivial programs, we need to learn how to define variables ourselves. In Julia, a variable is simply a name associated to a value. There are very few restrictions for naming variables, and the names themselves have no semantic meaning (the language will not treat variables differently based on their names, unlike say Ruby, where a name that is all caps is treated as a constant).

Let's see some examples:

julia> book = "Julia v1.0 By Example" 
julia> pi = 3.14 
julia> ANSWER = 42 
julia> my_first_name = "Adrian" 
You can follow along...

Comments

Common programming wisdom says the following:

"Code is read much more often than it is written, so plan accordingly."

Code comments are a powerful tool that make the programs easier to understand later on. In Julia, comments are marked with the # sign. Single-line comments are denoted by a # and everything that follows this, until the end of the line, is ignored by the compiler. Multiline comments are enclosed between #= ... =#. Everything within the opening and the closing comment tags is also ignored by the compiler. Here is an example:

julia> #= 
           Our company charges a fixed  
           $10 fee per transaction. 
       =# 
const flatfee = 10 # flat fee, per transaction  
 

In the previous snippet, we can see both multiline and single-line comments in action. A single-line comment can also be placed at the beginning of the line.

...

Strings

A string represents a sequence of characters. We can create a string by enclosing the corresponding sequence of characters between double quotes, as shown in the following:

julia> "Measuring programming progress by lines of code is like measuring aircraft building progress by weight." 
 

If the string also includes quotes, we can escape these by prefixing them with a backslash \:

julia> "Beta is Latin for \"still doesn't work\"." 

Triple-quoted strings

However, escaping can get messy, so there's a much better way of dealing with this—by using triple quotes """...""".

julia> """Beta is Latin for "still doesn&apos...

Regular expressions

Regular expressions are used for powerful pattern-matching of substrings within strings. They can be used to search for a substring in a string, based on patterns—and then to extract or replace the matches. Julia provides support for Perl-compatible regular expressions.

The most common way to input regular expressions is by using the so-called nonstandard string literals. These look like regular double-quoted strings, but carry a special prefix. In the case of regular expressions, this prefix is "r". The prefix provides for a different behavior, compared to a normal string literal.

For example, in order to define a regular string that matches all the letters, we can use r"[a-zA-Z]*".

Julia provides quite a few nonstandard string literals—and we can even define our own if we want to. The most widely used are for regular expressions...

Raw string literals

If you need to define a string that does not perform interpolation or escaping, for example to represent code from another language that might contain $ and \ which can interfere with the Julia parser, you can use raw strings. They are constructed with raw"..." and create ordinary String objects that contain the enclosed characters exactly as entered, with no interpolation or escaping:

julia> "This $will error out" 
ERROR: UndefVarError: will not defined 

Putting a $ inside the string will cause Julia to perform interpolation and look for a variable called will:

julia> raw"This $will work" 
"This \$will work" 

But by using a raw string, the $ symbol will be ignored (or rather, automatically escaped, as you can see in the output).

Numbers

Julia provides a broad range of primitive numeric types, together with the full range of arithmetic and bitwise operators and standard mathematical functions. We have at our disposal a rich hierarchy of numeric types, with the most generic being Number—which defines two subtypes, Complex and Real. Conversely, Real has four subtypes—AbstractFloat, Integer, Irrational, and Rational. Finally, Integer branches into four other subtypes—BigInt, Bool, Signed, and Unsigned.

Let's take a look at the most important categories of numbers.

Integers

Literal integers are represented simply as follows:

julia> 42 

The default Integer type, called Int, depends on the architecture of the system upon which...

Technical requirements


The Julia package ecosystem is under continuous development and new package versions are released on a daily basis. Most of the times this is great news, as new releases bring new features and bug fixes. However, since many of the packages are still in beta (version 0.x), any new release can introduce breaking changes. As a result, the code presented in the book can stop working. In order to ensure that your code will produce the same results as described in the book, it is recommended to use the same package versions. Here are the external packages used in this chapter and their specific versions:

CSV@v0.4.3
DataFrames@v0.15.2
Feather@v0.5.1
Gadfly@v1.0.1
IJulia@v1.14.1
JSON@v0.20.0
RDatasets@v0.6.1

In order to install a specific version of a package you need to run:

pkg> add PackageName@vX.Y.Z

For example:

pkg> add IJulia@v1.14.1

Alternatively you can install all the used packages by downloading the Project.toml file provided with the chapter and using pkg> instantiate...

Defining variables


We have seen in the previous chapter how to use the REPL in order to execute computations and have the result displayed back to us. Julia even lends a helping hand by setting up the ans variable, which automatically holds the last computed value.

 

But, if we want to write anything but the most trivial programs, we need to learn how to define variables ourselves. In Julia, a variable is simply a name associated to a value. There are very few restrictions for naming variables, and the names themselves have no semantic meaning (the language will not treat variables differently based on their names, unlike say Ruby, where a name that is all caps is treated as a constant).

Let's see some examples:

julia> book = "Julia v1.0 By Example" 
julia> pi = 3.14 
julia> ANSWER = 42 
julia> my_first_name = "Adrian"

Note

You can follow along through the examples in the chapter by loading the accompanying Jupyter/IJulia notebook provided with this chapter's support files.

The variables...

Comments


Common programming wisdom says the following:

"Code is read much more often than it is written, so plan accordingly."

Code comments are a powerful tool that make the programs easier to understand later on. In Julia, comments are marked with the # sign. Single-line comments are denoted by a # and everything that follows this, until the end of the line, is ignored by the compiler. Multiline comments are enclosed between #= ... =#. Everything within the opening and the closing comment tags is also ignored by the compiler. Here is an example:

julia> #= 
           Our company charges a fixed  
           $10 fee per transaction. 
       =# 
const flatfee = 10 # flat fee, per transaction 

In the previous snippet, we can see both multiline and single-line comments in action. A single-line comment can also be placed at the beginning of the line.

Strings


A string represents a sequence of characters. We can create a string by enclosing the corresponding sequence of characters between double quotes, as shown in the following:

julia> "Measuring programming progress by lines of code is like measuring aircraft building progress by weight." 

If the string also includes quotes, we can escape these by prefixing them with a backslash \:

julia> "Beta is Latin for \"still doesn't work\"."

Triple-quoted strings

However, escaping can get messy, so there's a much better way of dealing with this—by using triple quotes """...""".

julia> """Beta is Latin for "still doesn't work"."""

 

 

 

 

 

 

Within triple quotes, it is no longer necessary to escape the single quotes. However, make sure that the single quotes and the triple quotes are separated—or else the compiler will get confused:

julia> """Beta is Latin for "still doesn't work"""" 
syntax: cannot juxtapose string literal

The triple quotes come with some extra special powers when used with multiline...

Regular expressions


Regular expressions are used for powerful pattern-matching of substrings within strings. They can be used to search for a substring in a string, based on patterns—and then to extract or replace the matches. Julia provides support for Perl-compatible regular expressions.

The most common way to input regular expressions is by using the so-called nonstandard string literals. These look like regular double-quoted strings, but carry a special prefix. In the case of regular expressions, this prefix is "r". The prefix provides for a different behavior, compared to a normal string literal.

For example, in order to define a regular string that matches all the letters, we can use r"[a-zA-Z]*".

Julia provides quite a few nonstandard string literals—and we can even define our own if we want to. The most widely used are for regular expressions (r"..."), byte array literals (b"..."), version number literals (v"..."), and package management commands (pkg"...").

Here is how we build a regular...

Raw string literals


If you need to define a string that does not perform interpolation or escaping, for example to represent code from another language that might contain$and\ which can interfere with the Julia parser, you can use raw strings. They are constructed withraw"..."and create ordinaryStringobjects that contain the enclosed characters exactly as entered, with no interpolation or escaping:

julia> "This $will error out" 
ERROR: UndefVarError: will not defined

Putting a $ inside the string will cause Julia to perform interpolation and look for a variable called will:

julia> raw"This $will work" 
"This \$will work"

But by using a raw string, the $ symbol will be ignored (or rather, automatically escaped, as you can see in the output).

Numbers


Julia provides a broad range of primitive numeric types, together with the full range of arithmetic and bitwise operators and standard mathematical functions. We have at our disposal a rich hierarchy of numeric types, with the most generic being Number—which defines two subtypes, Complex and Real. Conversely, Real has four subtypes—AbstractFloat, Integer, Irrational, and Rational. Finally, Integer branches into four other subtypes—BigInt, Bool, Signed, and Unsigned.

Let's take a look at the most important categories of numbers.

 

Integers

Literal integers are represented simply as follows:

julia> 42

The default Integer type, called Int, depends on the architecture of the system upon which the code is executed. It can be either Int32 or Int64. On my 64-bit system, I get it as follows:

julia> typeof(42) 
Int64

The Int type will reflect that, as it's just an alias to either Int32 or Int64:

julia> @show Int 
Int = Int64 

Overflow behavior

The minimum and maximum values are given by the...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Work with powerful open-source libraries for data wrangling, analysis, and visualization
  • Develop full-featured, full-stack web applications
  • Learn to perform supervised and unsupervised machine learning and time series analysis with Julia

Description

Julia is a new programming language that offers a unique combination of performance and productivity. Its powerful features, friendly syntax, and speed are attracting a growing number of adopters from Python, R, and Matlab, effectively raising the bar for modern general and scientific computing. After six years in the making, Julia has reached version 1.0. Now is the perfect time to learn it, due to its large-scale adoption across a wide range of domains, including fintech, biotech, education, and AI. Beginning with an introduction to the language, Julia Programming Projects goes on to illustrate how to analyze the Iris dataset using DataFrames. You will explore functions and the type system, methods, and multiple dispatch while building a web scraper and a web app. Next, you'll delve into machine learning, where you'll build a books recommender system. You will also see how to apply unsupervised machine learning to perform clustering on the San Francisco business database. After metaprogramming, the final chapters will discuss dates and time, time series analysis, visualization, and forecasting. We'll close with package development, documenting, testing and benchmarking. By the end of the book, you will have gained the practical knowledge to build real-world applications in Julia.

Who is this book for?

Data scientists, statisticians, business analysts, and developers who are interested in learning how to use Julia to crunch numbers, analyze data and build apps will find this book useful. A basic knowledge of programming is assumed.

What you will learn

  • Leverage Julia s strengths, its top packages, and main IDE options
  • Analyze and manipulate datasets using Julia and DataFrames
  • Write complex code while building real-life Julia applications
  • Develop and run a web app using Julia and the HTTP package
  • Build a recommender system using supervised machine learning
  • Perform exploratory data analysis
  • Apply unsupervised machine learning algorithms
  • Perform time series data analysis, visualization, and forecasting

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 26, 2018
Length: 500 pages
Edition : 1st
Language : English
ISBN-13 : 9781788297257
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Dec 26, 2018
Length: 500 pages
Edition : 1st
Language : English
ISBN-13 : 9781788297257
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
R$50 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
R$500 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$5 each
Feature tick icon Exclusive print discounts
R$800 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total R$ 791.97
Julia 1.0 Programming Cookbook
R$272.99
Julia Programming Projects
R$272.99
Julia 1.0 Programming
R$245.99
Total R$ 791.97 Stars icon
Banner background image

Table of Contents

12 Chapters
Getting Started with Julia Programming Chevron down icon Chevron up icon
Creating Our First Julia App Chevron down icon Chevron up icon
Setting Up the Wiki Game Chevron down icon Chevron up icon
Building the Wiki Game Web Crawler Chevron down icon Chevron up icon
Adding a Web UI for the Wiki Game Chevron down icon Chevron up icon
Implementing Recommender Systems with Julia Chevron down icon Chevron up icon
Machine Learning for Recommender Systems Chevron down icon Chevron up icon
Leveraging Unsupervised Learning Techniques Chevron down icon Chevron up icon
Working with Dates, Times, and Time Series Chevron down icon Chevron up icon
Time Series Forecasting Chevron down icon Chevron up icon
Creating Julia Packages Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(10 Ratings)
5 star 70%
4 star 0%
3 star 0%
2 star 20%
1 star 10%
Filter icon Filter
Top Reviews

Filter reviews by




Kota Mori Mar 02, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book covers various tips about the Julia language: from installation, REPL, data types, and all the way through package development. I find the last part -- package development -- is quite unique for this book. I would recommend this book to people who are looking for "Advanced R" and/or "R packages" for Julia; Like the Wickham's books, this book helps one to turn a user into a developer.I would also note that this book does not cover so much about data science and statistics. If you want to learn data analysis in Julia, there would be better choice than this book.
Amazon Verified review Amazon
Jim and Virginia Davidson Jan 24, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is a great place to begin learning Julia if you have some background in programming. I am quite new to Julia, but have programmed in Matlab, Fortran, Python, C#, etc.I have not yet read all the book, but so far, have found it very well done. The text seems accurate based on my experience with Julia, up to date, and the examples and projects are helpful. The writing style is easy to follow. 5 stars for sure!
Amazon Verified review Amazon
dougfort Feb 08, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The projects are clear, detailed and show production quality code.
Amazon Verified review Amazon
Amazon Customer Feb 07, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Bom livro sobre a linguagem Julia.
Amazon Verified review Amazon
Massimiliano Bertinetti Aug 11, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Thank you Adrian for this clear guide for starting with Julia Programming!
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.