How to build a sailboat half-model?
Julia DataFrames
Filtering DataFrame
New Syntax
Syntax explained:
- from original "data" (type DataFrames)
- create new "dataA" (type DataFrames)
- filter indices in column "Treatment" with values equal to "A"
- include ALL COLUMNS indicated by ":"
- Show the first 6 rows
dataA = data[isequal.(data.Treatment, "A"), : ]
first(dataA, 6)
6 rows × 5 columns
| Age | WCC | CRP | Treatment | Result | |
|---|---|---|---|---|---|
| Int64 | Float64 | Int64 | String | String | |
| 1 | 37 | 10.2 | 30 | A | Worse |
| 2 | 67 | 10.4 | 70 | A | Worse |
| 3 | 42 | 10.4 | 100 | A | Static |
| 4 | 56 | 12.5 | 80 | A | Worse |
| 5 | 60 | 9.5 | 0 | A | Static |
| 6 | 62 | 13.7 | 10 | A | Worse |
Deprecated Syntax
# dataA = data[data[:Treatment] .== "A", :]
Warning: `getindex(df::DataFrame, col_ind::ColumnIndex)` is deprecated, use `df[!, col_ind]` instead.
Julia DataFrames
Filtering DataFrame
New Syntax
Syntax explained:
- from original "data" (type DataFrames)
- create new "dataA" (type DataFrames)
- filter indices in column "Treatment" with values equal to "A"
- include ALL COLUMNS indicated by ":"
- Show the first 6 rows
dataA = data[isequal.(data.Treatment, "A"), : ]
first(dataA, 6)
6 rows × 5 columns
| Age | WCC | CRP | Treatment | Result | |
|---|---|---|---|---|---|
| Int64 | Float64 | Int64 | String | String | |
| 1 | 37 | 10.2 | 30 | A | Worse |
| 2 | 67 | 10.4 | 70 | A | Worse |
| 3 | 42 | 10.4 | 100 | A | Static |
| 4 | 56 | 12.5 | 80 | A | Worse |
| 5 | 60 | 9.5 | 0 | A | Static |
| 6 | 62 | 13.7 | 10 | A | Worse |
Deprecated Syntax
# dataA = data[data[:Treatment] .== "A", :]
Warning: `getindex(df::DataFrame, col_ind::ColumnIndex)` is deprecated, use `df[!, col_ind]` instead.
Julia packages (Pkg)
Here are the Julia packages I have been using so far, I keep this list in case I need to re-install Julia.
Un-comment, install and pre-compile the package you need:
import Pkg
# Pkg.add("Atom")
# using Atom
# Pkg.add("BinDeps")
# using BinDeps
# Pkg.add("CSV")
# using CSV
# Pkg.add("CUDAapi")
# using CUDAapi
# Pkg.add("Calculus")
# using Calculus
# Pkg.add("CodecZlib")
# using CodecZlib
# Pkg.add("Codecs")
# using Codecs
# Pkg.add("ColorTypes")
# using ColorTypes
# Pkg.add("Colors")
# using Colors
# Pkg.add("Combinatorics")
# using Combinatorics
# Pkg.add("Compat")
# using Compat
# Pkg.add("Compose")
# using Compose
# Pkg.add("Contour")
# using Contour
# Pkg.add("DataArrays")
# using DataArrays
# Pkg.add("DataFrames")
# using DataFrames
# Pkg.add("DataStructures")
# using DataStructures
# Pkg.add("Distances")
# using Distances
# Pkg.add("Distributions")
# using Distributions
# Pkg.add("FileIO")
# using FileIO
# Pkg.add("FixedPointNumbers")
# using FixedPointNumbers
# Pkg.add("Flux")
# using Flux
# Pkg.add("ForwardDiff")
# using ForwardDiff
# Pkg.add("GLM")
# using GLM
# Pkg.add("GR")
# using GR
# Pkg.add("GZip")
# using GZip
# Pkg.add("GeometryBasics")
# using GeometryBasics
# Pkg.add("Hexagons")
# using Hexagons
# Pkg.add("HypothesisTests")
# using HypothesisTests
# Pkg.add("IJulia")
# using IJulia
# Pkg.add("JSON")
# using JSON
# Pkg.add("Juno")
# using Juno
# Pkg.add("KernelDensity")
# using KernelDensity
# Pkg.add("Knet")
# using Knet
# Pkg.add("Lathe")
# using Lathe
# Pkg.add("Loess")
# using Loess
# Pkg.add("Measures")
# using Measures
# Pkg.add("Metalhead")
# using Metalhead
# Pkg.add("NaNMath")
# using NaNMath
# Pkg.add("OffsetArrays")
# using OffsetArrays
# Pkg.add("Optim")
# using Optim
# Pkg.add("PDMats")
# using PDMats
# Pkg.add("Parameters")
# using Parameters
# Pkg.add("Plots")
# using Plots
# Pkg.add("Polynomials")
# using Polynomials
# Pkg.add("Primes")
# using Primes
# Pkg.add("PyCall")
# using PyCall
# Pkg.add("PyPlot")
# using PyPlot
# Pkg.add("QuartzImageIO")
# using QuartzImageIO
# Pkg.add("RDatasets")
# using RDatasets
# Pkg.add("Reexport")
# using Reexport
# Pkg.add("Rmath")
# using Rmath
# Pkg.add("Roots")
# using Roots
# Pkg.add("Showoff")
# using Showoff
# Pkg.add("SortingAlgorithms")
# using SortingAlgorithms
# Pkg.add("StaticArrays")
# using StaticArrays
# Pkg.add("StatsBase")
# using StatsBase
# Pkg.add("StatsFuns")
# using StatsFuns
# Pkg.add("StatsPlots")
# using StatsPlots
# Pkg.add("TensorFlow")
# using TensorFlow
# Pkg.add("TextAnalysis")
# using TextAnalysis
# Pkg.add("TinySegmenter")
# using TinySegmenter
# Pkg.add("URIParser")
# using URIParser
# Pkg.add("UnicodePlots")
# using UnicodePlots
# Pkg.add("WordTokenizers")
# using WordTokenizers
# Pkg.add("Dates")
# using Dates
# Pkg.add("DelimitedFiles")
# using DelimitedFiles
# Pkg.add("SHA")
# using SHA
# Pkg.add("Statistics")
# using Statistics
Julia packages (Pkg)
Here are the Julia packages I have been using so far, I keep this list in case I need to re-install Julia.
Un-comment, install and pre-compile the package you need:
import Pkg
# Pkg.add("Atom")
# using Atom
# Pkg.add("BinDeps")
# using BinDeps
# Pkg.add("CSV")
# using CSV
# Pkg.add("CUDAapi")
# using CUDAapi
# Pkg.add("Calculus")
# using Calculus
# Pkg.add("CodecZlib")
# using CodecZlib
# Pkg.add("Codecs")
# using Codecs
# Pkg.add("ColorTypes")
# using ColorTypes
# Pkg.add("Colors")
# using Colors
# Pkg.add("Combinatorics")
# using Combinatorics
# Pkg.add("Compat")
# using Compat
# Pkg.add("Compose")
# using Compose
# Pkg.add("Contour")
# using Contour
# Pkg.add("DataArrays")
# using DataArrays
# Pkg.add("DataFrames")
# using DataFrames
# Pkg.add("DataStructures")
# using DataStructures
# Pkg.add("Distances")
# using Distances
# Pkg.add("Distributions")
# using Distributions
# Pkg.add("FileIO")
# using FileIO
# Pkg.add("FixedPointNumbers")
# using FixedPointNumbers
# Pkg.add("Flux")
# using Flux
# Pkg.add("ForwardDiff")
# using ForwardDiff
# Pkg.add("GLM")
# using GLM
# Pkg.add("GR")
# using GR
# Pkg.add("GZip")
# using GZip
# Pkg.add("GeometryBasics")
# using GeometryBasics
# Pkg.add("Hexagons")
# using Hexagons
# Pkg.add("HypothesisTests")
# using HypothesisTests
# Pkg.add("IJulia")
# using IJulia
# Pkg.add("JSON")
# using JSON
# Pkg.add("Juno")
# using Juno
# Pkg.add("KernelDensity")
# using KernelDensity
# Pkg.add("Knet")
# using Knet
# Pkg.add("Lathe")
# using Lathe
# Pkg.add("Loess")
# using Loess
# Pkg.add("Measures")
# using Measures
# Pkg.add("Metalhead")
# using Metalhead
# Pkg.add("NaNMath")
# using NaNMath
# Pkg.add("OffsetArrays")
# using OffsetArrays
# Pkg.add("Optim")
# using Optim
# Pkg.add("PDMats")
# using PDMats
# Pkg.add("Parameters")
# using Parameters
# Pkg.add("Plots")
# using Plots
# Pkg.add("Polynomials")
# using Polynomials
# Pkg.add("Primes")
# using Primes
# Pkg.add("PyCall")
# using PyCall
# Pkg.add("PyPlot")
# using PyPlot
# Pkg.add("QuartzImageIO")
# using QuartzImageIO
# Pkg.add("RDatasets")
# using RDatasets
# Pkg.add("Reexport")
# using Reexport
# Pkg.add("Rmath")
# using Rmath
# Pkg.add("Roots")
# using Roots
# Pkg.add("Showoff")
# using Showoff
# Pkg.add("SortingAlgorithms")
# using SortingAlgorithms
# Pkg.add("StaticArrays")
# using StaticArrays
# Pkg.add("StatsBase")
# using StatsBase
# Pkg.add("StatsFuns")
# using StatsFuns
# Pkg.add("StatsPlots")
# using StatsPlots
# Pkg.add("TensorFlow")
# using TensorFlow
# Pkg.add("TextAnalysis")
# using TextAnalysis
# Pkg.add("TinySegmenter")
# using TinySegmenter
# Pkg.add("URIParser")
# using URIParser
# Pkg.add("UnicodePlots")
# using UnicodePlots
# Pkg.add("WordTokenizers")
# using WordTokenizers
# Pkg.add("Dates")
# using Dates
# Pkg.add("DelimitedFiles")
# using DelimitedFiles
# Pkg.add("SHA")
# using SHA
# Pkg.add("Statistics")
# using Statistics
"Rata Die". Counting Days since...
Counting Days since...
https://en.wikipedia.org/wiki/Rata_Die
# col1 is an exported column of dates
lastDay = 54 # last row in the column sorted by the date
daysSince(x) = Dates.datetime2rata(x) - Dates.datetime2rata(col1[lastDay])
arrayDays = Array{Int64}(undef, lastDay) # array size is 54
for i = 1:lastDay
arrayDays[i] = daysSince(col1[i])
end
arrayDays
Output:
54-element Array{Int64,1}:
613
606
599
592
582
575
568
554
547
540
533
526
512
⋮
"Rata Die". Counting Days since...
Counting Days since...
https://en.wikipedia.org/wiki/Rata_Die
# col1 is an exported column of dates
lastDay = 54 # last row in the column sorted by the date
daysSince(x) = Dates.datetime2rata(x) - Dates.datetime2rata(col1[lastDay])
arrayDays = Array{Int64}(undef, lastDay) # array size is 54
for i = 1:lastDay
arrayDays[i] = daysSince(col1[i])
end
arrayDays
Output:
54-element Array{Int64,1}:
613
606
599
592
582
575
568
554
547
540
533
526
512
⋮
Flux: The Julia Machine Learning Library
Flux is a machine learning library writer in Julia language.
Installation
(v1.3) pkg> add Flux
Flux: The Julia Machine Learning Library
Flux is a machine learning library writer in Julia language.
Installation
(v1.3) pkg> add Flux
Julia language, read delimited files (CSV) with "readdlm"
When trying to execute:
wikiEVDraw = readdlm("wikipediaEVDraw.csv", ',') # getting quotes right is important!
I get the following error:
UndefVarError: readdlm not defined.
help?> readdlm search: readdir Couldn't find readdlm Perhaps you meant readdir, read, read!, real or readchomp No documentation found. Binding readdlm does not exist.
In this case use:
using DelimitedFiles wikiEVDraw = readdlm("wikipediaEVDraw.csv", ',') # getting quotes right is important!
Julia language, read delimited files (CSV) with "readdlm"
When trying to execute:
wikiEVDraw = readdlm("wikipediaEVDraw.csv", ',') # getting quotes right is important!
I get the following error:
UndefVarError: readdlm not defined.
help?> readdlm search: readdir Couldn't find readdlm Perhaps you meant readdir, read, read!, real or readchomp No documentation found. Binding readdlm does not exist.
In this case use:
using DelimitedFileswikiEVDraw = readdlm("wikipediaEVDraw.csv", ',') # getting quotes right is important!
Using Julia Language with AWS Lambda functions.
Here is a Julia language library to operate with AWS Lamda functions:
https://github.com/samoconnor/AWSLambda.jl#deploy-a-julia-lambda-function
Using Julia Language with AWS Lambda functions.
Here is a Julia language library to operate with AWS Lamda functions:
https://github.com/samoconnor/AWSLambda.jl#deploy-a-julia-lambda-function
Julia
Julia
Arrays in Julia Language
Way to create an Array in Julia language:
A simple way of creating an array
array18 = fill(18, 4) # values of 18, 4 rows
4-element Array{Int64,1}:
18
18
18
18Float64, 2-dimensional, 4-rows, 3-columns
A = Array{Float64,2}(undef, 4,3)
# Array of floats, 2-dimentional, populate with undefiled data, 4-rows, 3-columns
4×3 Array{Float64,2}:
2.40692e-314 5.0e-324 1.5e-323
2.39671e-314 2.40692e-314 1.5e-323
2.40692e-314 2.40692e-314 1.0e-323 2.40692e-314 2.40692e-314 2.38725e-314
A[1,1] = 123
A
4×3 Array{Float64,2}:
123.0 5.0e-324 2.5e-323
2.38296e-314 2.38338e-314 2.5e-323
2.38338e-314 2.38338e-314 1.0e-323
2.38338e-314 2.38338e-314 2.64889e-32Abstract Type Integer
A = Array{Integer}(undef,2,3)
2×3 Array{Integer,2}:
#undef #undef #undef
#undef #undef #undefConcreate Type Int64
A = Array{Int64}(undef,2,3)
2×3 Array{Int64,2}:
4826207760 4826207824 4826207888
4826207792 4826207856 4825801360Reference:
Arrays in Julia Language
Way to create an Array in Julia language:
A simple way of creating an array
array18 = fill(18, 4) # values of 18, 4 rows
4-element Array{Int64,1}:
18
18
18
18Float64, 2-dimensional, 4-rows, 3-columns
A = Array{Float64,2}(undef, 4,3)
# Array of floats, 2-dimentional, populate with undefiled data, 4-rows, 3-columns
4×3 Array{Float64,2}:
2.40692e-314 5.0e-324 1.5e-323
2.39671e-314 2.40692e-314 1.5e-323
2.40692e-314 2.40692e-314 1.0e-323 2.40692e-314 2.40692e-314 2.38725e-314
A[1,1] = 123
A
4×3 Array{Float64,2}:
123.0 5.0e-324 2.5e-323
2.38296e-314 2.38338e-314 2.5e-323
2.38338e-314 2.38338e-314 1.0e-323
2.38338e-314 2.38338e-314 2.64889e-32Abstract Type Integer
A = Array{Integer}(undef,2,3)
2×3 Array{Integer,2}:
#undef #undef #undef
#undef #undef #undefConcreate Type Int64
A = Array{Int64}(undef,2,3)
2×3 Array{Int64,2}:
4826207760 4826207824 4826207888
4826207792 4826207856 4825801360Reference:
Special Characters used for Math, ML, Logic in Jupyther Lab
Here is a quick cheat sheet of useful Unicode characters you can use in Jupyther Lab and Julia language:
Greek Alphabet
α \alpha
β \beta
γ \gamma
∇ \delta
λ \lambda
μ \mu
Hebrew
Machine Learning
Math
∡ \measuredangle∑ \sum
± \pm (plus minus)
⌀ \diameter
0° 0\degree
Sets
Logic
∴ \thereforeSpecial Characters used for Math, ML, Logic in Jupyther Lab
Here is a quick cheat sheet of useful Unicode characters you can use in Jupyther Lab and Julia language:
Greek Alphabet
α \alpha
β \beta
γ \gamma
∇ \delta
λ \lambda
μ \mu
Hebrew
Machine Learning
Math
∡ \measuredangle∑ \sum
± \pm (plus minus)
⌀ \diameter
0° 0\degree
Sets
Logic
∴ \thereforeUsing Linear Regression with Julia Language
Linear Regression
What is a Linear Regression?
Selecting the best "fit" line to predict the data.
Calculating the deviations (the error)
Using Linear Regression with Julia Language
Linear Regression
What is a Linear Regression?
Selecting the best "fit" line to predict the data.
Calculating the deviations (the error)
Post Scriptum
I am preparing to cancel the subscription to the e-mail newsletter that sends my articles.
Follow me on:
X.com (Twitter)
Google Scholar
Popular Recent Posts
-
Keishin Kata (敬心形) of Shobudo (正武道) karate kei (敬) respect, reverence, or honor someone or something shin (心) heart or mind kata (形) fo...
-
Before arriving in Okinawa, several experiences prepared me for what I would eventually learn there. Karate was the first. It introduced me ...
-
I came across Ruri Ohama mentioning a book by Takafumi Horie and Yoichi Ochiai titled: “Job Atlas for 10 Years From Now. How Will You Live i...
-
Please look at the newer post: http://ukitech.blogspot.com/2009/09/eclipse-35-galileo-and-gwt-m2-svn.html 1) Upload a new version of Eclipse...
-
I have a habit of "stopping to smell the roses", or as in today's case, to take a photo of baby mushrooms on the forest floor....
-
http://code.google.com/apis/socialgraph/
-
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space or Unable to execute dex: Java heap space Java h...
-
Step 1: Register you app with Facebook. Sign in to Facebook using your standard credentials. Navigate to http://www.facebook.com/developer...
-
Many online videos warn about vegetables you should never eat, especially those rich in oxalates. The tone is dramatic. The reality is much ...
Most Popular Articles
-
Affordance as a Function of Intent and Action? As a person passionate about Behavioral Sciences, I found myself unable to shake the impre...
-
Step 1: Register you app with Facebook. Sign in to Facebook using your standard credentials. Navigate to http://www.facebook.com/developer...
-
Please look at the newer post: http://ukitech.blogspot.com/2009/09/eclipse-35-galileo-and-gwt-m2-svn.html 1) Upload a new version of Eclipse...
-
Creating Android ROS nodes to: - add control UI (HMI) - utilize existing phone sensors: -- gyroscope -- GPS -- compass -- camera - do...
-
In this tutorial we will learn how to install the Intellij IDEA database plugin. Start with opening Settings > search for plugins ...
-
Installing TuriCreate on Python 3.6 Anaconda Environment 1) Check what Python version Apple Turi Create supports https://github.com/ap...
-
In this tutorial we will overview integration basics of Android Studio and Gradle build tools.
-
This tutorial shows you how to change the code lower/upper case of code in Android Studio.
-
ImportError : No module named 'sklearn.model_selection' Before doing the embarrassing things I did below, read this: Setting Jupy...
-
This minimal PyTorch example implements a custom recurrent neural network (RNN) cell from first principles, showing how sequence memory eme...