Skip to content

Instantly share code, notes, and snippets.

@hpoit
hpoit / GraphQL_schemas_types.jl
Last active April 8, 2019 22:24
GraphQL_schemas_and_types.jl
# Object types and fields
struct Character
name::String
appearsIn::EpisodeArray
end
# Arguments
mutable struct Starship
@hpoit
hpoit / gist:7c6ce575fc5a4a274ed8c9cb6eab4a19
Last active April 8, 2019 17:56
Cascadia.jl working webscraping example
# https://github.com/Algocircle/Cascadia.jl#webscraping-example
using Cascadia
using Gumbo
using HTTP
# using Requests (deprecated)
r = HTTP.get("http://stackoverflow.com/questions/tagged/julia-lang")
h = parsehtml(String(r.body))
@hpoit
hpoit / NRLMSISE-00.for
Created June 12, 2018 02:19
MSIS atmosphere model
C-----------------------------------------------------------------------
SUBROUTINE GTD7(IYD,SEC,ALT,GLAT,GLONG,STL,F107A,F107,AP,MASS,D,T)
C
C NRLMSISE-00
C -----------
C Neutral Atmosphere Empirical Model from the surface to lower
C exosphere
C
C NEW FEATURES:
C *Extensive satellite drag database used in model generation
@hpoit
hpoit / regu_loss.jl
Created June 4, 2018 00:14
regularizing loss
julia> using Flux, Flux.Data.MNIST
julia> using Flux: onehotbatch, argmax, crossentropy, throttle
julia> using Base.Iterators: repeated
julia> # using CuArrays
# Classify MNIST digits with a simple multi-layer-perceptron
@hpoit
hpoit / building MAT
Last active June 1, 2018 21:06
building MAT
julia> Pkg.add("MAT")
INFO: Cloning cache of Blosc from https://github.com/stevengj/Blosc.jl.git
INFO: Cloning cache of BufferedStreams from https://github.com/BioJulia/BufferedStreams.jl.git
INFO: Cloning cache of CMakeWrapper from https://github.com/rdeits/CMakeWrapper.jl.git
INFO: Cloning cache of HDF5 from https://github.com/JuliaIO/HDF5.jl.git
INFO: Cloning cache of Libz from https://github.com/BioJulia/Libz.jl.git
INFO: Cloning cache of MAT from https://github.com/JuliaIO/MAT.jl.git
INFO: Installing Blosc v0.5.0
INFO: Installing BufferedStreams v0.4.0
INFO: Installing CMakeWrapper v0.1.0
@hpoit
hpoit / ang_assignment2-v03.jl
Last active May 26, 2018 01:11
Coursera ML week 3 - assignment 2 v0.3 - implementing Logit model on two datasets
# Logit mode, v0.3
using CSV, Plots; pyplot();
data = CSV.read("/Users/kevinliu/Documents/machine-learning-ex2/ex2/ex2data1.txt", datarow=1)
X = hcat(ones(100,1), Matrix(data[:, [1,2]]))
y = Vector(data[:, 3])
# Sigmoid function
function sigmoid(z)
@hpoit
hpoit / ang_assignment2-v02.jl
Last active May 18, 2018 13:40
Coursera ML week 3 - assignment 2 v0.2 - implementing Logit model on two datasets
# Logit model, v0.2
using CSV, Plots; pyplot();
data = CSV.read("/Users/kevinliu/Documents/machine-learning-ex2/ex2/ex2data1.txt", datarow=1)
X = hcat(ones(100,1), Matrix(data[:, [1,2]]))
y = Vector(data[:, 3])
# Sigmoid function
function sigmoid(z)
@hpoit
hpoit / ang_assignment2-v01.jl
Last active May 24, 2018 13:49
Coursera ML week 3 - assignment 2 v0.1 - implementing Logit model on two datasets
# Visualize the data
using CSV, Plots; pyplot();
data = CSV.read("/Users/kevinliu/Documents/machine-learning-ex2/ex2/ex2data1.txt", datarow=1)
X = data[:, [1,2]]; y = data[:, 3];
pos = find(y); neg = find(iszero, y); # or neg = find(t -> t == 0, y);
scatter(xaxis=("exam 1 score", (30,100), 30:10:100))
scatter!(yaxis=("exam 2 score", (30,100), 30:10:100))
scatter!(X[pos, 1], X[pos, 2], markershape=:+, label="admitted")
@hpoit
hpoit / ang_assignment1b.jl
Last active May 17, 2018 02:12
Coursera ML week 2 - assignment 1b - parts 3b-4
# Linear regression
# part 3b: plotting linear fit
using Plots, CSV
data = CSV.read("/Users/kevinliu/Downloads/machine-learning-ex1/ex1/ex1data1.txt", datarow=1) # or data = rand(97,2)
m = length(data[:, 2])
X = hcat(ones(m, 1), data[:, 1]);
y = data[:, 2]
#thetasA = [-4.090664703327588; -2.386107508525324]; # incorrect when compared to scatter()
thetasB = [0.4559997241594341; 2.786203914586563];
@hpoit
hpoit / ang_assignment1a.jl
Last active May 7, 2018 22:08
Coursera ML week 2 - assignment 1a - parts 1-3a
# Linear regression
# part 1: basic function, A = eye(5), trivial
# part 2: plotting
julia> using CSV
julia> data = CSV.read("/Users/kevinliu/Downloads/machine-learning-ex1/ex1/ex1data1.txt", datarow=1)
97×2 DataFrames.DataFrame
│ Row │ Column1 │ Column2 │