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

Arrow left icon
Profile Icon Adrian Salceanu
Arrow right icon
R$50 per month
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (10 Ratings)
Paperback Dec 2018 500 pages 1st Edition
eBook
R$49.99 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m
Arrow left icon
Profile Icon Adrian Salceanu
Arrow right icon
R$50 per month
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (10 Ratings)
Paperback Dec 2018 500 pages 1st Edition
eBook
R$49.99 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m
eBook
R$49.99 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781788292740
Category :
Languages :
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

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

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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.