Skip to content

Commit 6a3c2a2

Browse files
committed
julia project setup
1 parent efdab08 commit 6a3c2a2

File tree

8 files changed

+2677
-130
lines changed

8 files changed

+2677
-130
lines changed

JuliaExamples/Manifest.toml

+2,576
Large diffs are not rendered by default.

JuliaExamples/Project.toml

+5
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ Manopt = "0fc0a36d-df90-57f3-8f93-d78a9fc72bb5"
1919
MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
2020
MultivariateStats = "6f286f6a-111f-5878-ab1e-185364afe411"
2121
OpenSSL = "4d8831e6-92b7-49fb-bdf8-b643e874388c"
22+
PersistenceDiagrams = "90b4794c-894b-4756-a0f8-5efeb5ddf7ae"
2223
PlotThemes = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a"
2324
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
2425
Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
26+
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
2527
Ripserer = "aa79e827-bd0b-42a8-9f10-2b302677a641"
2628
SimpleWeightedGraphs = "47aef6b3-ad0c-573a-a1e2-d07658019622"
2729
StatisticalGraphics = "8341d8ab-e5ae-4f11-aa21-e11c5cc71259"
30+
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
31+
UMAP = "c4f8c510-2410-5be4-91d7-4fbaeb39457e"
32+
VegaLite = "112f6efa-9a02-5b7d-90c0-432ed331239a"

JuliaExamples/Project.toml.full

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[deps]
2+
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
3+
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
4+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
5+
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
6+
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
7+
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
8+
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
9+
InMemoryDatasets = "5c01b14b-ab03-46ff-b164-14c663efdd9f"
10+
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
11+
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
12+
ManifoldLearning = "06eb3307-b2af-5a2a-abea-d33192699d32"
13+
Manopt = "0fc0a36d-df90-57f3-8f93-d78a9fc72bb5"
14+
MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
15+
MultivariateStats = "6f286f6a-111f-5878-ab1e-185364afe411"
16+
OpenSSL = "4d8831e6-92b7-49fb-bdf8-b643e874388c"
17+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
18+
Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
19+
Ripserer = "aa79e827-bd0b-42a8-9f10-2b302677a641"
20+
SimpleWeightedGraphs = "47aef6b3-ad0c-573a-a1e2-d07658019622"
21+
StatisticalGraphics = "8341d8ab-e5ae-4f11-aa21-e11c5cc71259"

JuliaExamples/src/image_data.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ end
1414

1515
function load_dataset(root)
1616
files = map(x->joinpath(root, x), readdir(root))
17-
return mappedarray(p -> load_image(p), files)
17+
mappedarray(p -> load_image(p), files)
1818
end
1919

2020
function images_dataset_to_vectors_dataset(img_dataset, img_size=(32,32))
2121
img_flat_size = img_size[1] * img_size[2]
22-
resized_img_coil_dataset = map(img -> imresize(img, img_size), img_dataset)
23-
map(img -> real.(reshape(float(img), img_flat_size)), resized_img_coil_dataset)
22+
resized_img_coil_dataset = mappedarray(img -> imresize(img, img_size), img_dataset)
23+
mappedarray(img -> real.(reshape(float(img), img_flat_size)), resized_img_coil_dataset)
2424
end

JuliaExamples/src/manifold_learning.jl

Whitespace-only changes.

notebooks/julia_coil.jl

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### A Pluto.jl notebook ###
2-
# v0.19.29
2+
# v0.19.9
33

44
using Markdown
55
using InteractiveUtils
@@ -35,6 +35,12 @@ md"""
3535
## Setup
3636
"""
3737

38+
# ╔═╡ 5f72520b-017a-4428-836a-b4665e97fa43
39+
2 + 2
40+
41+
# ╔═╡ 943ace02-4e25-4474-95a4-500c796daf3e
42+
43+
3844
# ╔═╡ 59a31fc2-a9d1-4857-b18e-a2591f4327b0
3945
md"""
4046
## Imports
@@ -128,6 +134,17 @@ struct ManifoldLearner
128134
reduced_df :: Union{DataFrame, Nothing}
129135
end
130136

137+
# ╔═╡ d6dda024-56c1-4614-aa7d-ce721e09a0f7
138+
function fit_manifold_learner(args :: ManifoldLearnerArgs, data)
139+
(reducer, reduced_df) = fit_manifold_learner_impl(args.method, args.dim, args.k, data)
140+
ManifoldLearner(
141+
reducer,
142+
args,
143+
data,
144+
reduced_df
145+
)
146+
end
147+
131148
# ╔═╡ 2557d853-06fb-4ffd-8310-f9fc6abe3f47
132149
begin
133150
function make_reduced_dataframe(X_reduced)
@@ -156,17 +173,6 @@ function fit_manifold_learner_impl(method :: ManifoldLearningType, dim, k, data)
156173
(reducer, make_reduced_dataframe(ManifoldLearning.predict(reducer)'))
157174
end
158175

159-
# ╔═╡ d6dda024-56c1-4614-aa7d-ce721e09a0f7
160-
function fit_manifold_learner(args :: ManifoldLearnerArgs, data)
161-
(reducer, reduced_df) = fit_manifold_learner_impl(args.method, args.dim, args.k, data)
162-
ManifoldLearner(
163-
reducer,
164-
args,
165-
data,
166-
reduced_df
167-
)
168-
end
169-
170176
# ╔═╡ c5b61420-7cfe-4091-82eb-d270c690456a
171177
function add_classes(df, classes)
172178
df[!, "class"] = classes
@@ -309,6 +315,8 @@ end
309315
# ╔═╡ Cell order:
310316
# ╠═c7fdaf8f-5d97-4a71-b478-002d60b9e741
311317
# ╠═e3e020ac-6aaf-11ee-0d9a-85e0beb5ca6e
318+
# ╠═5f72520b-017a-4428-836a-b4665e97fa43
319+
# ╠═943ace02-4e25-4474-95a4-500c796daf3e
312320
# ╠═59a31fc2-a9d1-4857-b18e-a2591f4327b0
313321
# ╠═70d7489f-45fc-4677-9fbf-3a6916130530
314322
# ╠═94c2fb01-09db-4a90-b824-28cac32619cf

notebooks/julia_general.jl

-102
This file was deleted.

notebooks/math_ml/tda_julia.jl

+52-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### A Pluto.jl notebook ###
2-
# v0.19.29
2+
# v0.19.9
33

44
using Markdown
55
using InteractiveUtils
@@ -16,9 +16,12 @@ end
1616
begin
1717
using Ripserer
1818
using Plots, PlotThemes
19-
19+
using Random
2020
using Images, FileIO
21+
using LinearAlgebra
2122
theme(:juno)
23+
24+
rng = MersenneTwister(42)
2225
end
2326

2427
# ╔═╡ 10481fbc-6a08-11ee-1c4f-2b0f04f82767
@@ -36,20 +39,21 @@ md"""
3639
## Persistent homology with Ripser
3740
"""
3841

42+
# ╔═╡ 3d29a334-cece-4ba4-b38b-ec97eecff935
43+
44+
3945
# ╔═╡ 4ae94cd9-2b69-4e22-8dde-67a1a0cb9b4d
4046
function noisy_circle(n; r1=1, r2=1, noise=0.1)
41-
points = NTuple{2,Float64}[]
42-
for _ in 1:n
43-
θ = 2π * rand()
44-
point = (
45-
r1 * sin(θ) + noise * rand() - noise / 2,
46-
r2 * cos(θ) + noise * rand() - noise / 2,
47-
)
48-
push!(points, point)
49-
end
50-
return points
47+
X = randn(rng, Float64, (n, 3))
48+
points = Tuple{Float64,3}[]
49+
for row in eachrow(X)
50+
push!(points, Tuple(row))
51+
end
5152
end
5253

54+
# ╔═╡ e22bb3a8-0185-45e6-8824-365eb52c6640
55+
56+
5357
# ╔═╡ b95d2a4e-b5d8-4ec3-8baa-23bc7db5beea
5458
begin
5559
points = noisy_circle(100; noise=0)
@@ -61,13 +65,17 @@ begin
6165
aspect_ratio=1,
6266
xlim=(-2.2, 2.2),
6367
ylim=(-2.2, 2.2),
68+
zlim=(-2.2, 2.2)
6469
title="Data",
6570
)
6671
plt_diag = plot(result; infinity=3)
6772

6873
plot(plt_pts, plt_diag; size=(800, 400))
6974
end
7075

76+
# ╔═╡ 3f9f4667-4321-4d4e-b6c5-ae30c5d690b5
77+
78+
7179
# ╔═╡ fa674ef0-aab6-432b-a5ac-4e3bffa37a80
7280
md"""
7381
## COIL20
@@ -103,7 +111,7 @@ end
103111
typeof(images[1])
104112

105113
# ╔═╡ 6070ff3e-6d8d-48eb-86c6-a96623f74014
106-
114+
1 + 2
107115

108116
# ╔═╡ d2c84a1e-c7ad-4178-a6dd-b59d70385da9
109117
images[1] - 1
@@ -120,14 +128,45 @@ ceil((images[1] + images[2]) / 2)
120128
# ╔═╡ cdc1ca21-3568-4f08-b144-cc79a77f72a1
121129

122130

131+
# ╔═╡ 1f5ba155-abbc-4f1a-b5fa-a0051f89dbd4
132+
begin
133+
points = noisy_circle(100; noise=0)
134+
result = ripserer(points)
135+
136+
plt_pts = scatter(
137+
points;
138+
legend=false,
139+
aspect_ratio=1,
140+
xlim=(-2.2, 2.2),
141+
ylim=(-2.2, 2.2),
142+
zlim=(-2.2, 2.2),
143+
title="Data",
144+
)
145+
plt_diag = plot(result; infinity=3)
146+
147+
plot(plt_pts, plt_diag; size=(800, 400))
148+
end
149+
150+
# ╔═╡ 81a5a99b-dc3d-4643-a256-f83f0c0874a2
151+
begin
152+
X = randn(rng, Float64, (n, 3))
153+
points = Tuple{Float64,3}[]
154+
points
155+
end
156+
123157
# ╔═╡ Cell order:
124158
# ╠═10481fbc-6a08-11ee-1c4f-2b0f04f82767
125159
# ╠═6078059a-176d-4e95-92b8-7b39bdeff7cb
126160
# ╠═ec68f1f5-13ad-450f-8bd4-cfb15adb0e6c
127161
# ╠═b3ed9787-f333-4d4a-96e5-56a6541201fe
128162
# ╠═33fc86a7-f9ef-4ace-8593-54d1a7eeb4b9
163+
# ╠═81a5a99b-dc3d-4643-a256-f83f0c0874a2
164+
# ╠═3d29a334-cece-4ba4-b38b-ec97eecff935
129165
# ╠═4ae94cd9-2b69-4e22-8dde-67a1a0cb9b4d
166+
# ╠═e22bb3a8-0185-45e6-8824-365eb52c6640
167+
# ╠═1f5ba155-abbc-4f1a-b5fa-a0051f89dbd4
130168
# ╠═b95d2a4e-b5d8-4ec3-8baa-23bc7db5beea
169+
# ╠═3f9f4667-4321-4d4e-b6c5-ae30c5d690b5
131170
# ╠═fa674ef0-aab6-432b-a5ac-4e3bffa37a80
132171
# ╠═4adadda3-9459-4122-9417-917bd32e73f9
133172
# ╠═e4467766-25f7-44f7-b028-33ff8aac7306

0 commit comments

Comments
 (0)