Skip to content

Commit

Permalink
deploy: 65426f3
Browse files Browse the repository at this point in the history
  • Loading branch information
baniasbaabe committed Apr 8, 2024
1 parent 719a8f7 commit 2023f70
Show file tree
Hide file tree
Showing 53 changed files with 306 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="book/Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="book/Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
31 changes: 31 additions & 0 deletions _sources/book/Miscellaneous/Chapter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,37 @@
"\n",
"It makes your life easier by enforcing writing descriptive commits."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Docker Best Practice: Use `.dockerignore`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"One Docker Tip:\n",
"\n",
"Use a `.dockerignore` file to avoid adding unnecessary files to the image.\n",
"\n",
"This will definitely reduce your Docker image size, but also more safe."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# .dockerignore\n",
".git\n",
".cache\n",
"*.md\n",
"!README*.md\n",
"README-secret.md\n",
".env"
]
}
],
"metadata": {
Expand Down
50 changes: 50 additions & 0 deletions _sources/book/machinelearning/modeltraining.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1889,6 +1889,56 @@
"alpha = [0.05, 0.20]\n",
"y_pred, y_pis = mapie_regressor.predict(X_test, alpha=alpha)"
]
},
{
"cell_type": "markdown",
"id": "bc7f6fab",
"metadata": {},
"source": [
"## Extra Components For scikit-learn with `scikit-lego`"
]
},
{
"cell_type": "markdown",
"id": "29e041d4",
"metadata": {},
"source": [
"scikit-learn is one of the most popular ML libraries.\n",
"\n",
"While it's easy to write custom components, it would be nice to have all of them in a single place.\n",
"\n",
"`scikit-lego` is such a library which contains many custom components like:\n",
"\n",
"- `DebugPipeline`, which adds debug information to pipelines\n",
"- `ImbalancedLinearRegression` to punish over-/underestimation of a model\n",
"- `add_lags` to add lag values to a DataFrame\n",
"- `ZeroInflatedRegressor` which predicts zero or applies a regression based on a classifier\n",
"\n",
"and many more!"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f2c86d37",
"metadata": {},
"outputs": [],
"source": [
"from sklearn.preprocessing import StandardScaler\n",
"from sklearn.pipeline import Pipeline\n",
"from sklego.preprocessing import RandomAdder\n",
"from sklego.mixture import GMMClassifier\n",
"\n",
"...\n",
"\n",
"pipeline = Pipeline([\n",
" (\"scale\", StandardScaler()),\n",
" (\"random_noise\", RandomAdder()),\n",
" (\"model\", GMMClassifier())\n",
"])\n",
"\n",
"..."
]
}
],
"metadata": {
Expand Down
70 changes: 70 additions & 0 deletions _sources/book/pythontricks/Chapter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,76 @@
" \n",
"print(Status.PENDING.value) # Output: 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Never use `eval`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"One big mistake in Python:\n",
"\n",
"Using `eval` in your code.\n",
"\n",
"`eval`, like the name suggests, evaluates a Python expression.\n",
"\n",
"The big problem: One could inject malicious code which will be evaluated."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def calculate(expression):\n",
" return eval(expression)\n",
" \n",
"print(calculate(\"5 + 5\"))\n",
"\n",
"# DON'T RUN THIS LINE OF CODE\n",
"print(calculate(\"__import__('os').system('rm -rf /')\"))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Never use `import *`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"One nooby Python mistake:\n",
"\n",
"Running `import *`.\n",
"\n",
"You will only pollute your namespace, leading to potential naming conflicts.\n",
"\n",
"Your code also becomes less readable and maintainable when it's not clear where each name is coming from.\n",
"\n",
"Remember \"_Explicit is better than implicit_\"."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Ugly\n",
"from module import *\n",
"\n",
"# Better\n",
"from module import Class1, Class2, Class3"
]
}
],
"metadata": {
Expand Down
28 changes: 28 additions & 0 deletions book/Miscellaneous/Chapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
</li>
<li class="toctree-l1 current active has-children"><a class="reference internal" href="index.html">15. Miscellaneous</a><input checked="" class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul class="current">
<li class="toctree-l2 current active"><a class="current reference internal" href="#">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down Expand Up @@ -420,11 +421,17 @@ <h2> Contents </h2>
</div>
<nav aria-label="Page">
<ul class="visible nav section-nav flex-column">
<li class="toc-h1 nav-item toc-entry"><a class="reference internal nav-link" href="#">15.1. Miscellaneous</a><ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#must-have-vscode-extensions-for-python">15.1.1. Must-Have VSCode Extensions for Python</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#project-setup-from-templates-with-cookiecutter">15.1.2. Project Setup from Templates with <code class="docutils literal notranslate"><span class="pre">cookiecutter</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#project-scaffolding-with-smol-developer">15.1.3. Project Scaffolding with <code class="docutils literal notranslate"><span class="pre">smol-developer</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#well-commits-with-commitizen">15.1.4. Well Commits with <code class="docutils literal notranslate"><span class="pre">commitizen</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#docker-best-practice-use-dockerignore">15.1.5. Docker Best Practice: Use <code class="docutils literal notranslate"><span class="pre">.dockerignore</span></code></a></li>
</ul>
</li>
<li class="toc-h1 nav-item toc-entry"><a class="reference internal nav-link" href="#dockerignore">15.2. .dockerignore</a></li>
</ul>

</nav>
</div>
</div>
Expand Down Expand Up @@ -479,6 +486,21 @@ <h2><span class="section-number">15.1.4. </span>Well Commits with <code class="d
<p>It helps you define committing rules, bump project versions and create a changelog.</p>
<p>It makes your life easier by enforcing writing descriptive commits.</p>
</section>
<section id="docker-best-practice-use-dockerignore">
<h2><span class="section-number">15.1.5. </span>Docker Best Practice: Use <code class="docutils literal notranslate"><span class="pre">.dockerignore</span></code><a class="headerlink" href="#docker-best-practice-use-dockerignore" title="Permalink to this heading">#</a></h2>
<p>One Docker Tip:</p>
<p>Use a <code class="docutils literal notranslate"><span class="pre">.dockerignore</span></code> file to avoid adding unnecessary files to the image.</p>
<p>This will definitely reduce your Docker image size, but also more safe.</p>
</section>
</section>
<section id="dockerignore">
<h1><span class="section-number">15.2. </span>.dockerignore<a class="headerlink" href="#dockerignore" title="Permalink to this heading">#</a></h1>
<p>.git
.cache
<em>.md
!README</em>.md
README-secret.md
.env</p>
</section>

<script type="text/x-thebe-config">
Expand Down Expand Up @@ -539,11 +561,17 @@ <h2><span class="section-number">15.1.4. </span>Well Commits with <code class="d
</div>
<nav class="bd-toc-nav page-toc">
<ul class="visible nav section-nav flex-column">
<li class="toc-h1 nav-item toc-entry"><a class="reference internal nav-link" href="#">15.1. Miscellaneous</a><ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#must-have-vscode-extensions-for-python">15.1.1. Must-Have VSCode Extensions for Python</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#project-setup-from-templates-with-cookiecutter">15.1.2. Project Setup from Templates with <code class="docutils literal notranslate"><span class="pre">cookiecutter</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#project-scaffolding-with-smol-developer">15.1.3. Project Scaffolding with <code class="docutils literal notranslate"><span class="pre">smol-developer</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#well-commits-with-commitizen">15.1.4. Well Commits with <code class="docutils literal notranslate"><span class="pre">commitizen</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#docker-best-practice-use-dockerignore">15.1.5. Docker Best Practice: Use <code class="docutils literal notranslate"><span class="pre">.dockerignore</span></code></a></li>
</ul>
</li>
<li class="toc-h1 nav-item toc-entry"><a class="reference internal nav-link" href="#dockerignore">15.2. .dockerignore</a></li>
</ul>

</nav></div>

</div></div>
Expand Down
1 change: 1 addition & 0 deletions book/Miscellaneous/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 current active has-children"><a class="current reference internal" href="#">15. Miscellaneous</a><input checked="" class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/codequality/automation.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/codequality/cicd.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/codequality/codestyle.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/codequality/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/codequality/memory.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/codequality/principles.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/codequality/security.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/codequality/typing.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/cooltools/Chapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/cooltools/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/documentation/Chapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/documentation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/jupyternotebook/Chapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/jupyternotebook/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/llm/Chapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/llm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/machinelearning/dataaugmentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions book/machinelearning/eda.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../Miscellaneous/index.html">15. Miscellaneous</a><input class="toctree-checkbox" id="toctree-checkbox-15" name="toctree-checkbox-15" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-15"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../Miscellaneous/Chapter.html">15.1. Miscellaneous</a></li>

</ul>
</li>
</ul>
Expand Down
Loading

0 comments on commit 2023f70

Please sign in to comment.