diff --git a/docs/404.html b/docs/404.html index add8060..e711fcb 100644 --- a/docs/404.html +++ b/docs/404.html @@ -22,7 +22,7 @@ {"@context":"https://schema.org","@type":"WebPage","author":{"@type":"Person","name":"Akash Sharma"},"description":"Reading, Learning, Thinking and Writing","headline":"Page not found","url":"/blog/404.html"} - + @@ -268,21 +268,21 @@

404

- +
- Advanced-Twitter-Scraper + DashTerm
-
An advanced Twitter Scrapper which bypasses Twitter's official API Limit on tweet data retrieval.
+
A terminal based application (TUI) for enhancing your productive workstation 👨‍💻
- 4 + 8 0 - 2022-06-27 + 2023-06-13
@@ -291,21 +291,21 @@

404

- +
- Stay-unDistracted-Chrome-Extension + Advanced-Twitter-Scraper
-
Now Stay Protected from Distractions with "passion, vision and aggression" via this Chrome Extension
+
An advanced Twitter Scrapper which bypasses Twitter's official API Limit on tweet data retrieval.
- 2 + 4 0 - 2021-09-07 + 2022-06-27
@@ -314,21 +314,21 @@

404

- +
- Disentangling-Factors-of-Variation-in-Images-with-Cycle-Consistent-VAE + Stay-unDistracted-Chrome-Extension
-
Implementation of Cycle Consistent Variational AutoEncoder for getting the factors of variation across Images.
+
Now Stay Protected from Distractions with "passion, vision and aggression" via this Chrome Extension
2 0 - 2022-06-28 + 2021-09-07
diff --git a/docs/about/index.html b/docs/about/index.html index 11c18bd..9e741aa 100644 --- a/docs/about/index.html +++ b/docs/about/index.html @@ -22,7 +22,7 @@ {"@context":"https://schema.org","@type":"WebSite","author":{"@type":"Person","name":"Akash Sharma"},"description":"Reading, Learning, Thinking and Writing","headline":"About","name":"Akash Sharma’s Blog","url":"/blog/about/"} - + @@ -210,21 +210,21 @@
- +
- Advanced-Twitter-Scraper + DashTerm
-
An advanced Twitter Scrapper which bypasses Twitter's official API Limit on tweet data retrieval.
+
A terminal based application (TUI) for enhancing your productive workstation 👨‍💻
- 4 + 8 0 - 2022-06-27 + 2023-06-13
@@ -233,21 +233,21 @@
- +
- Stay-unDistracted-Chrome-Extension + Advanced-Twitter-Scraper
-
Now Stay Protected from Distractions with "passion, vision and aggression" via this Chrome Extension
+
An advanced Twitter Scrapper which bypasses Twitter's official API Limit on tweet data retrieval.
- 2 + 4 0 - 2021-09-07 + 2022-06-27
@@ -256,21 +256,21 @@
- +
- Disentangling-Factors-of-Variation-in-Images-with-Cycle-Consistent-VAE + Stay-unDistracted-Chrome-Extension
-
Implementation of Cycle Consistent Variational AutoEncoder for getting the factors of variation across Images.
+
Now Stay Protected from Distractions with "passion, vision and aggression" via this Chrome Extension
2 0 - 2022-06-28 + 2021-09-07
diff --git a/docs/classification/index.html b/docs/classification/index.html index 692f948..db45862 100644 --- a/docs/classification/index.html +++ b/docs/classification/index.html @@ -22,7 +22,7 @@ {"@context":"https://schema.org","@type":"WebPage","author":{"@type":"Person","name":"Akash Sharma"},"description":"Reading, Learning, Thinking and Writing","headline":"Classification","url":"/blog/classification/"} - + diff --git a/docs/feed.xml b/docs/feed.xml index a0acfc7..667514b 100644 --- a/docs/feed.xml +++ b/docs/feed.xml @@ -1,4 +1,4 @@ -Jekyll2022-07-08T22:18:13+05:30/blog/feed.xmlAkash Sharma’s BlogReading, Learning, Thinking and WritingAkash SharmaBasic Data Structure Concepts and Implementations2022-06-29T00:00:00+05:302022-06-29T00:00:00+05:30/blog/leetcode/stack/queue/linked-list/tree/trie/disjoint%20set/heap/2022/06/29/Basic-Data-Structure-Implementations<blockquote> +Jekyll2023-09-18T23:18:23+05:30/blog/feed.xmlAkash Sharma’s BlogReading, Learning, Thinking and WritingAkash SharmaBasic Data Structure Concepts and Implementations2022-06-29T00:00:00+05:302022-06-29T00:00:00+05:30/blog/leetcode/stack/queue/linked-list/tree/trie/disjoint%20set/heap/2022/06/29/Basic-Data-Structure-Implementations<blockquote> <p>This post is a basic cheat-sheet on some of the basics yet crucial data structures’ underlying concepts and high level implementations. I also try to cover some more interesting related ideas for some of these data structures</p> </blockquote> @@ -100,7 +100,7 @@ <span class="p">}</span> <span class="nx">deQueue</span><span class="p">()</span> <span class="p">{</span> <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isEmpty</span><span class="p">())</span> <span class="p">{</span> - <span class="k">throw</span> <span class="nb">Error</span><span class="p">(</span><span class="dl">'</span><span class="s1">Queue is empty</span><span class="dl">'</span><span class="p">)</span> + <span class="k">throw</span> <span class="nb">Error</span><span class="p">(</span><span class="dl">'</span><span class="s1">Queue is empty</span><span class="dl">'</span><span class="p">)</span> <span class="p">}</span> <span class="kd">let</span> <span class="nx">r</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">queue</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">first</span><span class="p">]</span> <span class="k">this</span><span class="p">.</span><span class="nx">queue</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">first</span><span class="p">]</span> <span class="o">=</span> <span class="kc">null</span> @@ -115,7 +115,7 @@ <span class="p">}</span> <span class="nx">getHeader</span><span class="p">()</span> <span class="p">{</span> <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isEmpty</span><span class="p">())</span> <span class="p">{</span> - <span class="k">throw</span> <span class="nb">Error</span><span class="p">(</span><span class="dl">'</span><span class="s1">Queue is empty</span><span class="dl">'</span><span class="p">)</span> + <span class="k">throw</span> <span class="nb">Error</span><span class="p">(</span><span class="dl">'</span><span class="s1">Queue is empty</span><span class="dl">'</span><span class="p">)</span> <span class="p">}</span> <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">queue</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">first</span><span class="p">]</span> <span class="p">}</span> @@ -168,8 +168,8 @@ <span class="p">}</span> <span class="nx">addNode</span><span class="p">(</span><span class="nx">v</span><span class="p">,</span> <span class="nx">index</span><span class="p">)</span> <span class="p">{</span> <span class="k">this</span><span class="p">.</span><span class="nx">checkIndex</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span> - <span class="c1">// the next of the node inserted should be previous node'next</span> - <span class="c1">// and the previous node's next should point to the node insert,</span> + <span class="c1">// the next of the node inserted should be previous node'next</span> + <span class="c1">// and the previous node's next should point to the node insert,</span> <span class="c1">// except inserted to tail which next is null</span> <span class="kd">let</span> <span class="nx">prev</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">dummyNode</span><span class="p">,</span> <span class="nx">index</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="nx">prev</span><span class="p">.</span><span class="nx">next</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Node</span><span class="p">(</span><span class="nx">v</span><span class="p">,</span> <span class="nx">prev</span><span class="p">.</span><span class="nx">next</span><span class="p">)</span> @@ -202,7 +202,7 @@ <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">removeNode</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">size</span><span class="p">,</span> <span class="kc">true</span><span class="p">)</span> <span class="p">}</span> <span class="nx">checkIndex</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span> <span class="p">{</span> - <span class="k">if</span> <span class="p">(</span><span class="nx">index</span> <span class="o">&lt;</span> <span class="mi">0</span> <span class="o">||</span> <span class="nx">index</span> <span class="o">&gt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">size</span><span class="p">)</span> <span class="k">throw</span> <span class="nb">Error</span><span class="p">(</span><span class="dl">'</span><span class="s1">Index error</span><span class="dl">'</span><span class="p">)</span> + <span class="k">if</span> <span class="p">(</span><span class="nx">index</span> <span class="o">&lt;</span> <span class="mi">0</span> <span class="o">||</span> <span class="nx">index</span> <span class="o">&gt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">size</span><span class="p">)</span> <span class="k">throw</span> <span class="nb">Error</span><span class="p">(</span><span class="dl">'</span><span class="s1">Index error</span><span class="dl">'</span><span class="p">)</span> <span class="p">}</span> <span class="nx">getNode</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span> <span class="p">{</span> <span class="k">this</span><span class="p">.</span><span class="nx">checkIndex</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span> @@ -679,7 +679,7 @@ So let us implement the simple operation at first: delete the minimum node. It c <span class="kd">let</span> <span class="nx">node</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">root</span> <span class="k">for</span> <span class="p">(</span><span class="kd">let</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">str</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// get the index of the character</span> - <span class="kd">let</span> <span class="nx">index</span> <span class="o">=</span> <span class="nx">str</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">charCodeAt</span><span class="p">()</span> <span class="o">-</span> <span class="dl">'</span><span class="s1">a</span><span class="dl">'</span><span class="p">.</span><span class="nx">charCodeAt</span><span class="p">()</span> + <span class="kd">let</span> <span class="nx">index</span> <span class="o">=</span> <span class="nx">str</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">charCodeAt</span><span class="p">()</span> <span class="o">-</span> <span class="dl">'</span><span class="s1">a</span><span class="dl">'</span><span class="p">.</span><span class="nx">charCodeAt</span><span class="p">()</span> <span class="c1">// create if without the index</span> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">node</span><span class="p">.</span><span class="nx">next</span><span class="p">[</span><span class="nx">index</span><span class="p">])</span> <span class="p">{</span> <span class="nx">node</span><span class="p">.</span><span class="nx">next</span><span class="p">[</span><span class="nx">index</span><span class="p">]</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">TrieNode</span><span class="p">()</span> @@ -694,7 +694,7 @@ So let us implement the simple operation at first: delete the minimum node. It c <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">str</span><span class="p">)</span> <span class="k">return</span> <span class="kd">let</span> <span class="nx">node</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">root</span> <span class="k">for</span> <span class="p">(</span><span class="kd">let</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">str</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span> - <span class="kd">let</span> <span class="nx">index</span> <span class="o">=</span> <span class="nx">str</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">charCodeAt</span><span class="p">()</span> <span class="o">-</span> <span class="dl">'</span><span class="s1">a</span><span class="dl">'</span><span class="p">.</span><span class="nx">charCodeAt</span><span class="p">()</span> + <span class="kd">let</span> <span class="nx">index</span> <span class="o">=</span> <span class="nx">str</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">charCodeAt</span><span class="p">()</span> <span class="o">-</span> <span class="dl">'</span><span class="s1">a</span><span class="dl">'</span><span class="p">.</span><span class="nx">charCodeAt</span><span class="p">()</span> <span class="c1">// if the index does node exists, there is no string to be search</span> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">node</span><span class="p">.</span><span class="nx">next</span><span class="p">[</span><span class="nx">index</span><span class="p">])</span> <span class="p">{</span> <span class="k">return</span> <span class="mi">0</span> @@ -708,7 +708,7 @@ So let us implement the simple operation at first: delete the minimum node. It c <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="nx">str</span><span class="p">))</span> <span class="k">return</span> <span class="kd">let</span> <span class="nx">node</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">root</span> <span class="k">for</span> <span class="p">(</span><span class="kd">let</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">str</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span> - <span class="kd">let</span> <span class="nx">index</span> <span class="o">=</span> <span class="nx">str</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">charCodeAt</span><span class="p">()</span> <span class="o">-</span> <span class="dl">'</span><span class="s1">a</span><span class="dl">'</span><span class="p">.</span><span class="nx">charCodeAt</span><span class="p">()</span> + <span class="kd">let</span> <span class="nx">index</span> <span class="o">=</span> <span class="nx">str</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">charCodeAt</span><span class="p">()</span> <span class="o">-</span> <span class="dl">'</span><span class="s1">a</span><span class="dl">'</span><span class="p">.</span><span class="nx">charCodeAt</span><span class="p">()</span> <span class="c1">// if the path is 0, this means no string pass </span> <span class="c1">// delete it</span> <span class="k">if</span> <span class="p">(</span><span class="o">--</span><span class="nx">node</span><span class="p">.</span><span class="nx">next</span><span class="p">[</span><span class="nx">index</span><span class="p">].</span><span class="nx">path</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span> @@ -742,7 +742,7 @@ So let us implement the simple operation at first: delete the minimum node. It c <div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">class</span> <span class="nx">DisjointSet</span> <span class="p">{</span> <span class="c1">// init sample</span> <span class="kd">constructor</span><span class="p">(</span><span class="nx">count</span><span class="p">)</span> <span class="p">{</span> - <span class="c1">// each node's parenet node is iteself when initialization</span> + <span class="c1">// each node's parenet node is iteself when initialization</span> <span class="k">this</span><span class="p">.</span><span class="nx">parent</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Array</span><span class="p">(</span><span class="nx">count</span><span class="p">)</span> <span class="c1">// record the deepth of the tree to optimize the complexity of query</span> <span class="k">this</span><span class="p">.</span><span class="nx">rank</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Array</span><span class="p">(</span><span class="nx">count</span><span class="p">)</span> @@ -842,7 +842,7 @@ The index of the left-child of each node is <code class="language-plaint <span class="c1">// exchange if the current node is bigger than the parent node</span> <span class="k">while</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">heap</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">&gt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">heap</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">getParentIndex</span><span class="p">(</span><span class="nx">k</span><span class="p">)])</span> <span class="p">{</span> <span class="k">this</span><span class="p">.</span><span class="nx">_swap</span><span class="p">(</span><span class="nx">k</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">getParentIndex</span><span class="p">(</span><span class="nx">k</span><span class="p">))</span> - <span class="c1">// update the index to the parent node's</span> + <span class="c1">// update the index to the parent node's</span> <span class="nx">k</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getParentIndex</span><span class="p">(</span><span class="nx">k</span><span class="p">)</span> <span class="p">}</span> <span class="p">}</span> @@ -896,7 +896,7 @@ The index of the left-child of each node is <code class="language-plaint <span class="c1">// exchange if the current node is bigger than the parent node</span> <span class="k">while</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">heap</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">&gt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">heap</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">getParentIndex</span><span class="p">(</span><span class="nx">k</span><span class="p">)])</span> <span class="p">{</span> <span class="k">this</span><span class="p">.</span><span class="nx">_swap</span><span class="p">(</span><span class="nx">k</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">getParentIndex</span><span class="p">(</span><span class="nx">k</span><span class="p">))</span> - <span class="c1">// update the index to the parent node's</span> + <span class="c1">// update the index to the parent node's</span> <span class="nx">k</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getParentIndex</span><span class="p">(</span><span class="nx">k</span><span class="p">)</span> <span class="p">}</span> <span class="p">}</span> @@ -924,7 +924,7 @@ The index of the left-child of each node is <code class="language-plaint </code></pre></div></div> <div class="alert alert-info" role="alert"> - I would be covering some more basic Data-structures' concept and implementation in this post.Also, would be covering some advanced data-structures as well as their applications in some other post. + I would be covering some more basic Data-structures' concept and implementation in this post.Also, would be covering some advanced data-structures as well as their applications in some other post. </div>Akash SharmaThis post is a basic cheat-sheet on some of the basics yet crucial data structures’ underlying concepts and high level implementations. I also try to cover some more interesting related ideas for some of these data structuresSetting up Dell XPS 15 with Pop!_OS Distro2021-07-08T00:00:00+05:302021-07-08T00:00:00+05:30/blog/tech/2021/07/08/Setting-up-Dell-XPS-15-with-Pop!_OS-Distro<p>I’ve got a <a href="https://www.dell.com/en-in/work/shop/scc/sr/laptops/xps-laptops">Dell XPS 15 9570</a> (16GB RAM, i7-8750H CPU) for work expecting it to have good support in Linux, considering other XPS laptops ship with Ubuntu.</p> <p>However, the massive (for a laptop) NVIDIA GeForce GTX 1050Ti with 4GB GDDR5 ensures installing Linux is not so smooth…🤔</p> @@ -1229,9 +1229,9 @@ Let me know if you do!</p> </span><span class="n">Y</span> <span class="o">=</span> <span class="n">f</span><span class="p">(</span><span class="n">X</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span> <span class="c1"># Plot optimization objective with noise level -</span><span class="n">plt</span><span class="p">.</span><span class="n">plot</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">Y</span><span class="p">,</span> <span class="s">'y--'</span><span class="p">,</span> <span class="n">lw</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s">'Noise-free objective'</span><span class="p">)</span> -<span class="n">plt</span><span class="p">.</span><span class="n">plot</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">f</span><span class="p">(</span><span class="n">X</span><span class="p">),</span> <span class="s">'bx'</span><span class="p">,</span> <span class="n">lw</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s">'Noisy samples'</span><span class="p">)</span> -<span class="n">plt</span><span class="p">.</span><span class="n">plot</span><span class="p">(</span><span class="n">X_init</span><span class="p">,</span> <span class="n">Y_init</span><span class="p">,</span> <span class="s">'kx'</span><span class="p">,</span> <span class="n">mew</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s">'Initial samples'</span><span class="p">)</span> +</span><span class="n">plt</span><span class="p">.</span><span class="n">plot</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">Y</span><span class="p">,</span> <span class="s">'y--'</span><span class="p">,</span> <span class="n">lw</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s">'Noise-free objective'</span><span class="p">)</span> +<span class="n">plt</span><span class="p">.</span><span class="n">plot</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">f</span><span class="p">(</span><span class="n">X</span><span class="p">),</span> <span class="s">'bx'</span><span class="p">,</span> <span class="n">lw</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s">'Noisy samples'</span><span class="p">)</span> +<span class="n">plt</span><span class="p">.</span><span class="n">plot</span><span class="p">(</span><span class="n">X_init</span><span class="p">,</span> <span class="n">Y_init</span><span class="p">,</span> <span class="s">'kx'</span><span class="p">,</span> <span class="n">mew</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s">'Initial samples'</span><span class="p">)</span> <span class="n">plt</span><span class="p">.</span><span class="n">legend</span><span class="p">();</span> </code></pre></div></div> @@ -1242,7 +1242,7 @@ Let me know if you do!</p> <div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">from</span> <span class="nn">scipy.stats</span> <span class="kn">import</span> <span class="n">norm</span> <span class="k">def</span> <span class="nf">expected_improvement</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">X_sample</span><span class="p">,</span> <span class="n">Y_sample</span><span class="p">,</span> <span class="n">gpr</span><span class="p">,</span> <span class="n">xi</span><span class="o">=</span><span class="mf">0.01</span><span class="p">):</span> - <span class="s">''' + <span class="s">''' Computes the EI at points X based on existing samples X_sample and Y_sample using a Gaussian process surrogate model. @@ -1255,7 +1255,7 @@ Let me know if you do!</p> Returns: Expected improvements at points X. - '''</span> + '''</span> <span class="n">mu</span><span class="p">,</span> <span class="n">sigma</span> <span class="o">=</span> <span class="n">gpr</span><span class="p">.</span><span class="n">predict</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">return_std</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span> <span class="n">mu_sample</span> <span class="o">=</span> <span class="n">gpr</span><span class="p">.</span><span class="n">predict</span><span class="p">(</span><span class="n">X_sample</span><span class="p">)</span> @@ -1266,7 +1266,7 @@ Let me know if you do!</p> </span> <span class="c1"># See also section 2.4 in [...] </span> <span class="n">mu_sample_opt</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="nb">max</span><span class="p">(</span><span class="n">mu_sample</span><span class="p">)</span> - <span class="k">with</span> <span class="n">np</span><span class="p">.</span><span class="n">errstate</span><span class="p">(</span><span class="n">divide</span><span class="o">=</span><span class="s">'warn'</span><span class="p">):</span> + <span class="k">with</span> <span class="n">np</span><span class="p">.</span><span class="n">errstate</span><span class="p">(</span><span class="n">divide</span><span class="o">=</span><span class="s">'warn'</span><span class="p">):</span> <span class="n">imp</span> <span class="o">=</span> <span class="n">mu</span> <span class="o">-</span> <span class="n">mu_sample_opt</span> <span class="o">-</span> <span class="n">xi</span> <span class="n">Z</span> <span class="o">=</span> <span class="n">imp</span> <span class="o">/</span> <span class="n">sigma</span> <span class="n">ei</span> <span class="o">=</span> <span class="n">imp</span> <span class="o">*</span> <span class="n">norm</span><span class="p">.</span><span class="n">cdf</span><span class="p">(</span><span class="n">Z</span><span class="p">)</span> <span class="o">+</span> <span class="n">sigma</span> <span class="o">*</span> <span class="n">norm</span><span class="p">.</span><span class="n">pdf</span><span class="p">(</span><span class="n">Z</span><span class="p">)</span> @@ -1280,7 +1280,7 @@ Let me know if you do!</p> <div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">from</span> <span class="nn">scipy.optimize</span> <span class="kn">import</span> <span class="n">minimize</span> <span class="k">def</span> <span class="nf">propose_location</span><span class="p">(</span><span class="n">acquisition</span><span class="p">,</span> <span class="n">X_sample</span><span class="p">,</span> <span class="n">Y_sample</span><span class="p">,</span> <span class="n">gpr</span><span class="p">,</span> <span class="n">bounds</span><span class="p">,</span> <span class="n">n_restarts</span><span class="o">=</span><span class="mi">25</span><span class="p">):</span> - <span class="s">''' + <span class="s">''' Proposes the next sampling point by optimizing the acquisition function. Args: @@ -1291,7 +1291,7 @@ Let me know if you do!</p> Returns: Location of the acquisition function maximum. - '''</span> + '''</span> <span class="n">dim</span> <span class="o">=</span> <span class="n">X_sample</span><span class="p">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="n">min_val</span> <span class="o">=</span> <span class="mi">1</span> <span class="n">min_x</span> <span class="o">=</span> <span class="bp">None</span> @@ -1302,7 +1302,7 @@ Let me know if you do!</p> <span class="c1"># Find the best optimum by starting from n_restart different random points. </span> <span class="k">for</span> <span class="n">x0</span> <span class="ow">in</span> <span class="n">np</span><span class="p">.</span><span class="n">random</span><span class="p">.</span><span class="n">uniform</span><span class="p">(</span><span class="n">bounds</span><span class="p">[:,</span> <span class="mi">0</span><span class="p">],</span> <span class="n">bounds</span><span class="p">[:,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="n">n_restarts</span><span class="p">,</span> <span class="n">dim</span><span class="p">)):</span> - <span class="n">res</span> <span class="o">=</span> <span class="n">minimize</span><span class="p">(</span><span class="n">min_obj</span><span class="p">,</span> <span class="n">x0</span><span class="o">=</span><span class="n">x0</span><span class="p">,</span> <span class="n">bounds</span><span class="o">=</span><span class="n">bounds</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s">'L-BFGS-B'</span><span class="p">)</span> + <span class="n">res</span> <span class="o">=</span> <span class="n">minimize</span><span class="p">(</span><span class="n">min_obj</span><span class="p">,</span> <span class="n">x0</span><span class="o">=</span><span class="n">x0</span><span class="p">,</span> <span class="n">bounds</span><span class="o">=</span><span class="n">bounds</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s">'L-BFGS-B'</span><span class="p">)</span> <span class="k">if</span> <span class="n">res</span><span class="p">.</span><span class="n">fun</span> <span class="o">&lt;</span> <span class="n">min_val</span><span class="p">:</span> <span class="n">min_val</span> <span class="o">=</span> <span class="n">res</span><span class="p">.</span><span class="n">fun</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="n">min_x</span> <span class="o">=</span> <span class="n">res</span><span class="p">.</span><span class="n">x</span> @@ -1345,7 +1345,7 @@ Let me know if you do!</p> <span class="c1"># Plot samples, surrogate function, noise-free objective and next sampling location </span> <span class="n">plt</span><span class="p">.</span><span class="n">subplot</span><span class="p">(</span><span class="n">n_iter</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="n">plot_approximation</span><span class="p">(</span><span class="n">gpr</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">Y</span><span class="p">,</span> <span class="n">X_sample</span><span class="p">,</span> <span class="n">Y_sample</span><span class="p">,</span> <span class="n">X_next</span><span class="p">,</span> <span class="n">show_legend</span><span class="o">=</span><span class="n">i</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> - <span class="n">plt</span><span class="p">.</span><span class="n">title</span><span class="p">(</span><span class="sa">f</span><span class="s">'Iteration </span><span class="si">{</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="si">}</span><span class="s">'</span><span class="p">)</span> + <span class="n">plt</span><span class="p">.</span><span class="n">title</span><span class="p">(</span><span class="sa">f</span><span class="s">'Iteration </span><span class="si">{</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="si">}</span><span class="s">'</span><span class="p">)</span> <span class="n">plt</span><span class="p">.</span><span class="n">subplot</span><span class="p">(</span><span class="n">n_iter</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">i</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span> <span class="n">plot_acquisition</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">expected_improvement</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">X_sample</span><span class="p">,</span> <span class="n">Y_sample</span><span class="p">,</span> <span class="n">gpr</span><span class="p">),</span> <span class="n">X_next</span><span class="p">,</span> <span class="n">show_legend</span><span class="o">=</span><span class="n">i</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> @@ -1388,7 +1388,7 @@ Let me know if you do!</p> <span class="n">r</span> <span class="o">=</span> <span class="n">gp_minimize</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="o">-</span><span class="n">f</span><span class="p">(</span><span class="n">np</span><span class="p">.</span><span class="n">array</span><span class="p">(</span><span class="n">x</span><span class="p">))[</span><span class="mi">0</span><span class="p">],</span> <span class="n">bounds</span><span class="p">.</span><span class="n">tolist</span><span class="p">(),</span> <span class="n">base_estimator</span><span class="o">=</span><span class="n">gpr</span><span class="p">,</span> - <span class="n">acq_func</span><span class="o">=</span><span class="s">'EI'</span><span class="p">,</span> <span class="c1"># expected improvement + <span class="n">acq_func</span><span class="o">=</span><span class="s">'EI'</span><span class="p">,</span> <span class="c1"># expected improvement </span> <span class="n">xi</span><span class="o">=</span><span class="mf">0.01</span><span class="p">,</span> <span class="c1"># exploitation-exploration trade-off </span> <span class="n">n_calls</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="c1"># number of iterations </span> <span class="n">n_random_starts</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="c1"># initial samples are provided @@ -1419,13 +1419,13 @@ Let me know if you do!</p> <span class="kn">from</span> <span class="nn">GPyOpt.methods</span> <span class="kn">import</span> <span class="n">BayesianOptimization</span> <span class="n">kernel</span> <span class="o">=</span> <span class="n">GPy</span><span class="p">.</span><span class="n">kern</span><span class="p">.</span><span class="n">Matern52</span><span class="p">(</span><span class="n">input_dim</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">variance</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">lengthscale</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span> -<span class="n">bds</span> <span class="o">=</span> <span class="p">[{</span><span class="s">'name'</span><span class="p">:</span> <span class="s">'X'</span><span class="p">,</span> <span class="s">'type'</span><span class="p">:</span> <span class="s">'continuous'</span><span class="p">,</span> <span class="s">'domain'</span><span class="p">:</span> <span class="n">bounds</span><span class="p">.</span><span class="n">ravel</span><span class="p">()}]</span> +<span class="n">bds</span> <span class="o">=</span> <span class="p">[{</span><span class="s">'name'</span><span class="p">:</span> <span class="s">'X'</span><span class="p">,</span> <span class="s">'type'</span><span class="p">:</span> <span class="s">'continuous'</span><span class="p">,</span> <span class="s">'domain'</span><span class="p">:</span> <span class="n">bounds</span><span class="p">.</span><span class="n">ravel</span><span class="p">()}]</span> <span class="n">optimizer</span> <span class="o">=</span> <span class="n">BayesianOptimization</span><span class="p">(</span><span class="n">f</span><span class="o">=</span><span class="n">f</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">bds</span><span class="p">,</span> - <span class="n">model_type</span><span class="o">=</span><span class="s">'GP'</span><span class="p">,</span> + <span class="n">model_type</span><span class="o">=</span><span class="s">'GP'</span><span class="p">,</span> <span class="n">kernel</span><span class="o">=</span><span class="n">kernel</span><span class="p">,</span> - <span class="n">acquisition_type</span> <span class="o">=</span><span class="s">'EI'</span><span class="p">,</span> + <span class="n">acquisition_type</span> <span class="o">=</span><span class="s">'EI'</span><span class="p">,</span> <span class="n">acquisition_jitter</span> <span class="o">=</span> <span class="mf">0.01</span><span class="p">,</span> <span class="n">X</span><span class="o">=</span><span class="n">X_init</span><span class="p">,</span> <span class="n">Y</span><span class="o">=-</span><span class="n">Y_init</span><span class="p">,</span> @@ -1462,7 +1462,7 @@ Let me know if you do!</p> </span><span class="n">xgb</span> <span class="o">=</span> <span class="n">XGBRegressor</span><span class="p">()</span> <span class="c1"># and compute a baseline to beat with hyperparameter optimization -</span><span class="n">baseline</span> <span class="o">=</span> <span class="n">cross_val_score</span><span class="p">(</span><span class="n">xgb</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">Y</span><span class="p">,</span> <span class="n">scoring</span><span class="o">=</span><span class="s">'neg_mean_squared_error'</span><span class="p">).</span><span class="n">mean</span><span class="p">()</span> +</span><span class="n">baseline</span> <span class="o">=</span> <span class="n">cross_val_score</span><span class="p">(</span><span class="n">xgb</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">Y</span><span class="p">,</span> <span class="n">scoring</span><span class="o">=</span><span class="s">'neg_mean_squared_error'</span><span class="p">).</span><span class="n">mean</span><span class="p">()</span> </code></pre></div></div> <h3 id="hyperparameter-tuning-with-random-search">Hyperparameter tuning with random search</h3> @@ -1477,7 +1477,7 @@ Let me know if you do!</p> <span class="s">"min_child_weight"</span><span class="p">:</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">10</span><span class="p">)}</span> <span class="n">rs</span> <span class="o">=</span> <span class="n">RandomizedSearchCV</span><span class="p">(</span><span class="n">xgb</span><span class="p">,</span> <span class="n">param_distributions</span><span class="o">=</span><span class="n">param_dist</span><span class="p">,</span> - <span class="n">scoring</span><span class="o">=</span><span class="s">'neg_mean_squared_error'</span><span class="p">,</span> <span class="n">n_iter</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span> + <span class="n">scoring</span><span class="o">=</span><span class="s">'neg_mean_squared_error'</span><span class="p">,</span> <span class="n">n_iter</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span> <span class="c1"># Run random search for 25 iterations </span><span class="n">rs</span><span class="p">.</span><span class="n">fit</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">Y</span><span class="p">);</span> @@ -1487,11 +1487,11 @@ Let me know if you do!</p> <p>To tune hyperparameters with Bayesian optimization we implement an objective function <code class="language-plaintext highlighter-rouge">cv_score</code> that takes hyperparameters as input and returns a cross-validation score. Here, we assume that cross-validation at a given point in hyperparameter space is deterministic and therefore set the <code class="language-plaintext highlighter-rouge">exact_feval</code> parameter of <code class="language-plaintext highlighter-rouge">BayesianOptimization</code> to <code class="language-plaintext highlighter-rouge">True</code>. Depending on model fitting and cross-validation details this might not be the case but we ignore that here.</p> -<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">bds</span> <span class="o">=</span> <span class="p">[{</span><span class="s">'name'</span><span class="p">:</span> <span class="s">'learning_rate'</span><span class="p">,</span> <span class="s">'type'</span><span class="p">:</span> <span class="s">'continuous'</span><span class="p">,</span> <span class="s">'domain'</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)},</span> - <span class="p">{</span><span class="s">'name'</span><span class="p">:</span> <span class="s">'gamma'</span><span class="p">,</span> <span class="s">'type'</span><span class="p">:</span> <span class="s">'continuous'</span><span class="p">,</span> <span class="s">'domain'</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">5</span><span class="p">)},</span> - <span class="p">{</span><span class="s">'name'</span><span class="p">:</span> <span class="s">'max_depth'</span><span class="p">,</span> <span class="s">'type'</span><span class="p">:</span> <span class="s">'discrete'</span><span class="p">,</span> <span class="s">'domain'</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">50</span><span class="p">)},</span> - <span class="p">{</span><span class="s">'name'</span><span class="p">:</span> <span class="s">'n_estimators'</span><span class="p">,</span> <span class="s">'type'</span><span class="p">:</span> <span class="s">'discrete'</span><span class="p">,</span> <span class="s">'domain'</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">300</span><span class="p">)},</span> - <span class="p">{</span><span class="s">'name'</span><span class="p">:</span> <span class="s">'min_child_weight'</span><span class="p">,</span> <span class="s">'type'</span><span class="p">:</span> <span class="s">'discrete'</span><span class="p">,</span> <span class="s">'domain'</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">)}]</span> +<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">bds</span> <span class="o">=</span> <span class="p">[{</span><span class="s">'name'</span><span class="p">:</span> <span class="s">'learning_rate'</span><span class="p">,</span> <span class="s">'type'</span><span class="p">:</span> <span class="s">'continuous'</span><span class="p">,</span> <span class="s">'domain'</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)},</span> + <span class="p">{</span><span class="s">'name'</span><span class="p">:</span> <span class="s">'gamma'</span><span class="p">,</span> <span class="s">'type'</span><span class="p">:</span> <span class="s">'continuous'</span><span class="p">,</span> <span class="s">'domain'</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">5</span><span class="p">)},</span> + <span class="p">{</span><span class="s">'name'</span><span class="p">:</span> <span class="s">'max_depth'</span><span class="p">,</span> <span class="s">'type'</span><span class="p">:</span> <span class="s">'discrete'</span><span class="p">,</span> <span class="s">'domain'</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">50</span><span class="p">)},</span> + <span class="p">{</span><span class="s">'name'</span><span class="p">:</span> <span class="s">'n_estimators'</span><span class="p">,</span> <span class="s">'type'</span><span class="p">:</span> <span class="s">'discrete'</span><span class="p">,</span> <span class="s">'domain'</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">300</span><span class="p">)},</span> + <span class="p">{</span><span class="s">'name'</span><span class="p">:</span> <span class="s">'min_child_weight'</span><span class="p">,</span> <span class="s">'type'</span><span class="p">:</span> <span class="s">'discrete'</span><span class="p">,</span> <span class="s">'domain'</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">)}]</span> <span class="c1"># Optimization objective </span><span class="k">def</span> <span class="nf">cv_score</span><span class="p">(</span><span class="n">parameters</span><span class="p">):</span> @@ -1502,14 +1502,14 @@ Let me know if you do!</p> <span class="n">max_depth</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">2</span><span class="p">]),</span> <span class="n">n_estimators</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">3</span><span class="p">]),</span> <span class="n">min_child_weight</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">4</span><span class="p">]),</span> - <span class="n">X</span><span class="p">,</span> <span class="n">Y</span><span class="p">,</span> <span class="n">scoring</span><span class="o">=</span><span class="s">'neg_mean_squared_error'</span><span class="p">).</span><span class="n">mean</span><span class="p">()</span> + <span class="n">X</span><span class="p">,</span> <span class="n">Y</span><span class="p">,</span> <span class="n">scoring</span><span class="o">=</span><span class="s">'neg_mean_squared_error'</span><span class="p">).</span><span class="n">mean</span><span class="p">()</span> <span class="n">score</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">array</span><span class="p">(</span><span class="n">score</span><span class="p">)</span> <span class="k">return</span> <span class="n">score</span> <span class="n">optimizer</span> <span class="o">=</span> <span class="n">BayesianOptimization</span><span class="p">(</span><span class="n">f</span><span class="o">=</span><span class="n">cv_score</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">bds</span><span class="p">,</span> - <span class="n">model_type</span><span class="o">=</span><span class="s">'GP'</span><span class="p">,</span> - <span class="n">acquisition_type</span> <span class="o">=</span><span class="s">'EI'</span><span class="p">,</span> + <span class="n">model_type</span><span class="o">=</span><span class="s">'GP'</span><span class="p">,</span> + <span class="n">acquisition_type</span> <span class="o">=</span><span class="s">'EI'</span><span class="p">,</span> <span class="n">acquisition_jitter</span> <span class="o">=</span> <span class="mf">0.05</span><span class="p">,</span> <span class="n">exact_feval</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">maximize</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span> @@ -1522,19 +1522,19 @@ Let me know if you do!</p> <p>On average, Bayesian optimization finds a better optimium in a smaller number of steps than random search and beats the baseline in almost every run. This trend becomes even more prominent in higher-dimensional search spaces. Here, the search space is 5-dimensional which is rather low to substantially profit from Bayesian optimization. One advantage of random search is that it is trivial to parallelize. Parallelization of Bayesian optimization is much harder and subject to research (see [4], for example).</p> -<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">y_rs</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">maximum</span><span class="p">.</span><span class="n">accumulate</span><span class="p">(</span><span class="n">rs</span><span class="p">.</span><span class="n">cv_results_</span><span class="p">[</span><span class="s">'mean_test_score'</span><span class="p">])</span> +<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">y_rs</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">maximum</span><span class="p">.</span><span class="n">accumulate</span><span class="p">(</span><span class="n">rs</span><span class="p">.</span><span class="n">cv_results_</span><span class="p">[</span><span class="s">'mean_test_score'</span><span class="p">])</span> <span class="n">y_bo</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">maximum</span><span class="p">.</span><span class="n">accumulate</span><span class="p">(</span><span class="o">-</span><span class="n">optimizer</span><span class="p">.</span><span class="n">Y</span><span class="p">).</span><span class="n">ravel</span><span class="p">()</span> -<span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">'Baseline neg. MSE = </span><span class="si">{</span><span class="n">baseline</span><span class="p">:.</span><span class="mi">2</span><span class="n">f</span><span class="si">}</span><span class="s">'</span><span class="p">)</span> -<span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">'Random search neg. MSE = </span><span class="si">{</span><span class="n">y_rs</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]:.</span><span class="mi">2</span><span class="n">f</span><span class="si">}</span><span class="s">'</span><span class="p">)</span> -<span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">'Bayesian optimization neg. MSE = </span><span class="si">{</span><span class="n">y_bo</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]:.</span><span class="mi">2</span><span class="n">f</span><span class="si">}</span><span class="s">'</span><span class="p">)</span> +<span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">'Baseline neg. MSE = </span><span class="si">{</span><span class="n">baseline</span><span class="p">:.</span><span class="mi">2</span><span class="n">f</span><span class="si">}</span><span class="s">'</span><span class="p">)</span> +<span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">'Random search neg. MSE = </span><span class="si">{</span><span class="n">y_rs</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]:.</span><span class="mi">2</span><span class="n">f</span><span class="si">}</span><span class="s">'</span><span class="p">)</span> +<span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">'Bayesian optimization neg. MSE = </span><span class="si">{</span><span class="n">y_bo</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]:.</span><span class="mi">2</span><span class="n">f</span><span class="si">}</span><span class="s">'</span><span class="p">)</span> -<span class="n">plt</span><span class="p">.</span><span class="n">plot</span><span class="p">(</span><span class="n">y_rs</span><span class="p">,</span> <span class="s">'ro-'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s">'Random search'</span><span class="p">)</span> -<span class="n">plt</span><span class="p">.</span><span class="n">plot</span><span class="p">(</span><span class="n">y_bo</span><span class="p">,</span> <span class="s">'bo-'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s">'Bayesian optimization'</span><span class="p">)</span> -<span class="n">plt</span><span class="p">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s">'Iteration'</span><span class="p">)</span> -<span class="n">plt</span><span class="p">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s">'Neg. MSE'</span><span class="p">)</span> +<span class="n">plt</span><span class="p">.</span><span class="n">plot</span><span class="p">(</span><span class="n">y_rs</span><span class="p">,</span> <span class="s">'ro-'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s">'Random search'</span><span class="p">)</span> +<span class="n">plt</span><span class="p">.</span><span class="n">plot</span><span class="p">(</span><span class="n">y_bo</span><span class="p">,</span> <span class="s">'bo-'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s">'Bayesian optimization'</span><span class="p">)</span> +<span class="n">plt</span><span class="p">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s">'Iteration'</span><span class="p">)</span> +<span class="n">plt</span><span class="p">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s">'Neg. MSE'</span><span class="p">)</span> <span class="n">plt</span><span class="p">.</span><span class="n">ylim</span><span class="p">(</span><span class="o">-</span><span class="mi">5000</span><span class="p">,</span> <span class="o">-</span><span class="mi">3000</span><span class="p">)</span> -<span class="n">plt</span><span class="p">.</span><span class="n">title</span><span class="p">(</span><span class="s">'Value of the best sampled CV score'</span><span class="p">);</span> +<span class="n">plt</span><span class="p">.</span><span class="n">title</span><span class="p">(</span><span class="s">'Value of the best sampled CV score'</span><span class="p">);</span> <span class="n">plt</span><span class="p">.</span><span class="n">legend</span><span class="p">();</span> </code></pre></div></div> @@ -1714,7 +1714,7 @@ Bayesian optimization neg. MSE = -3185.50 <p><code class="language-plaintext highlighter-rouge">yaml # This file is generated from information provided by # the datasource. Changes to it will not persist across an instance. - # To disable cloud-init's network configuration capabilities, write a file + # To disable cloud-init's network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: @@ -1778,14 +1778,14 @@ Bayesian optimization neg. MSE = -3185.50 <div class="language-makefile highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># dev builds and installs developer binaries. </span><span class="nl">dev</span><span class="o">:</span> - <span class="err">go</span> <span class="err">install</span> <span class="nv">-tags</span><span class="o">=</span><span class="s1">'dev debug profile netgo'</span> <span class="nt">-ldflags</span><span class="o">=</span><span class="s1">'</span><span class="nv">$(ldflags)</span><span class="s1">'</span> <span class="nv">$(pkgs)</span> + <span class="err">go</span> <span class="err">install</span> <span class="nv">-tags</span><span class="o">=</span><span class="s1">'dev debug profile netgo'</span> <span class="nt">-ldflags</span><span class="o">=</span><span class="s1">'</span><span class="nv">$(ldflags)</span><span class="s1">'</span> <span class="nv">$(pkgs)</span> </code></pre></div></div> <p>for</p> <div class="language-makefile highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># dev builds and installs developer binaries. </span><span class="nl">dev</span><span class="o">:</span> - <span class="nv">GOOS</span><span class="o">=</span>windows <span class="nv">GOARCH</span><span class="o">=</span>amd64 go <span class="nb">install</span> <span class="nt">-tags</span><span class="o">=</span><span class="s1">'dev debug profile netgo'</span> <span class="nt">-ldflags</span><span class="o">=</span><span class="s1">'</span><span class="nv">$(ldflags)</span><span class="s1">'</span> <span class="nv">$(pkgs)</span> + <span class="nv">GOOS</span><span class="o">=</span>windows <span class="nv">GOARCH</span><span class="o">=</span>amd64 go <span class="nb">install</span> <span class="nt">-tags</span><span class="o">=</span><span class="s1">'dev debug profile netgo'</span> <span class="nt">-ldflags</span><span class="o">=</span><span class="s1">'</span><span class="nv">$(ldflags)</span><span class="s1">'</span> <span class="nv">$(pkgs)</span> </code></pre></div></div> <blockquote> @@ -1919,9 +1919,9 @@ Bayesian optimization neg. MSE = -3185.50 <span class="nt">--disable-api-security</span> allow siad to listen on a non-localhost address <span class="o">(</span>DANGEROUS<span class="o">)</span> <span class="nt">-h</span>, <span class="nt">--help</span> <span class="nb">help </span><span class="k">for</span> ./siad <span class="nt">--host-addr</span> string which port the host listens on <span class="o">(</span>default <span class="s2">":9982"</span><span class="o">)</span> - <span class="nt">-M</span>, <span class="nt">--modules</span> string enabled modules, see <span class="s1">'siad modules'</span> <span class="k">for </span>more info <span class="o">(</span>default <span class="s2">"cghrtw"</span><span class="o">)</span> + <span class="nt">-M</span>, <span class="nt">--modules</span> string enabled modules, see <span class="s1">'siad modules'</span> <span class="k">for </span>more info <span class="o">(</span>default <span class="s2">"cghrtw"</span><span class="o">)</span> <span class="nt">--no-bootstrap</span> disable bootstrapping on this run - <span class="nt">--profile</span> string <span class="nb">enable </span>profiling with flags <span class="s1">'cmt'</span> <span class="k">for </span>CPU, memory, trace + <span class="nt">--profile</span> string <span class="nb">enable </span>profiling with flags <span class="s1">'cmt'</span> <span class="k">for </span>CPU, memory, trace <span class="nt">--profile-directory</span> string location of the profiling directory <span class="o">(</span>default <span class="s2">"profiles"</span><span class="o">)</span> <span class="nt">--rpc-addr</span> string which port the gateway listens on <span class="o">(</span>default <span class="s2">":9981"</span><span class="o">)</span> <span class="nt">-d</span>, <span class="nt">--sia-directory</span> string location of the sia directory @@ -2014,7 +2014,7 @@ Bayesian optimization neg. MSE = -3185.50 gateway Perform gateway actions <span class="nb">help </span>Help about any <span class="nb">command </span>host Perform host actions - hostdb Interact with the renter<span class="s1">'s host database. + hostdb Interact with the renter<span class="s1">'s host database. man-generation Creates unix style manpages. miner Perform miner actions renter Perform renter actions @@ -2025,9 +2025,9 @@ Bayesian optimization neg. MSE = -3185.50 Flags: -a, --addr string which host/port to communicate with (i.e. the host/port siad is listening on) (default "localhost:9980") - --apipassword string the password for the API'</span>s http authentication + --apipassword string the password for the API'</span>s http authentication <span class="nt">-h</span>, <span class="nt">--help</span> <span class="nb">help </span><span class="k">for</span> ./siac - <span class="nt">--useragent</span> string the useragent used by siac to connect to the daemon<span class="s1">'s API (default "Sia-Agent") + <span class="nt">--useragent</span> string the useragent used by siac to connect to the daemon<span class="s1">'s API (default "Sia-Agent") Use "./siac [command] --help" for more information about a command. </span></code></pre></div> </div> @@ -2358,7 +2358,7 @@ Estimated Fee: 30 mS / KB <p>The Renter node uploads files via <code class="language-plaintext highlighter-rouge">./siac renter upload [source] [path]</code>, and checks the status of all files via <code class="language-plaintext highlighter-rouge">./siac renter list</code></p> <div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code> akashsharma@192.168.127.23 sia <span class="nv">$ </span>./siac renter upload test_file <span class="nb">test - </span>Uploaded <span class="s1">'/home/akashsharma/sia/test_file'</span> as test. + </span>Uploaded <span class="s1">'/home/akashsharma/sia/test_file'</span> as test. akashsharma@192.168.127.23 sia <span class="nv">$ </span>./siac renter list Tracking 1 files: Total uploaded: 12.09 MB @@ -2380,7 +2380,7 @@ Estimated Fee: 30 mS / KB <div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code> akashsharma@192.168.127.23 sia <span class="nv">$ </span>./siac renter download <span class="nb">test </span>test_file2 Downloading... 95.4% of 12.09 MB, 1s elapsed, 61.42 Mbps - Downloaded <span class="s1">'test'</span> to /home/akashsharma/sia/test_file2. + Downloaded <span class="s1">'test'</span> to /home/akashsharma/sia/test_file2. </code></pre></div> </div> </li> </ol> @@ -2511,7 +2511,7 @@ if (2 &gt; 1) { <span class="gt">&gt; 1. This is the first list item.</span> <span class="gt">&gt; 1. This is the second list item.</span> <span class="gt">&gt;</span> -<span class="gt">&gt; Here's some example code:</span> +<span class="gt">&gt; Here's some example code:</span> <span class="gt">&gt;</span> <span class="gt">&gt; ```java</span> <span class="gt">&gt; if (2 &gt; 1) {</span> diff --git a/docs/index.html b/docs/index.html index a3cf4d8..d2e6b90 100644 --- a/docs/index.html +++ b/docs/index.html @@ -22,7 +22,7 @@ {"@context":"https://schema.org","@type":"WebSite","author":{"@type":"Person","name":"Akash Sharma"},"description":"Reading, Learning, Thinking and Writing","headline":"Home","name":"Akash Sharma’s Blog","url":"/blog/"} - + @@ -442,21 +442,21 @@
- +
- Advanced-Twitter-Scraper + DashTerm
-
An advanced Twitter Scrapper which bypasses Twitter's official API Limit on tweet data retrieval.
+
A terminal based application (TUI) for enhancing your productive workstation 👨‍💻
- 4 + 8 0 - 2022-06-27 + 2023-06-13
@@ -465,21 +465,21 @@
- +
- Stay-unDistracted-Chrome-Extension + Advanced-Twitter-Scraper
-
Now Stay Protected from Distractions with "passion, vision and aggression" via this Chrome Extension
+
An advanced Twitter Scrapper which bypasses Twitter's official API Limit on tweet data retrieval.
- 2 + 4 0 - 2021-09-07 + 2022-06-27
@@ -488,21 +488,21 @@
- +
- Disentangling-Factors-of-Variation-in-Images-with-Cycle-Consistent-VAE + Stay-unDistracted-Chrome-Extension
-
Implementation of Cycle Consistent Variational AutoEncoder for getting the factors of variation across Images.
+
Now Stay Protected from Distractions with "passion, vision and aggression" via this Chrome Extension
2 0 - 2022-06-28 + 2021-09-07
diff --git a/docs/leetcode/categories/index.html b/docs/leetcode/categories/index.html index 60cc12b..4b53a92 100644 --- a/docs/leetcode/categories/index.html +++ b/docs/leetcode/categories/index.html @@ -22,7 +22,7 @@ {"@context":"https://schema.org","@type":"WebPage","author":{"@type":"Person","name":"Akash Sharma"},"description":"Reading, Learning, Thinking and Writing","headline":"LeetCode Grind Topics","url":"/blog/leetcode/categories/"} - + diff --git a/docs/leetcode/index.html b/docs/leetcode/index.html index bf670e4..02ad096 100644 --- a/docs/leetcode/index.html +++ b/docs/leetcode/index.html @@ -22,7 +22,7 @@ {"@context":"https://schema.org","@type":"WebPage","author":{"@type":"Person","name":"Akash Sharma"},"description":"Reading, Learning, Thinking and Writing","headline":"Leetcode Grinding","url":"/blog/leetcode/"} - + diff --git a/docs/leetcode/stack/queue/linked-list/tree/trie/disjoint set/heap/2022/06/29/Basic-Data-Structure-Implementations.html b/docs/leetcode/stack/queue/linked-list/tree/trie/disjoint set/heap/2022/06/29/Basic-Data-Structure-Implementations.html index 14f064b..32669f5 100644 --- a/docs/leetcode/stack/queue/linked-list/tree/trie/disjoint set/heap/2022/06/29/Basic-Data-Structure-Implementations.html +++ b/docs/leetcode/stack/queue/linked-list/tree/trie/disjoint set/heap/2022/06/29/Basic-Data-Structure-Implementations.html @@ -23,7 +23,7 @@ {"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Akash Sharma"},"dateModified":"2022-06-29T00:00:00+05:30","datePublished":"2022-06-29T00:00:00+05:30","description":"This post is a basic cheat-sheet on some of the basics yet crucial data structures’ underlying concepts and high level implementations. I also try to cover some more interesting related ideas for some of these data structures","headline":"Basic Data Structure Concepts and Implementations","mainEntityOfPage":{"@type":"WebPage","@id":"/blog/leetcode/stack/queue/linked-list/tree/trie/disjoint%20set/heap/2022/06/29/Basic-Data-Structure-Implementations.html"},"url":"/blog/leetcode/stack/queue/linked-list/tree/trie/disjoint%20set/heap/2022/06/29/Basic-Data-Structure-Implementations.html"} - + diff --git a/docs/tech/2019/07/19/MarkDown101-and-how-to-use-them-in-your-website.html b/docs/tech/2019/07/19/MarkDown101-and-how-to-use-them-in-your-website.html index 14c32dd..7563809 100644 --- a/docs/tech/2019/07/19/MarkDown101-and-how-to-use-them-in-your-website.html +++ b/docs/tech/2019/07/19/MarkDown101-and-how-to-use-them-in-your-website.html @@ -23,7 +23,7 @@ {"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Akash Sharma"},"dateModified":"2019-07-19T00:00:00+05:30","datePublished":"2019-07-19T00:00:00+05:30","description":"This post is a basic cheat-sheet on how to write a markdown based document with proper syntax and formatting. Markdown is an easy-to-remember which is just a lightweight markup language with plain text formatting syntax. We will also explore on how to extend upon its capabilities to work in web page just like this one !","headline":"MarkDown101 and how to use them in your webpages?","mainEntityOfPage":{"@type":"WebPage","@id":"/blog/tech/2019/07/19/MarkDown101-and-how-to-use-them-in-your-website.html"},"url":"/blog/tech/2019/07/19/MarkDown101-and-how-to-use-them-in-your-website.html"} - + diff --git a/docs/tech/2020/08/09/sia-cloud-based-development.html b/docs/tech/2020/08/09/sia-cloud-based-development.html index fab191b..8956d6c 100644 --- a/docs/tech/2020/08/09/sia-cloud-based-development.html +++ b/docs/tech/2020/08/09/sia-cloud-based-development.html @@ -23,7 +23,7 @@ {"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Akash Sharma"},"dateModified":"2020-08-09T00:00:00+05:30","datePublished":"2020-08-09T00:00:00+05:30","description":"Sia is the leading decentralized cloud storage platform. No signups, no servers, no trusted third parties. Sia leverages blockchain technology to create a data storage marketplace that is more robust and more affordable than traditional cloud storage providers.","headline":"Sia Cloud-Based Storage Development","mainEntityOfPage":{"@type":"WebPage","@id":"/blog/tech/2020/08/09/sia-cloud-based-development.html"},"url":"/blog/tech/2020/08/09/sia-cloud-based-development.html"} - + diff --git a/docs/tech/2020/10/14/Exploration-of-Bayesian-Optimization-&-Gaussian-Processes.html b/docs/tech/2020/10/14/Exploration-of-Bayesian-Optimization-&-Gaussian-Processes.html index 43fb4db..f7700eb 100644 --- a/docs/tech/2020/10/14/Exploration-of-Bayesian-Optimization-&-Gaussian-Processes.html +++ b/docs/tech/2020/10/14/Exploration-of-Bayesian-Optimization-&-Gaussian-Processes.html @@ -23,7 +23,7 @@ {"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Akash Sharma"},"dateModified":"2020-10-14T00:00:00+05:30","datePublished":"2020-10-14T00:00:00+05:30","description":"Bayesian Optimization provides a principled technique based on Bayes Theorem to direct a search of a global optimization problem that is efficient and effective. Bayesian Optimization is often used in applied machine learning to tune the hyperparameters of a given well-performing model on a validation dataset.","headline":"Exploration of Bayesian Optimization and Gaussian Processes","mainEntityOfPage":{"@type":"WebPage","@id":"/blog/tech/2020/10/14/Exploration-of-Bayesian-Optimization-&-Gaussian-Processes.html"},"url":"/blog/tech/2020/10/14/Exploration-of-Bayesian-Optimization-&-Gaussian-Processes.html"} - + diff --git a/docs/tech/2021/07/08/Setting-up-Dell-XPS-15-with-Pop!_OS-Distro.html b/docs/tech/2021/07/08/Setting-up-Dell-XPS-15-with-Pop!_OS-Distro.html index bc2dcbd..65fca6c 100644 --- a/docs/tech/2021/07/08/Setting-up-Dell-XPS-15-with-Pop!_OS-Distro.html +++ b/docs/tech/2021/07/08/Setting-up-Dell-XPS-15-with-Pop!_OS-Distro.html @@ -23,7 +23,7 @@ {"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Akash Sharma"},"dateModified":"2021-07-08T00:00:00+05:30","datePublished":"2021-07-08T00:00:00+05:30","description":"I’ve got a Dell XPS 15 9570 (16GB RAM, i7-8750H CPU) for work expecting it to have good support in Linux, considering other XPS laptops ship with Ubuntu.","headline":"Setting up Dell XPS 15 with Pop!_OS Distro","mainEntityOfPage":{"@type":"WebPage","@id":"/blog/tech/2021/07/08/Setting-up-Dell-XPS-15-with-Pop!_OS-Distro.html"},"url":"/blog/tech/2021/07/08/Setting-up-Dell-XPS-15-with-Pop!_OS-Distro.html"} - +