nixify notebook
This commit is contained in:
parent
456f1234a2
commit
3c21d9a900
|
@ -1,30 +1,32 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
"nixpkgs-lib": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1687709756,
|
||||
"narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7",
|
||||
"lastModified": 1725234343,
|
||||
"narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "567b938d64d4b4112ee253b9274472dc3a346eb6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1687898314,
|
||||
"narHash": "sha256-B4BHon3uMXQw8ZdbwxRK1BmxVOGBV4viipKpGaIlGwk=",
|
||||
"lastModified": 1725432240,
|
||||
"narHash": "sha256-+yj+xgsfZaErbfYM3T+QvEE2hU7UuE+Jf0fJCJ8uPS0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e18dc963075ed115afb3e312b64643bf8fd4b474",
|
||||
"rev": "ad416d066ca1222956472ab7d0555a6946746a80",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -36,8 +38,9 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"systems": "systems"
|
||||
}
|
||||
},
|
||||
"systems": {
|
64
flake.nix
Normal file
64
flake.nix
Normal file
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-parts = {
|
||||
url = "github:hercules-ci/flake-parts";
|
||||
inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||
};
|
||||
systems.url = "github:nix-systems/default";
|
||||
};
|
||||
|
||||
outputs = {flake-parts, ...} @ inputs:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
systems = import inputs.systems;
|
||||
|
||||
perSystem = {
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}: rec {
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = packages.notebooks.buildInputs;
|
||||
};
|
||||
|
||||
packages.notebooks = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "notebooks";
|
||||
|
||||
src = ./julia;
|
||||
dontUnpack = true;
|
||||
buildInputs = [
|
||||
(pkgs.julia.withPackages [
|
||||
"Pluto"
|
||||
"Plots"
|
||||
"Statistics"
|
||||
"PlutoUI"
|
||||
"LinearAlgebra"
|
||||
"StatsPlots"
|
||||
"Distributions"
|
||||
"MAT"
|
||||
"DSP"
|
||||
])
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
# copy the notebooks, Pluto needs write permission
|
||||
cp $src/notebook.jl index.jl
|
||||
cp $src/donnees.mat donnees.mat
|
||||
chmod +w index.jl
|
||||
|
||||
# julia needs permission to create .julia directory
|
||||
export HOME=$TMPDIR
|
||||
|
||||
# run and export the notebooks
|
||||
julia $src/export_html.jl index.jl
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp index.html $out
|
||||
cp -r $src/content $out
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
13
julia/.vscode/settings.json
vendored
13
julia/.vscode/settings.json
vendored
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"editor.formatOnSave": true,
|
||||
"files.insertFinalNewline": true,
|
||||
"editor.trimAutoWhitespace": true,
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"terminal.integrated.env.linux": {
|
||||
"JULIA_PROJECT": "@."
|
||||
},
|
||||
"[julia]": {
|
||||
"editor.tabSize": 2,
|
||||
"editor.insertSpaces": true
|
||||
}
|
||||
}
|
42
julia/export_html.jl
Normal file
42
julia/export_html.jl
Normal file
|
@ -0,0 +1,42 @@
|
|||
using Pluto
|
||||
|
||||
function export_html(notebook_path, html_path)
|
||||
# load notebook
|
||||
notebook = Pluto.load_notebook(Pluto.tamepath(notebook_path));
|
||||
topology = Pluto.updated_topology(notebook.topology, notebook, notebook.cells)
|
||||
|
||||
# create offline workspace
|
||||
workspace = Pluto.WorkspaceManager.make_workspace(
|
||||
(
|
||||
Pluto.ServerSession(),
|
||||
notebook,
|
||||
),
|
||||
is_offline_renderer=true,
|
||||
)
|
||||
|
||||
# run all the cells of the notebook
|
||||
for cell in notebook.cells
|
||||
Pluto.run_single!(
|
||||
workspace,
|
||||
cell,
|
||||
topology.nodes[cell],
|
||||
topology.codes[cell],
|
||||
)
|
||||
end
|
||||
|
||||
# convert notebook outputs to html
|
||||
html_contents = Pluto.generate_html(notebook);
|
||||
|
||||
# write to html file
|
||||
open(html_path, "w") do html_file
|
||||
write(html_file, html_contents);
|
||||
end
|
||||
end
|
||||
|
||||
# get cli args
|
||||
for arg in ARGS
|
||||
filename, _ = splitext(arg)
|
||||
html_path = filename * ".html"
|
||||
println("Exporting $arg to $html_path")
|
||||
export_html(arg, filename * ".html")
|
||||
end
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
julia
|
||||
ffmpeg-full # https://github.com/JuliaIO/FFMPEG.jl/issues/48#issuecomment-898340527
|
||||
patchelf
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
|
@ -372,7 +372,7 @@ begin
|
|||
# Estimation du degré de la courbe et de σ, par leave-one-out
|
||||
local d_estime_loo = degres[argmin(erreurs_leave_one_out)]
|
||||
local σ_estime_loo = std(erreurs_leave_one_out)
|
||||
|
||||
|
||||
Markdown.MD(
|
||||
Markdown.Admonition(
|
||||
"info", "Résultats", [Markdown.parse("""
|
||||
|
@ -382,7 +382,7 @@ begin
|
|||
|
||||
Leave-one-out : d=$(d_estime_loo), σ=$(round(σ_estime_loo, digits=2))
|
||||
""")]
|
||||
)
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -435,7 +435,7 @@ On peut montrer que le vecteur de paramètres estimé en moindres carrés est di
|
|||
|
||||
$$\beta \hookrightarrow \mathcal{N} ( \beta^*, \sigma^2 ( A^\intercal A )^{-1})$$
|
||||
|
||||
On trace alors sur la figure suivante, avec un tracé continu la distribution théorique des $\beta$, et via un histogramme la distribution que l'on obtient par estimation aux moindres carrés (sur un grand nombre de points, n=$(n))
|
||||
On trace alors sur la figure suivante, avec un tracé continu la distribution théorique des $\beta$, et via un histogramme la distribution que l'on obtient par estimation aux moindres carrés (sur un grand nombre de points, n=1000)
|
||||
"""
|
||||
|
||||
# ╔═╡ a8843a99-cd5d-47fa-810b-68b56e405af9
|
||||
|
@ -452,7 +452,6 @@ begin
|
|||
λ: $(λ_slider)
|
||||
|
||||
On observe que via les moindres carrés classiques, notre régression a souvent tendance à [overfitter](https://fr.wikipedia.org/wiki/Surapprentissage) les points d'apprentissage. Pour remédier à ce problème, nous pouvons introduire un hyperparamètre $\lambda$ qui nous permettra de pénaliser l'overfitting (par régularisation).
|
||||
|
||||
"""
|
||||
end
|
||||
|
||||
|
@ -2555,7 +2554,7 @@ html"""
|
|||
|
||||
# ╔═╡ 80b2e36a-5464-454a-a5cd-6980e89aa5b7
|
||||
md"""
|
||||
Un cas d'application de cette initialisation est de permettre la séparation de sources. En effet si nous initialisons nos matrices à partir de notes de piano et de violons, en coupant en deux nos matrices A et D finales nous sommes maintenant capable de séparer l'audio du violon et du piano.
|
||||
Un cas d'application de cette initialisation est de permettre la séparation de sources. En effet si nous initialisons nos matrices à partir de notes de piano et de violons, en coupant en deux nos matrices A et D finales nous sommes maintenant capable de séparer l'audio du violon et du piano.
|
||||
"""
|
||||
|
||||
# ╔═╡ af94b4a6-94bc-4a8e-956a-488c050a7b20
|
||||
|
@ -3953,27 +3952,30 @@ version = "1.4.1+0"
|
|||
# ╟─1ae5bc6d-16c4-40cb-846e-3b0e177fd0cf
|
||||
# ╟─b3634cc1-fb5f-4b7b-bfa3-08d1fb787c5f
|
||||
# ╟─73ed5f0e-4298-4308-bcb8-7c1245ebf0f5
|
||||
# ╟─d969e49e-0a0c-4bdf-aba2-835586c87e7f
|
||||
# ╟─c0615490-3d43-4c42-9ac6-c4fdd59aae7f
|
||||
# ╟─cc938f64-41f9-478b-a136-ae0cc55b5f48
|
||||
# ╟─aec0ff6e-ac6a-4104-83c1-f70e254602b9
|
||||
# ╟─dbffcc35-ba67-4468-b1b5-1c38a0fd971e
|
||||
# ╟─d969e49e-0a0c-4bdf-aba2-835586c87e7f
|
||||
# ╟─c0615490-3d43-4c42-9ac6-c4fdd59aae7f
|
||||
# ╟─ae8a3f9b-12cf-4802-8ae5-31546d82516d
|
||||
# ╠═7960408a-d922-43e2-9a61-4aaf0c9e6a39
|
||||
# ╟─7960408a-d922-43e2-9a61-4aaf0c9e6a39
|
||||
# ╟─b56c3502-4dd9-4446-acd9-dcb0c667803f
|
||||
# ╟─76279a22-3afe-46e1-829f-88f5dddfd55c
|
||||
# ╟─cde13c7c-fbc2-4a8d-9b82-7607d71bb4b1
|
||||
# ╟─a8843a99-cd5d-47fa-810b-68b56e405af9
|
||||
# ╠═c3f3a0c3-8523-43aa-8a8a-589f567399c9
|
||||
# ╟─c3f3a0c3-8523-43aa-8a8a-589f567399c9
|
||||
# ╟─f60fbae0-a6bd-4791-b38b-9e29ae801a07
|
||||
# ╟─b95121b9-4b58-4086-bbd8-ecd2893060dd
|
||||
# ╟─3ff18976-beb4-45ad-aa29-d511e5d3ad0a
|
||||
# ╟─c563818e-d117-47ce-abeb-5b048edad64e
|
||||
# ╟─650ab9f4-581b-4190-8dd0-91c6d4c86b6b
|
||||
# ╟─1b88eacd-754b-4b6b-a8e0-dd35ae37f248
|
||||
# ╟─acbab47e-2ab5-443a-8d78-f597a4ca08ed
|
||||
# ╟─230c1126-6717-4a93-9013-5f0c15616904
|
||||
# ╟─c563818e-d117-47ce-abeb-5b048edad64e
|
||||
# ╟─650ab9f4-581b-4190-8dd0-91c6d4c86b6b
|
||||
# ╟─5974ceb3-1e82-4183-9dca-35ccd6b9a9ba
|
||||
# ╟─fac7b990-552e-4353-8264-ba0840a95383
|
||||
# ╟─4bcfb185-4499-422d-9439-6ca4e30c4846
|
||||
# ╟─174dbb25-12ba-460d-a905-8223f8241964
|
||||
# ╟─27a1f0cc-a6bc-417e-9c58-6b63172f753f
|
||||
# ╟─c9e530b7-f5f6-4905-8c6c-69ea2440f57d
|
||||
# ╟─67a5b4cc-00dd-4f8f-a408-27f1d8c60e7c
|
||||
|
@ -3981,9 +3983,6 @@ version = "1.4.1+0"
|
|||
# ╟─8655b8fd-ef08-441f-9186-e2febce6e8f1
|
||||
# ╟─e16bb608-d97b-40eb-bf6b-4199ee4d1926
|
||||
# ╟─475aecd7-123f-4e4a-b004-90c2a8a951d8
|
||||
# ╟─fac7b990-552e-4353-8264-ba0840a95383
|
||||
# ╟─4bcfb185-4499-422d-9439-6ca4e30c4846
|
||||
# ╟─174dbb25-12ba-460d-a905-8223f8241964
|
||||
# ╟─59be55be-5847-4fa1-a4f6-ef8e0658da13
|
||||
# ╟─2e002135-2a74-47bb-92a6-520d84e85bf3
|
||||
# ╟─764c0716-5dd2-4d3c-9489-1dd92d29d7c7
|
||||
|
|
Loading…
Reference in a new issue