teleren/devto huggingface dataset:
Introduction to Baseline Models
Tags: machinelearning, datascience, beginners
Published: 2020-12-21 04:33:41

In this post, I would like to give an overview of the different baseline models and benchmark approaches that could be used to estimate the performance of the machine learning models. I would divide baseline models into 3 buckets by the technique used: naive, heuristics, and machine/statistical learning models. 

**Naive baselines.**
After processing and cleaning the data, and splitting it to train and test sets, we can start working on the simplest baseline models: e.g., Random Prediction, Zero Rule, One Rule, etc.

Random Prediction.
For simplicity, we can use the binary classification problem (e.g., target =0 or 1).  In the Random Prediction, we don't use any feature from the dataset, but just randomly generate a prediction (0 or 1) for the target, and we expect more or less uniform distribution for the predicted classes. 

ZeroR.
When dealing with an imbalanced classification problem (e.g., have more 0s or 1s in case of binary classification), Zero Rule could be used. This method also relies on the target, while ignoring features. It predicts the majority class. 

OneR.
One Rule uses one feature at a time and correlates it with a target. Basically, by creating a frequency table (one feature vs target) we can predict a target. We do that for all features and choose the one with the smallest error.

**Heuristics.**
"A heuristic technique is any approach to problem-solving that uses a practical method or various shortcuts in order to produce solutions that may not be optimal but are sufficient given a limited timeframe or deadline"[(source).](https://www.investopedia.com/terms/h/heuristics.asp) A heuristic is a method, which is often based on the industry experience and subject matter expertise. For example, in a time-series sales problem, the latest sales data is more important than sales data a few years ago, and using this rule specific features could be engineered and used for the prediction.

**Machine and Statistical Learning Baselines.**
Here we can include some statistical methods, for example for time-series 
regression problems, predicting target by using Moving Average, or AutoRegressive Integrated Moving Average (ARIMA).
From non-parametric models, a decision tree, or even a random forest (depending on the problem) could be used as an example of a baseline.

**Summary.**
There are many specific benchmarks within each bucket, we can use to measure the performance of the main machine learning model. It is good to keep in mind that baseline models (or approaches) should be explainable, computationally inexpensive, and relatively simple. So, if we propose a more complex model to solve the problem, we can compare it to the baseline and see whether this complex model brings more value (e.g. predictive capacity) compare to the baseline.
Automate packaging of Visual Studio Code extension
Tags: vscode, extension, python, automation
Published: 2020-12-21 04:04:41

During my work with the Visual Studio Code extension [AngularTools](https://marketplace.visualstudio.com/items?itemName=coderAllan.vscode-angulartools) I more than once annoyingly forgot one of the steps in the deployment.

Its not a complicated set of tasks but in my list of things to do when packaging a new version I have to:
* Verify that the version number in the package.json has been updated.
* Verify that the CHANGELOG.md file has been updated with a description of bugfixes and new features.
* Create a tag for the version in the Git repository.
* Run `vsce package` to create the vsix package file.

So I automated the tasks with the python script below:

```python
import os
import json
import re
from git import Repo, TagReference

def readVersionFromPackageJson():
  packageJson = open("package.json", "r")
  contentRaw = packageJson.read()
  contentJson = json.loads(contentRaw)
  packageJson.close()
  return contentJson["version"]

def isPackageJsonVersionTagged(repo, packageJsonVersion):
  packageJsonVersionTagFound = False
  for tag in repo.tags:
    if tag.name == packageJsonVersion:
      packageJsonVersionTagFound = True
      break
  return packageJsonVersionTagFound

def isChangeLogUpdatedWithPackageJsonVersion(packageJsonVersion):
  packageJsonVersionChangeLogEntryFound = False
  changeLog = open("CHANGELOG.md", "r")
  changeLogContent = changeLog.readlines()
  changeLog.close()
  for line in changeLogContent:
    match = re.search(f"^## Version {packageJsonVersion}$", line)
    if match:
      packageJsonVersionChangeLogEntryFound = True
      break
  return packageJsonVersionChangeLogEntryFound

def packageExtension():
  os.system("vsce package")

def main():
  packageJsonVersion = readVersionFromPackageJson()
  repo = Repo("./")
  packageJsonVersionTagFound = isPackageJsonVersionTagged(repo, packageJsonVersion)
  packageJsonVersionChangeLogEntryFound = isChangeLogUpdatedWithPackageJsonVersion(packageJsonVersion)

  if not packageJsonVersionChangeLogEntryFound:
    print("Fail: CHANGELOG.md not update!")
  else:
    if not packageJsonVersionTagFound:
      print(f"New version found in package.json: {packageJsonVersion}.")
      print("Creating tag in Git...")
      repo.create_tag(packageJsonVersion)
      print("Creating vsix package...")
      packageExtension()
    else:
      print(f"Fail: Version already tagged: {packageJsonVersion}.")
      print("No vsix package created")
  
main()

```

I hope you find it useful or that it will inspire you to automate some of your boring or annoying tasks.

You can find the script and the code for [AngularTools on GitHub](https://github.com/CoderAllan/vscode-angulartools).

![The script running](https://dev-to-uploads.s3.amazonaws.com/i/j7ambnxt1h8hq0f17boi.gif)
Looking Back at the First Mile
Published: 2020-12-21 03:55:16

   A few weeks ago I wouldn't have thought I'd be celebrating a tic tac toe game. It isn't something world beating, mind blowing or life changing. It didn't show me the meaning of life or the next winning set of lotto numbers. What it has done is give me a sense of satisfaction that goes beyond the simple Xs and Os. I made that. I put together some methods and lines of code and out popped a simple game.  For each little line and circle I wrestled with a language that two weeks ago I knew basically nothing about. In the grand scheme of things it isn't much.  It is just the first hill at the foot of the mountain that the next few months will be. But it was a hill. And on this little hill I will plant a little flag made of Xs and Os.  If all goes well if a few months I'll be up on top of the mountain planting a much bigger flag but for now. For today. I'm happy with my little flag and the Xs and Os. 

Tomorrow, onward to the mountain.
How to get raw sql that is being executed with binded data
Tags: laravel, php, webdev
Published: 2020-12-21 03:27:20

Sometime we need to print executed queries in Laravel application for debug, I will give methods of how to show it.

**Method 1**

In controller:

```php
$posts = Post::whereActive(1);
dd($posts->toSql(), $posts->getBindings());
```

Output:

```
"select * from `posts` where `status` = ?"

array:1 [▼
  0 => 1
]
```


**Method 2**

In controller:

```php
DB::enableQueryLog();
$posts = Post::active()->paginate(5);
$query = DB::getQueryLog();
dd($query);
```

Output:

```
array:2 [▼
  0 => array:3 [▼
    "query" => "select count(*) as aggregate from `posts` where `status` = ?"
    "bindings" => array:1 [▼
      0 => 1
    ]
    "time" => 0.3
  ]
  1 => array:3 [▼
    "query" => "select * from `posts` where `status` = ? limit 5 offset 0"
    "bindings" => array:1 [▼
      0 => 1
    ]
    "time" => 0.3
  ]
]
```

**Method 3**

In controller:

```php
use Illuminate\Support\Facades\DB;

DB::listen(function ($query) {
    dump($query->sql,$query->bindings);
});
$post = Post::ofSlug($slug)->active()->firstOrFail();
```

Output:

```
"select * from `posts` where `slug` = ? and `status` = ? limit 1"

array:2 [▼
  0 => "create-custom-helper-class-in-laravel-7"
  1 => 1
]
```

Happy Coding :)
image thumnails java spring boot | Web Developer
Tags: java, spring, developer, thumbnail
Published: 2020-12-21 03:22:21


{% youtube OCm3DpBimiY %}

This is a method of extracting the desired thumbnail for the file uploaded image in Java Spring Boot environment.

The library github address used for the video is: https://github.com/coobird/thumbnailator

The YouTube video link address is:
https://www.youtube.com/watch?v=OCm3DpBimiY

Please refer to it when making image thumbnails.

Thank you.
Alguns livros grátis sobre Golang!
Tags: go, books, livros
Published: 2020-12-21 03:12:23

Estou aprendendo a programar em GO e uma das coisas que eu mais utilizo para estudar são livros e artigos, então como tem me ajudado acredito que vai ajudar demais também outras pessoas, a maioria deles eu não pude ler ainda, mas este artigo serve até para eu consultar e ver quais faltam.
 
# [Aprenda GO com testes](https://larien.gitbook.io/aprenda-go-com-testes/)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/momlxonvpnzkp9i4frwn.png)

Este é um livro que atualmente estou consumindo muito porque ele dá uma boa visão sobre a linguagem, enquanto explica como funciona os testes na linguagem e os motivos para cada coisa, esta versão está traduzida para PT-BR então é 1000% de dar uma lida até por que é uma leitura bem rápida.

# [Go web programming](https://livebook.manning.com/book/go-web-programming/preface/)
![71kVbQ4a9OL._AC_UL600_SR480,600_](https://dev-to-uploads.s3.amazonaws.com/i/ccqilnum9zfx6ln0x7ma.jpg)

Esta é uma leitura que pretendo ler o mais cedo quanto possível, pude consultar algumas coisas nele e senti ser bem explicado e com muito aprendizado principalmente para mim que tenho muito a aprender principalmente em boas práticas na linguagem, caso prefira você também pode comprar a versão física dele.

# [Go Bootcamp](http://www.golangbootcamp.com/book)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/94pam14674zd4qjtt8xr.png)

Este livro é uma introdução muito maneira ao funcionamento do GO com exemplos práticos e uma lista de exercícios no final bem maneira, assim como o aprenda GO com testes, esta é uma leitura bem tranquila.

# [Go for Javascript Developers](http://www.pazams.com/Go-for-Javascript-Developers/)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2o29d8zquyqdxix4xgy7.png)

Esta é uma leitura que eu estou extremamente interessado em ler, pois, eu tenho mais afinidade com Javascript/Typescript então acredito que será uma leitura quase obrigatória para mim, de modo a entender as semelhanças e as diferenças entre as linguagens.

# Conclusão

Estes foram alguns livros que encontrei, caso queiram mais, este repositório -> [GoBooks](https://github.com/dariubs/GoBooks) <-  tem vários livros sobre GO tanto pago quanto grátis(Lembra de deixar a :star: se gostar), caso conheçam mais algum livro interessante, ou até mesmo série de artigos compartilhe aqui conosco e fortaleça o compartilhamento de informações de forma gratuita. 
Obrigado por ler até o fim, e caso eu esteja errado em algo ou tenha passado alguma informação ruim, por favor me avise de alguma forma, uso estes artigos para fixar conhecimento e compartilhar informação aos próximos.
![Alt](https://res.cloudinary.com/practicaldev/image/fetch/s--uLCaazgs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5991methcmv4ojwolws2.gif)
Why I chose Software Engineering
Tags: cybersecurity, programming, womenintech, softwareengineer
Published: 2020-12-21 03:11:42

When this year started, I thought about all the goals I had set and what I was going to achieve and yes, some obstacles that would come in the way. But I never would have thought that in March everything would change and we as a world would stumble upon a huge obstacle. COVID-19. This felt like the world froze for a couple of months and I could take a step back and actually reflect on what it is I want in life. I have a bachelor's degree in Criminal Justice and I've been working at TSA with Homeland Security for a while. I felt like it was time for something new and I started thinking about Cybersecurity. How amazing would it be to learn more about technology, incorporating my degree with software engineering? That was the motivation I needed to look more into Software Engineering. I spent weeks on FreeCodeCamp and figured out, this is something I genuinely enjoy doing. It's a challenge but it is also very rewarding once you have the issues figured out. The beauty of software engineering is that we are able to build the things that we are passionate about, we're not limited to certain things. You can be creative and that is the kind of person I am, creativity and working hands on. We are able to help others through building an app or even helping our nation by protecting it through cyber security. That to me is my passion.
How to run docker containers in AWS EC2
Tags: docker, react, aws, node
Published: 2020-12-21 02:43:35

# Dockerized `Click Counter app` app to deploy at AWS EC2 ubuntu instance

> Get the source code [here](https://github.com/kamal-hossain/MERN-docker-ec2-deploy-practice)

### Stack 
- React 
- Nodejs
- MongoDB

---

## Docker notes
If docker is installed you can build and run images locally.

```
docker-compose up --build
```
> Set the `REACT_APP_API_URL` variable in .env, based on your need.


## Create a new EC2 instance (Ubuntu 18.04)

- Go to AWS EC2
- Launch instance
- Chose Ubuntu 18.04 64 bit ( you can choose as your need )
- Select Free tier eligible ( recommended for testing )
- In `Configure Security Group` add `All traffic` rule and allow from anywhere ( for testing only )
- Leave all settings as default 
- Launch
- Create a key pair, and download it.

## Connect EC2 instance from Windows machine

- Install [PuTTY](https://www.putty.org/) 
- Open PuTTYgen, `Load` the downloaded `*.pem` file
- Save private key ( this will save a `*.ppk` file )
- Go to the AWS EC2
- Select the instance 
- Click on `connect`
- Copy the name from `ssh` ( the part should start with `ubuntu` and end with `.com` )
- Open PuTTY ( NOT PuTTYgen! ) 
- Go `Session`, paste the copied name in `Host Name (or IP address)` leave port as `22`
- Go `Connection` > `SSH` > `Auth` and browse the saved private key ( `*.ppk` ) in `Private key file for authentication` 
- Click `Open`
- Click `Yes` ( if anything prompt up ) 

## Configure docker in EC2 (Ubuntu 18.04)

Run the following commands to install docker and docker compose

```
sudo apt-get update
```
```
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
```
```
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
```
```
apt-cache madison docker-ce
```
```
sudo apt install docker.io
```
```
sudo apt install docker-compose
```

Run this repo in AWS EC2 by following commands

```
git clone https://github.com/kamal-hossain/MERN-docker-ec2-deploy-practice
```

```
cd MERN-docker-ec2-deploy-practice
```

```
sudo docker-compose up --build
```

You can also run it background by adding `-d` flag

```
sudo docker-compose up --build -d
```
Confirm it by

```
sudo docker ps
```
Stop the containers
```
sudo docker-compose down
```

To access the app from browser do the followings:

- Select the instance in AWS EC2
- Copy the `Public IPv4 address` from Details
- Open it on browser

> You can't access the IP if `All traffic` is not enabled in `Security group` from anywhere. (Or simillar settings)

---

Resource(s): [1](https://www.youtube.com/watch?v=awFLzy0XwXo)
Taskord Changelog - Dec 21
Tags: opensource, productivity, changelog, showdev
Published: 2020-12-21 02:15:04

Welcome to **Taskord Changelog** 📜, This is a weekly post where we share what we shipped to [Taskord](https://taskord.com) this week.

Visit Taskord: https://taskord.com

**This week on Taskord**

- Brand new Icon set, Thanks to [Heroicons](https://heroicons.com), no more slowly Font Awesome

![Screenshot 2020-12-21 073420](https://dev-to-uploads.s3.amazonaws.com/i/sp1x89ll1exuoc98v3f2.png)

![Screenshot 2020-12-21 073536](https://dev-to-uploads.s3.amazonaws.com/i/yjikgxnzzihwopt8psyk.png) 

- Users can now set account Status

![Screenshot 2020-12-21 073630](https://dev-to-uploads.s3.amazonaws.com/i/6l5l0blb0nwhmkl581mh.png)

![Screenshot 2020-12-21 073652](https://dev-to-uploads.s3.amazonaws.com/i/lqqyjfe92avfz3s1b1ss.png)

- Improved web vitals score

![Screenshot 2020-12-21 073934](https://dev-to-uploads.s3.amazonaws.com/i/9e89tr5aak5dd8c2e3hh.png)

- Dark mode is now even darker

![Screenshot 2020-12-21 074053](https://dev-to-uploads.s3.amazonaws.com/i/bztx6iu1zeiosrtjdf0b.png)

- Added Product avatar on the popover

![Screenshot 2020-12-21 074315](https://dev-to-uploads.s3.amazonaws.com/i/jlv70eaj009il882zlt1.png) 

- Improved sidebar design
- Now Images are served from Imagekit CDN
- Lot more security and performance improvement

Happy shipping ❤️
RCT005 React Scaffold
Tags: react
Published: 2020-12-21 02:12:53

# React脚手架

使用React开发一个单独的前端项目，也就是前后端分离后的前端部分。

# create-react-app

`create-react-app`是FaceBook的React团队官方出的一个构建React单页面应用的脚手架工具。

## 安装

利用npm来进行**全局**安装。

```
npm install -g create-react-app
```

## 创建项目

```
create-react-app xxx
```

创建的项目会是一个nodejs的项目，并且已经自动配好了react的环境。

## 运行项目

通过查看生成的`package.json`文件，可以知道通过`npm run start`来运行项目，输入指令后，会自动以端口号3000运行，并打开浏览器。

## 项目结构

项目内除了`node_modules`文件夹用来存储包，还有：

- `src`文件夹存储页面（js文件）和css文件，包括入口文件`index.js`
- `public`文件夹存储静态资源，包括整个项目的基础`index.html`

# create-react-app 的 Hello World

将之前的To do List 迁移到脚手架里，我们需要替换`App.js`和`App.css`里面的内容，其他都不需要改变。

App.js
```javascript
import React from 'react';
import './App.css';

class App extends React.Component {

  state = {
    value: '',
    list: []
  }

  handleAdd = () => {
    const val = this.state.value;
    const list = this.state.list;
    //或 es6结构语法
    // const{val,list} = this.state;
    list.push(val);
    this.setState({
      list: list
      //es6中 当list和value相等时，可以省略key
      //由list:list 简写为 list
    })
  }

  handleInput = (event) => {
    this.setState({
      value: event.target.value
    })
  }

  handelRemove = (event) => {
    var kk = event.target.dataset.bid
    console.log(kk)
    var arr = this.state.list;
    arr.splice(kk, 1)  // delete the item with index kk
    this.setState({
      list: arr
    })
  }

  render() {
    const val = this.state.value;
    const arr = this.state.list;
    const listItem = []
    for (var i = 0; i < arr.length; i++) {
      listItem.push(
        <li key={i}>
          {arr[i]}
          <button data-bid={i} onClick={this.handelRemove}>remove</button>
        </li>
      )
    }

    return (
      <div className="container">
      	<p>欢迎学习react</p>
        <h1>Hello World</h1>
        <div>
          <input type="text" value={val} onChange={this.handleInput} placeholder="To do" />
          <button onClick={this.handleAdd}>Add Item</button>
        </div>
        <ul>
          {listItem}
        </ul>
      </div>)
  }
}

export default App;
```

App.css
```css
.container {
  text-align: center;
  margin: 20px auto;
}
.container p {
  font-size: 10px;
}
.container h1 {
  font-size: 20px;
  color: #02043d;
}
```

实际上，这个脚手架做的事情是：

1. App.js里面写了一个`<App />`标签
2. index.js里面将 `<div> <App /> </div>`渲染到了index.html中

也就是说，我们是一个单页面应用，我们开发时只需要修改App等相关文件就可以了。我们项目中看上去是页面跳转，实际上是`<App>`标签发生了改变，react重新渲染了它。
IntelliJ doesn't open .class files, unlike VSCode???
Tags: help, intellij, java, watercooler
Published: 2020-12-21 01:58:01

I was suggested IntelliJ as an IDE for Java, since it's "better" than VSCode (in my experience, it looks weird in comparison, and isn't as "easy" to use), but, I tried `ctrl+lclick`ing on `String`, but it said it couldn't find a definition, I tried it with some other `java.lang` classes, and apparently none of them are defined? Why?
VSCode never had an issue, and this IDE feels like a downgrade.

Can anyone explain how I can get this feature (viewing classes by `ctrl` and `lclick`ing on the name) to work, and how I can make it more like my old VSCode setup?

Thanks.
Cheers.
Is GitHub going to disable command line access for git ?
Tags: github, git
Published: 2020-12-21 01:55:28

I received a mail that

```
Hi @SoumyaRanjanNaik,

You recently used a password to access the repository at <sensitive data> with git using git/2.25.1.

Basic authentication using a password to Git is deprecated and will soon no longer work. Visit https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information around suggested workarounds and removal dates.

Thanks,
The GitHub Team
```

So I want to understand if 
1. I should stop using git and instead start using the github-cli instead ?

2. Is git access being deprecated to older git version or is it the case for all git versions ?
Unpopular Language to Learn
Tags: language, unpopular, programming, learning
Published: 2020-12-21 01:43:53

So I have learned C++, Python, and HTML, and currently I am learning CSS, Advanced C++, and JS. I feel like all of these languages are pretty good but they are all very popular too. I want to learn another programming language, which isn't as popular as the 5 I am learning or have learned. Someone told me Ruby before, which I think is a good choice, and I might learn Ruby itself, but if anyone else has another programming language which they think is not popular but good, please tell me.