Julia Programming Projects

Book description

A step-by-step guide that demonstrates how to build simple-to-advanced applications through examples in Julia Lang 1.x using modern tools

Key Features

  • 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

Book 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.

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

Who this book is 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.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Julia Programming Projects
  3. Dedication
  4. About Packt
    1. Why subscribe?
    2. Packt.com
  5. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  7. Getting Started with Julia Programming
    1. Technical requirements
    2. Why Julia?
      1. Good performance
        1. Concise, readable, and intuitive syntax
        2. Powerful and productive dynamic type system
        3. Designed for parallelism and distributed computation
        4. Efficient intercommunication with other languages
        5. Powerful REPL and shell-like capabilities
        6. And more...
    3. Installing Julia
      1. Windows
        1. Official Windows installer
        2. Using Chocolatey
        3. Windows Subsystem for Linux
      2. macOS
        1. Official image
        2. Homebrew
      3. Linux and FreeBSD
      4. Docker
      5. JuliaPro
      6. JuliaBox
    4. Choosing an IDE
      1. Juno (Atom)
      2. Visual Studio Code
      3. IJulia (JuliaBox)
      4. Other options
    5. Getting started with Julia
      1. The Julia REPL
        1. Interacting with the REPL
          1. The ans variable
          2. Prompt pasting
          3. Tab completion
          4. Cleaning the REPL scope
      2. Additional REPL modes
        1. Accessing the documentation with the help mode
        2. Shell mode
        3. Search modes
      3. The startup.jl file
      4. REPL hooks
      5. Exiting the REPL
    6. The package system
      1. Adding a package
        1. OhMyREPL
        2. Custom package installation
          1. Revise
      2. Checking the package status
      3. Using packages
        1. One more step
      4. Updating packages
        1. Pinning packages
      5. Removing packages
      6. Discovering packages
      7. Registered versus unregistered
    7. Summary
  8. Creating Our First Julia App
    1. Technical requirements
    2. Defining variables
      1. Constants
      2. Why are constants important?
    3. Comments
    4. Strings
      1. Triple-quoted strings
      2. Concatenating strings
      3. Interpolating strings
      4. Manipulating strings
      5. Unicode and UTF-8
    5. Regular expressions
    6. Raw string literals
    7. Numbers
      1. Integers
      2. Overflow behavior
      3. Floating-point numbers
      4. Rational numbers
      5. Numerical operators
      6. Vectorized dot operators
      7. There's more to it
    8. Tuples
      1. Named tuples
    9. Ranges
    10. Arrays
      1. Iteration
      2. Mutating arrays
      3. Comprehensions
      4. Generators
    11. Exploratory data analysis with Julia
      1. The Iris flower dataset
      2. Using the RDatasets package
    12. Using simple statistics to better understand our data
      1. Visualizing the Iris flowers data
    13. Loading and saving our data
      1. Saving and loading using tabular file formats
      2. Working with Feather files
      3. Saving and loading with MongoDB
    14. Summary
  9. Setting Up the Wiki Game
    1. Technical requirements
    2. Data harvesting through web scraping
      1. How the web works – a crash course
      2. Making HTTP requests
        1. Learning about HTTP methods
        2. Understanding HTTPS
    3. Understanding HTML documents
      1. HTML selectors
        1. Learning about the HTML attributes
      2. Learning about CSS and JavaScript selectors
      3. Understanding the structure of a link
    4. Accessing the internet from Julia
      1. Making requests with the HTTP package
    5. Handling HTTP responses
      1. HTTP status codes
      2. Learning about HTTP headers
      3. The HTTP message body
    6. Understanding HTTP responses
      1. The status code
        1. The headers
        2. The message body
        3. Learning about pairs
    7. Dictionaries
      1. Constructing dictionaries
        1. Ordered dictionaries
        2. Working with dictionaries
    8. Using the HTTP response
      1. Manipulating the response body
      2. Building a DOM representation of the page
      3. Parsing HTML with Gumbo
    9. Coding defensively
      1. The pipe operator
    10. Handling errors like a pro
      1. The try...catch statements
      2. The finally clause
      3. Throwing exceptions on errors
      4. Rethrowing exceptions
    11. Learning about functions
      1. The return keyword
      2. Returning multiple values
        1. Optional arguments
        2. Keyword arguments
      3. Documenting functions
    12. Writing a basic web crawler – take one
      1. Setting up our project
      2. Writing a Julia program
      3. Conditional evaluation of if, elseif, and else statements
      4. The ternary operator
      5. Short-circuit evaluation
        1. Beware of operator precedence
    13. Carrying on with the crawler's implementation
    14. Summary
  10. Building the Wiki Game Web Crawler
    1. Technical requirements
    2. Six Degrees of Wikipedia, the gameplay
      1. Some additional requirements
    3. Organizing our code
      1. Using modules to tame our code
      2. Defining modules
        1. Productive REPL sessions with Julia
      3. Setting up our modules
      4. Referencing modules
        1. Setting up the LOAD_PATH
        2. Loading modules with using
        3. Loading modules with import
        4. Loading modules with include
      5. Nesting modules
    4. Setting up our game's architecture
      1. Checking our code
    5. Building our Wikipedia crawler - take two
      1. Using blocks
    6. Implementing the gameplay
    7. Finishing touches
      1. One more thing
    8. Learning about Julia's type system
      1. Defining our own types
      2. Constructing types
      3. Mutable composite types
      4. Type hierarchy and inheritance
      5. Type unions
    9. Using article types
      1. Inner constructors
    10. Methods
    11. Working with relational databases
      1. Adding MySQL support
        1. Connecting to the database
      2. Setting up our Article module
        1. Adding the persistence and retrieval methods
        2. Putting it all together
    12. Summary
  11. Adding a Web UI for the Wiki Game
    1. Technical requirements
    2. The game plan
    3. Learning about Julia's web stack
      1. Beginning with a simple example – Hello World
    4. Developing the game's web UI
      1. Defining our routes
      2. Preparing the landing page
    5. Starting a new game
      1. Extracting the difficulty settings from the page URL
      2. Starting a new game session
      3. Rendering the first Wikipedia article from the chain
      4. Setting up in-article navigation
      5. Displaying information about the game session
    6. Displaying a Wikipedia article page
      1. Navigating back up the article chain
    7. Showing the solution
    8. Handling any other requests
    9. Wrapping it up
    10. Summary
  12. Implementing Recommender Systems with Julia
    1. Technical requirements
    2. Understanding recommender systems
    3. Classifying recommender systems
      1. Learning about non-personalized, stereotyped, and personalized recommendations
        1. Understanding personalized recommendations
          1. Explicit and implicit ratings
        2. Understanding content-based recommender systems
        3. Beginning with association-based recommendations
        4. Learning about collaborative filtering
          1. Understanding user-item CF
          2. Item-item CF
    4. Summary
  13. Machine Learning for Recommender Systems
    1. Technical requirements
    2. Comparing the memory-based versus model-based recommenders
      1. Learning about the model-based approach
      2. Understanding our data
        1. A first look at the data
        2. Loading the data
        3. Handling missing data
      3. Data analysis and preparation
        1. Training our data models
        2. Scaling down our dataset
        3. Training versus testing data
    3. Machine learning-based recommendations
      1. Making recommendations with Recommendation
        1. Setting up the training data
        2. Building and training the recommender
          1. Matrix Factorization
        3. Making recommendations
    4. Testing the recommendations
    5. Learning about hybrid recommender systems
    6. Summary
  14. Leveraging Unsupervised Learning Techniques
    1. Technical requirements
    2. Unsupervised machine learning
    3. Clustering
    4. Data analysis of the San Francisco business
      1. Data wrangling with query
      2. Metaprogramming in Julia
        1. Learning about symbols and expressions in metaprogramming
          1. Quoting expressions
          2. Interpolating strings
        2. Macros
        3. Closing words about macros
        4. Beginning with Query.jl basics
          1. @from
          2. @select
          3. @collect
          4. @where
          5. @join
          6. @group
          7. @orderby
        5. Preparing our data
    5. Unsupervised machine learning with clustering
      1. The k-means algorithm
        1. Algorithm seeding
      2. Finding the areas with the most businesses
      3. Training our model
      4. Interpreting the results
      5. Refining our findings
        1. Visualizing our clusters on the map
        2. Using BatchGeo to quickly build maps of our data
        3. Choosing the optimal number of clusters for k-means (and other algorithms)
        4. Clustering validation
    6. Summary
  15. Working with Dates, Times, and Time Series
    1. Technical requirements
    2. Working with dates and times
    3. Constructing dates and times
      1. Parsing strings into dates and times
      2. Formatting dates
        1. Defining other locales
    4. Working with date and time accessors
      1. Querying dates
    5. Defining the date ranges
    6. Period types and period arithmetic
    7. Date adjustments
    8. Rounding of dates
    9. Adding support for time zones
      1. Converting time zones
      2. Parsing date strings
      3. ZonedDateTime period arithmetic
      4. Time zone-aware date ranges
    10. Time series data in Julia
      1. A quick look at our data with Plots and PyPlot
      2. The TimeArray type
        1. Indexing the TimeArray objects
        2. Querying TimeArray objects
          1. The when() method
          2. The from() method
          3. The to() method
          4. The findall() and findwhen() methods
      3. Manipulating time series objects
        1. merge()
          1. The vcat() method
          2. The collapse() method
          3. The map() method
    11. Summary
  16. Time Series Forecasting
    1. Technical requirements
    2. A quick look at our data
      1. Data processing
    3. Understanding time series components
      1. Trend
      2. Seasonality
      3. Random noise
      4. Cyclicity
    4. Time series decomposition
      1. Explaining data – an additive approach or multiplicative approach?
      2. Extracting the trend
      3. Computing the seasonality
        1. TimeSeries operators
    5. Time series stationarity
      1. Differencing a time series
      2. Autocorrelation
    6. Time series forecasting
      1. Naïve
      2. Simple average
      3. Moving average
      4. Linear regression
      5. Closing thoughts
    7. Summary
  17. Creating Julia Packages
    1. Technical requirements
    2. Creating a new Julia package
      1. Generating packages 
        1. The Project.toml file
        2. The src folder and the main module
      2. Using our new package
    3. Defining the requirements for our package
    4. Beginning with test-driven Julia development
      1. Peeking into Julia's registry
        1. Working with TOML files
      2. The IssueReporter.jl package
    5. Performance testing
      1. Benchmarking tools
      2. Type stability is key
        1. Benchmarking our code
    6. Interacting with the GitHub API
      1. Authenticating with the GitHub API
      2. Reporting GitHub issues
    7. Documenting our package
    8. Advanced documentation tips
      1. Generating the documentation
    9. Registering our package
      1. Finishing touches
      2. Setting up the repository
      3. Unleashing Julia's army of bots
    10. Summary
  18. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Julia Programming Projects
  • Author(s): Adrian Salceanu
  • Release date: December 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788292740