teleren/devto huggingface dataset:
How to use a Dictionary API
Tags: tooling, todayilearned, json
Published: 2021-01-18 04:31:32

Hey!

# Step 1: Get the words
1. I manually scraped tough English words from the internet and stored it in a json file.

# Step 2: Finding a dictionary API
1. I used the Merriam Webster Dictionary API
2. Understanding the API seems a bit intimidating..Let's make a request with the API and check out the json response we receive:
`https://www.dictionaryapi.com/api/v3/references/thesaurus/json/umpire?key=yourkey`

![Screenshot 2021-01-17 at 8.23.42 PM](https://dev-to-uploads.s3.amazonaws.com/i/atb7symhwxjd0o19fh7q.png)

So at the topmost level we have 5 keys - 

###I. meta
![Screenshot 2021-01-17 at 8.44.09 PM](https://dev-to-uploads.s3.amazonaws.com/i/ohwbcfha7ucvxrllysnt.png)
 
- The key refers to metadata(a shorthand representation of data) and gives a shorthand representation of the word.
It contains:
  1. "id" - the word itself (here, "umpire")
  2. "uuid" - universally unique identifier ( a string)
  3. "src" - source data set (like collegiate thesaurus)
  4. "section" - indicates section (alpha - alphabetical, geog - geographic etc..)
  5. "stems" - other words which stem from this word - lists all of the word's variants - querying the API with this word would also return the same response
  6. "syns" - synonyms

###II. hwi
![Screenshot 2021-01-17 at 8.47.48 PM](https://dev-to-uploads.s3.amazonaws.com/i/3ntogvfqrcopyp4g2pe7.png) 
- means head word information
- "hw" : string  headword

###III. fl
![Screenshot 2021-01-17 at 8.50.24 PM](https://dev-to-uploads.s3.amazonaws.com/i/d8bt39vacld9cxz11wu7.png) 
- means functional label
- tells grammatical function(noun, adj etc..)

###IV. def
![Screenshot 2021-01-17 at 8.59.44 PM](https://dev-to-uploads.s3.amazonaws.com/i/v7uke1ytsbswr8sp116l.png) 
- groups together all sense sequences and verb dividers(transitive/intransitive)
   1. sseq - sense sequence contains a series of senses
![Screenshot 2021-01-17 at 9.30.21 PM](https://dev-to-uploads.s3.amazonaws.com/i/55bla16d7ahdat46pfgi.png) 

sense - a unit which contains all content relevant to a particular meaning
![Screenshot 2021-01-17 at 9.31.00 PM](https://dev-to-uploads.s3.amazonaws.com/i/27cshf7xtza408yo7ydi.png)

dt - defining text is an array which contains:
1. ["text", string] - string is definition of word
2. ["vis", [{object}]] - verbal illustration is an example sentence and each object may contain the members:

"t" : string  text of verbal illustration

![Screenshot 2021-01-17 at 11.18.41 PM](https://dev-to-uploads.s3.amazonaws.com/i/qtdpuzg5xxvcqpduc4ds.png)
 
###V. shortdef 

a highly abridged version of the main definition section, consisting of just the definition text for the first three senses. 

![Screenshot 2021-01-17 at 11.21.19 PM](https://dev-to-uploads.s3.amazonaws.com/i/nt25d16bpuui6eywkt15.png)
 
That's all for now.
Bye!
@stratospher
How machine learning and deep learning can improve our daily lives in future
Published: 2021-01-18 04:21:25

Undeniably, artificial intelligence has become one of the most talked-about areas of the IT domain.
The terms “artificial intelligence,” “machine learning” and “deep learning” are often thrown about interchangeably.AI is just a container. You don’t learn AI. I’ll not confuse with terms.
Let’s see the difference between Deep Learning And Machine Learning-
Machine learning, which is a type of artificial intelligence (AI), was born in the 1950s. Arthur Samuel wrote the first computer learning program in 1959, in which an IBM computer got better at the game of checkers the longer it played. Where as in deep learning You may already have experienced the results of an in-depth deep learning program without even realizing it! If you’ve ever watched Netflix, you’ve probably seen its recommendations for what to watch. And some streaming-music services choose songs based on what you’ve listened to in the past.While machine learning uses simpler concepts like predictive models, deep learning uses artificial neural networks designed to imitate the way humans think and learn.
THE FUTURE
• Machine learning
Machine learning focuses on the development of computer programs that can access data and use it learn for themselves.Machine learning is being used in a wide range of fields: art, science, finance, healthcare—you name it. And there are different ways of getting machines to learn.In other words, they continuously improve their performance on a task—for example, playing a game—without additional help from a human.It’s helpful to know R or Python if you want to delve more deeply into machine learning with R and machine learning with Python.Supervised machine learning algorithms ,unsupervised machine learning algorithms ,Semi-supervised machine learning algorithms ,Reinforcement machine learning algorithms are some of the machine learning methods.Basic machine learning applications include predictive programs (such as for forecasting prices in the stock market or where and when the next hurricane will hit), email spam identifiers, and programs that design evidence-based treatment plans for medical patients.
• Deep Learning
Deep learning allows machines to solve complex problems even when using a data set that is very diverse, unstructured and inter-connected.In addition to the examples mentioned above of Netflix, music-streaming services and facial recognition, one highly publicized application of deep learning is self-driving cars—the programs use many layers of neural networks to do things like determine objects to avoid, recognize traffic lights and know when to speed up or slow down. The healthcare industry also will likely change, as deep learning helps doctors do things like to predict or detect cancer earlier, which can save lives.
As you may have figured out by now, it’s an exciting (and profitable!) time to be a machine learning engineer. So there has never been a better time to begin studying to be in this field or deepen your knowledge base.
Share it if you liked this blog! Thank you
XG Boost for Classification

Tags: machinelearning, datascience
Published: 2021-01-18 03:23:16

The logic of the XGBoost Classification algorithm is similar to [XGBoost Regression](https://dev.to/xsabzal/xg-boost-for-regression-5c90), with a few minor differences, like using the Log-Likelihood Loss function, instead of Least Squares and using Probability and Log of Odds in the calculations. 

1) Define initial values and hyperparameters.

1a) Define differentiable Loss Function, e.g. 'Negative Log-Likelihood' : 
L(yi,pi) =- [yi*ln(pi) +(1-yi)*ln(1-pi)], where 
yi- True probabilities (1 or 0), pi - predicted probabilities.
Here we will convert pi to odds and use log of odds when optimizing the objective function.

1b) Assign a value to the initial predicted probabilities (p), by default, it is the same number for all observations, e.g. 0.5.

1c) Assign values to parameters:
learning rate (eta), max_depth, max_leaves, number of boosted rounds etc.
and regularization hyperparameters: lambda, gamma. 
Default values in the XG Boost [documentation](https://xgboost.readthedocs.io/en/latest/parameter.html).  

2) Build 1 to N number of trees iteratively.
This step is the same as in the [XGBoost Regression](https://dev.to/xsabzal/xg-boost-for-regression-5c90), where we fit each tree to the residuals.

The difference here: 
a) in the formula of the output calculation, where 
H = Previous_Probability*[1-Previous_probability].
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/49asc6jv2a994jc7qqmx.png)
  
b) we compute new prediction values as 
log(new_odds) =log(previos_odds) + eta * output_value
new_probability = e^log(new_odds)/[1+e^log(new_odds)]

3)last step: get final predictions
Creating a Featured Posts collection in 11ty
Tags: tutorial, javascript, 11ty
Published: 2021-01-18 04:17:07

---
title: Creating a Featured Posts collection in 11ty
published: true
description: A small snippet of code showing how to create a featured posts collection
tags: tutorial, javascript, 11ty
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/56190whoohniuof726ma.png
---
My site [jonathanyeong.com](https://jonathanyeong.com) is built using Eleventy (11ty). 11ty is a static site generator that is flexible with folder structure, data, and templates. This flexibility makes it really easy to add new features or customizations to your site. One feature that I wanted on my site is "Featured Posts". These posts would be the first posts you see on the homepage. They would be handpicked by me. And I wanted to define an ordering for them. 

Here's how I set up Featured Posts.


## Defining the front matter

11ty allows you define some data in your templates through front matter. Front matter is a block of text between a pair of three dashes. In the example below, I'm using [yaml](https://yaml.org/) front matter to add some metadata to my post. Here are the 11ty docs for more on [Front Matter data](https://www.11ty.dev/docs/data-frontmatter/).

The two lines relevant to this tutorial are `featured_posts: true` and `post_weight: 1.0`.

```yaml
---
date: 2020-12-15T00:00:00-08:00
title: Blog post title
published: true
featured_post: true
post_weight: 1.0
---

<h1>Post Content<h1>
```

Now that the front matter is squared away we need to create the Featured Posts collection.

## Creating the collection
A collection in 11ty is an array of objects. These objects can come from any number of places. Let's break down how we create the `featuredPosts` collection.

1. Specify the collection that we're creating via `addCollection('featuredPosts'...`.
2. Get all my markdown posts from `/src/posts/` using `getFilteredByGlob`.
3. Filter the collection by `published` and `featured_post`. These two pieces of data come from the front matter we declared above.
4. Sort the filtered collection by `post_weight`. The largest post weight will be the first post you see in the `featuredPosts` collection.
5. Now you can use this collection in your 11ty templates via `collections.featuredPosts`.

```javascript
eleventyConfig.addCollection('featuredPosts', collection => {
 return collection.getFilteredByGlob('./src/posts/*.md')
   .filter(
     post => post.data.featured_post && p.data.published
   )
   .sort((a,b) => {
     return a.data.post_weight - b.data.post_weight;
   });
});
```
---
There's a lot more you can do with collections. If you're interested here are the [11ty docs on collections](https://www.11ty.dev/docs/collections/). I hope this tutorial has inspired you to add featured posts to your site. Or to create your own collection! 

> *I'd love to know if this article helped you or if you found it confusing. Please leave a comment below, I can't wait to read them!*
JavaScript: Memoization
Published: 2021-01-18 04:16:17

Hey Guyz! I wanted to write a quick little blog about the memoization topic in JavaScript. At the start of my learning, the concept was so confusing to me(as was may other things lol), so I am writing this blog for you as well as for me solely for the purpose referring back to it in the future. Cool, lets get into it! 

What is Memoization?

Memoization is cache return value of a function based on specific parameters. *"When we input the same value into our memoized function, it returns the value stored in the cache instead of running the function again, thus boosting performance. No longer does your program have to recalculate every number to get a result."*(Medium, codesmith Jan 17, 2018)

Memoization is essentially creating an object, checking for values matching the parameters, then storing new key-values that aren't available. Breaking down complex problems into tinier problems then storing it in a table(array, hash, and map)

    function memoizeMultBy2() {
      const cache = {}
      return function (num) {
        if (num in cache) {
          return cache(num)
        } else {
          cache[num] = num * 2
          console.log("Loading....")
          return cache[num]
        }
      }
    }
     
    const memoize = memoizeMultBy2()
    console.log(memoize(2))


I followed this algorithm by watching an explanation by youtuber Adam Coder. Summarizing the algorithm, we created a cache object, within the function we are also returning an function, we initialized and declared the variable memoize and invoked it so we are able to pass in a parameter. The first time we run this algorithm, we will get "Loading...." then the answer 4, when this algorithm is run again, the num parameter has already been cached so it displays the num without running through the algorithm again saving run time.


I hope this made sense and helped you, please let me know if there is anything you think I should clarify. Keep Smiling and enjoy life!
Reporting in Power BI - Quick Steps
Tags: database, sql, datascience, beginners
Published: 2021-01-18 04:12:24

Power BI is a business analytics service by Microsoft. It aims to provide interactive visualizations and business intelligence capabilities with an interface simple enough for end users to create their own reports and dashboards.

# Power BI Reporting

##Steps:

### 1. Prepare Data

- Importing Data (from data sources)
- Transforming Data (Edit query in Query editor)
  * Rename table
  * Append Query (two or more tables to append columns)
  * Fixing Metadata
  * Filter Rows (condition)
  * Remove Columns
  * Adding Columns
  * Merge queries (inner, outer, left, right)
  * Split by delimiter

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/nopyer2pdhx1sjko5hi5.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bgduhd75exheuokm0w9i.png)


- Cleansing Data (Edit query in Query editor)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rd2is22ri8vg3unpp115.png)


### 2. Create Data Model, Enhance

- Define table relationships
  * Fix data model for summarization
  * Fix query and create relationships
- Configure Model properties

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/th1bsw8pbn7s076mrw06.png)

- Adding Calculated columns and Measures (DAX - Data Analysis Expression)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/fiowfggyngrcbr5m9nr9.png)

- Create hierarchies

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/iors7u9l6ztrqwjb26ii.png)


### 3. Create Report

#### Report elements

- Visualization elements
- Static elements
- Page

#### Format

- Chart (Conditional Formatting)
- Page (background)

### 4. Publish Report

- PBIX file
- Pin to Dashboard

### 5. Visualize Data

- Filters, Slicers
- Highlighting, Drilling

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/v21qfv1i65k6c9aut5ep.png)

### 6. Refresh Data

- Publish dataset
- Refreshing data
- Power BI Gateway set up - Personal
- Power BI Gateway - Enterprise
My Experiences in the Hacker Community & MLH Local Hack Day: Build 
Tags: mlh, majorleaguehacking, localhackday, opensource
Published: 2021-01-18 04:06:23

![unknown](https://dev-to-uploads.s3.amazonaws.com/i/q3i356ckkkam3p9dgpia.png)
It's 5 am in the morning as I write this, and I've just spent the last 48 hours straight mentoring at HackED, HackDavis, and SB Hacks, so you'll have to forgive me if my structure isn't on point.

My experiences in the hacker community have by and large been extremely positive, thanks to the amazing network of people that hold the community up on their shoulders. 

Every single mentoring experience, every single hackathon participated in, have all served to deepen my bonds in this community. I've met some truly amazing people along the way, networked with people who are not even close to me geographically, people I would never have gotten the chance to meet if not for this community.

My most recent (and stand-out) experiences in this community are:
a) Participating in (and potentially winning! The final results are not out at the time of writing this post, but fingers crossed!) Major League Hacking's Local Hack Day: Build 2021, and
b) Mentoring at HackDavis 2021

a)
The 'day' part of the name 'Local Hack Day' is a misnomer (and so is the 'Local' part) - LHD: Build 2021 was an event that stretched across a week, involving people from all around the globe, and whose goal was to encourage hackers to push the boundaries of their comfort zones - task by task, workshop by workshop, challenge by challenge.

The week consisted of daily challenges on a (no points for guessing!) daily basis, as well as larger projects that you could pursue over the course of a week. 

These projects / hack-challenges were all over the place - one day, you'd be building a flask web app in python, and the next day, dealing with blockchain for a fintech hack, with workshops, live streams, and mini-events peppered in between.

These streams and workshops were challenge-based, so if you found a particular task to be too challenging, you could tune into that particular stream to borrow some tips and inspiration from a more seasoned MLH Coach.

Overall, I felt like the past week was one of amazing learnings, getting my feet wet in many new stacks (Winning doesn't hurt either :P)

Moving on to my second experience,

While LHD was about building and hacking together projects, there's something I enjoy even more: helping people out and mentoring them.

This is something I got from HackDavis, where I did my best to help out a bunch of hackers trying to put together projects on incredibly short timelines.

My role at HackDavis involved helping out the hackers that raised support tickets, when they faced difficulty with a concept or issue. Not only did I get the satisfaction of helping the community from this, I met a ton of really amazing fellow mentors, and was able to network effectively, in a non-stiff manner.

All-in-all, this week has been an amazing start to 2021, and I'm expecting great things from my interactions with the hacker community this year!

Signing off,
Sreekaran
What is Major League Hacking by a Hacker!
Tags: mlh, majorleaguehacking, localhackday
Published: 2021-01-18 03:50:45

What is Major League Hacking ??
It is a Company which organizes Hackathons for the students at weekends. But they just don't stop here , the also provide then students with Mentor support so that if they get stuck somewhere in their project the mentor can help them to resolve that problem . 

The also have Different Categories like first, second and third position and those winners also get attractive prizes plus some Awesome Swags . Not only this all the participants who have participated in this gets swags.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ebf7owy2zvzypurgb1fw.jpeg)

Who Am i ? 
I have been Hacking (Making Project ) At MLH Hackathons since last 5 months and have also participated in Local Hack Day Learn and organized various events at our Guild i.e Developer Students Community. I have attended 10 + Hackathons and also have mentored and volunteer in some . As a CSE Student i would suggest just go to the Hackathons you will learn so many new things there and your network will also gradually increase.

Next big Event by MLH : Local Hack Day [Share] .
NodeJS Create folder if not exists in 3 lines - No dependencies
Tags: webdev, javascript, filesystem
Published: 2021-01-18 03:44:21

---
title: NodeJS Create folder if not exists in 3 lines - No dependencies
description: The simplest and dependency-free way to create a folder in NodeJS if it doesn't exist
canonical_url: https://puruvj.dev/blog/create-folder-if-not-exists
---

> [Read this post in **dark** or **mid-day** theme](https://puruvj.dev/blog/create-folder-if-not-exists)

Here's a very simple trick to create a folder if it doesn't exists (Or ensure if a folder exists) in NodeJS. **Just 3 lines, no dependencies**

# Minimum requirements

1. NodeJS >= v10 LTS.
2. Working knowledge of `promises` and `async await`.

That's it 😊

# TLDR Code:

```js
const { mkdir } = require('fs').promises;

try {
  await mkdir('folderPath');
} catch (e) {}
```

# Explanation

1. We import promise-based version of mkdir from `fs.promises`. Read my article about [Simple code with fs.promises and async await](https://puruvj.dev/blog/fs-promises).

2. We actually create the folder with the `await mkdir('folderPath')`.

> Note: We are using an await here, so it's necessary for this code to be in an async function, or you can also use the <mark>Top Level Await</mark> feature in NodeJS >= 14.8.0. Read my article about why [Top level Await is AWESOME!! 😍](https://puruvj.dev/blog/top-level-await)

## Why wrap it in try-catch?

Remember: We're trying to create a folder if it doesn't exists. That means there's a fair chance it may already exists, in which case mkdir will throw an error, and will stop the rest of code from executing. We don't want that now, do we? 😉

So if `mkdir` works perfectly, good, means the folder didn't exist, so it was created. But if it throws error, try catch will simply catch the error, ignore it, and move on to the rest of the code.

Simple!

# As a utility function

Make this snippet part of your utility belt 👇

```js
/**
 * Ensure that a folder exists
 * @param {string} folderPath
 */
async function ensureFolder(folderPath) {
  try {
    await mkdir(folderPath);
  } catch (e) {}
}
```

Hope it helped!
Code Smell 56 - Preprocessors
Tags: codenewbie, tutorial, programming, codesmell
Published: 2021-01-18 03:02:35

*We want our code to behave different on different environments, operating systems, so taking decisions at compile time is the best decision, isn't it?.*

# Problems

- Readability

- Premature Optimization
 
- Unnecessary complexity

- Debugging

# Solutions

1. Remove all compiler directives.

2. If you want different behavior, model it with objects

3. If you think there's a performance penalty, make a serious benchmark instead of doing premature optimization.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/b9945cd67cc06de97cffe8edb114862c)
```c
#if VERBOSE >= 2
  printf("trace message");
#endif
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/717c0b451c159315180c56fb0849419c)
```c
if (runtimeEnvironment->traceDebug()) {
  printf("trace message");
}

## even better with polymorphism and we avoid annoying ifs

runtimeEnvironment->traceDebug("trace message");

```

# Detection

This is a syntactic directive promoted by several languages, therefore it is easy to detect and replace with real behavior.

# Tags

- Compilers

- Metaprogramming

# Conclusion

Adding an extra layer of complexity makes debugging very difficult. This technique was used when memory and CPU were scarce. Nowadays, we need clean code and we must leave premature optimization buried in the past.

Bjarne Stroustrup, in his book *The Design and Evolution of C++*, regrets on the pre-processor directives he created years before.
 
# Relations

{% post https://dev.to/mcsee/code-smell-20-premature-optimization-4moe %}

# More info

{% post https://dev.to/mcsee/laziness-i-meta-programming-32a9 %}
 
[C++Faq](http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.8)

[C Preprocessor](https://en.wikipedia.org/wiki/C_preprocessor)

[#ifdef Considered Harmful](https://www.usenix.org/legacy/publications/library/proceedings/sa92/spencer.pdf)

# Credits

<span>Photo by [CDC](https://unsplash.com/@cdc) on [Unsplash](https://unsplash.com/s/photos/customs)</span>

* * *

>  C++ is designed to allow you to express ideas, but if you don't have ideas or don't have any clue about how to express them, C++ doesn't offer much help.

_Bjarne Stroustrup_
  
* * *
 
{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}
Day15 :100DaysOfCode
Tags: 100daysofcode, productivity, java, programming
Published: 2021-01-18 03:01:38

Completed the daily scrum at intern..

thereafter studied scanline and Linear Diophantine Equations
algo...
some leetcode questions

continued learning spring .
will continue with trees from today :)
. 
. 
thats all!

You can Follow me->
https://github.com/singhtaran1005
https://www.linkedin.com/in/taranpreet-singh-chabbra-27517918a/