Elton  Bogan

Elton Bogan

1597001880

DBSCAN From Scratch (Almost)

Part One: What?

DBSCAN (Density-Based Spatial Clustering of Applications with Noise) is a data-clustering algorithm originally proposed by Ester et al in 1996.

Definitions

  • ε (epsilon): the radius of a neighborhood centered on a given point
  • Core Point: a given point is considered a Core Point if there are at least minPts points within its ε neighborhood, including itself
  • Border Point: a given point is considered a Borer Point if there fewer than _minPts _points within its ε neighborhood, including itself
  • Noise: any point that is not a Core Point or Border Point
  • Directly Density Reachable: a given point is Directly Density Reachable (ε Reachable) from another point if the second point is a core point, and the first point lies within the ε neighborhood of the second point
  • Density Reachable: a given point is Density Reachable from another point if there is a chain of points, Directly Density Reachable from each other, that connects them
  • Density Connected: A given point is Density Connected from another point if there is a third point from which both are Density Reachable — These points are said to be Connected Components

Method

Given a set of points P, the radius of a neighborhood ε, and a minimum number of points minPts:

  1. Find all points within the ε neighborhood of each point;
  2. Identify Core Points with at least minPts neighbors;
  3. Find all Connected Components of each core point — This Density Connected grouping of points is a cluster
  4. Each Border Point is assigned to a cluster if that cluster is Density Reachable, otherwise Border Point is considered Noise

Any given point may initially be considered noise and later revised to belong to a cluster, but once assigned to a cluster a point will never be assigned.

#algorithms #science #python #data-science #analytics

What is GEEK

Buddha Community

DBSCAN From Scratch (Almost)
Ian  Robinson

Ian Robinson

1624380180

Big data Clustering: MR-DBSCAN from scratch using Python

Clustering based on basic standards like density, shape, and size is very common. In a similar way, DBSCAN is an extensive method of the density-based clustering algorithm.

For MapReduce check this article (https://medium.com/@rrfd/your-first-map-reduce-using-hadoop-with-python-and-osx-ca3b6f3dfe78)

Algorithm description:

  1. Choose a random point p.
  2. Fetch all points that are density-reachable from p with respect to eps and minPts.
  3. A cluster is formed if p is a core point.
  4. Visit the next point of the dataset, if p is a border point and none of the points is density-reachable from p.
  5. Repeat the above process until all the points have been examined.

#mapreduce #big-data #partitioning #dbscan #clustering-algorithm #big data clustering: mr-dbscan from scratch using python

Brooke  Giles

Brooke Giles

1662003714

Scratch Card with HTML, CSS and JavaScript

This tutorial shows how to create a scratch card with HTML, CSS and JavaScript. Basic knowledge of Canvas might come in handy for this project, but it isn’t necessary.

00:00 Intro
00:05 Project Preview
00:53 HTML & CSS
06:07 Step 1: Create Initial References
06:36 Step 2: Implement The init()
08:32 Step 3: Detect If The Device Is A Touch Device
12:16 Step 4: Get Position Of Mouse/Touch
14:40 Step 5: Add Event Listeners To Canvas
15:41 Step 6: Function To Draw Scratch

HTML:

We start with the HTML code. The HTML code creates elements necessary to build the structure of our scratch card. First, copy the code below and paste it into your HTML document.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Scratch Card</title>
    <!-- Google Fonts -->
    <link
      href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap"
      rel="stylesheet"
    />
    <!-- Stylesheet -->
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div class="container">
      <div class="base">
        <h4>You Won</h4>
        <h3>$10</h3>
      </div>
      <canvas id="scratch" width="200" height="200"></canvas>
    </div>
    <!-- Script -->
    <script src="script.js"></script>
  </body>
</html>

CSS:

With CSS, we style the scratch card according to our desired theme. For this copy, the code provided to you below and paste it into your stylesheet.

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
body {
  height: 100vh;
  background: linear-gradient(135deg, #c3a3f1, #6414e9);
}
.container {
  width: 31em;
  height: 31em;
  background-color: #f5f5f5;
  position: absolute;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 50%;
  border-radius: 0.6em;
}
.base,
#scratch {
  height: 200px;
  width: 200px;
  position: absolute;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 50%;
  text-align: center;
  cursor: grabbing;
  border-radius: 0.3em;
}
.base {
  background-color: #ffffff;
  font-family: "Poppins", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1.2em 2.5em rgba(16, 2, 96, 0.15);
}
.base h3 {
  font-weight: 600;
  font-size: 1.5em;
  color: #17013b;
}
.base h4 {
  font-weight: 400;
  color: #746e7e;
}
#scratch {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

Javascript:

Finally, we implement the logic of this code. To do that, copy the code below and paste it into your script file.

let canvas = document.getElementById("scratch");
let context = canvas.getContext("2d");

const init = () => {
  let gradientColor = context.createLinearGradient(0, 0, 135, 135);
  gradientColor.addColorStop(0, "#c3a3f1");
  gradientColor.addColorStop(1, "#6414e9");
  context.fillStyle = gradientColor;
  context.fillRect(0, 0, 200, 200);
};

//initially mouse X and mouse Y positions are 0
let mouseX = 0;
let mouseY = 0;
let isDragged = false;

//Events for touch and mouse
let events = {
  mouse: {
    down: "mousedown",
    move: "mousemove",
    up: "mouseup",
  },
  touch: {
    down: "touchstart",
    move: "touchmove",
    up: "touchend",
  },
};

let deviceType = "";

//Detech touch device
const isTouchDevice = () => {
  try {
    //We try to create TouchEvent. It would fail for desktops and throw error.
    document.createEvent("TouchEvent");
    deviceType = "touch";
    return true;
  } catch (e) {
    deviceType = "mouse";
    return false;
  }
};

//Get left and top of canvas
let rectLeft = canvas.getBoundingClientRect().left;
let rectTop = canvas.getBoundingClientRect().top;

//Exact x and y position of mouse/touch
const getXY = (e) => {
  mouseX = (!isTouchDevice() ? e.pageX : e.touches[0].pageX) - rectLeft;
  mouseY = (!isTouchDevice() ? e.pageY : e.touches[0].pageY) - rectTop;
};

isTouchDevice();
//Start Scratch
canvas.addEventListener(events[deviceType].down, (event) => {
  isDragged = true;
  //Get x and y position
  getXY(event);
  scratch(mouseX, mouseY);
});

//mousemove/touchmove
canvas.addEventListener(events[deviceType].move, (event) => {
  if (!isTouchDevice()) {
    event.preventDefault();
  }
  if (isDragged) {
    getXY(event);
    scratch(mouseX, mouseY);
  }
});

//stop drawing
canvas.addEventListener(events[deviceType].up, () => {
  isDragged = false;
});

//If mouse leaves the square
canvas.addEventListener("mouseleave", () => {
  isDragged = false;
});

const scratch = (x, y) => {
  //destination-out draws new shapes behind the existing canvas content
  context.globalCompositeOperation = "destination-out";
  context.beginPath();
  //arc makes circle - x,y,radius,start angle,end angle
  context.arc(x, y, 12, 0, 2 * Math.PI);
  context.fill();
};

window.onload = init();

📁 Download Source Code : 
https://www.codingartistweb.com

#html #css #js #javascript  

Brielle  Maggio

Brielle Maggio

1626657482

Learn Angular From Scratch - Build SPA/Website with Angular 9 and Bootstrap - Part 1

Part 1 - Creating Angular 9 website using Angular CLI - Angular Single page application

Download NodeJS
https://nodejs.org/en/download/

Install Angular CLI
https://cli.angular.io/

Create Angular project from scratch using Angular CLI
ng new ProjectName

Spin up the application in the browser
ng serve -o

#angular #bootstrap #angular 9 #scratch #scratch

Kabanda  Nat

Kabanda Nat

1624633200

Using An Existing Blogging Platform vs Building A Blog From Scratch

Each option has its benefits and drawbacks. The purpose of this article is to answer this question and clarify it! Also, it’s important to note that everyone has different needs. So there is not a universal answer.
What matters most
Before going further, let’s see the most important things one should look for when opening a blog. They are as follows:

  • Having a personal domain - Having your domain is essential for two reasons. First of all, your blog looks more professional. Secondly, all the SEO benefits go to YOU. Hashnode is the only blogging platform that allows you to use your domain and for free. If you decide to move away, you retain all the SEO benefits, unlike other blogging platforms.

#scratch #existing blogging platform #a blog from scratch

Understanding DBSCAN Algorithm and Implementation from Scratch

What is DBSCAN
DBSCAN(Density-Based Spatial Clustering of Applications with Noise) is a commonly used unsupervised clustering algorithm proposed in 1996. Unlike the most well known K-mean, DBSCAN does not need to specify the number of clusters. It can automatically detect the number of clusters based on your input data and parameters. More importantly, DBSCAN can find arbitrary shape clusters that k-means are not able to find. For example, a cluster surrounded by a different cluster.
Also, DBSCAN can handle noise and outliers. All the outliers will be identified and marked without been classified into any cluster. Therefore, DBSCAN can also be used for Anomaly Detection (Outlier Detection)
Before we take a look at the preusdecode, we need to first understand some basic concepts and terms. Eps, Minpits, Directly density-reachable, density-reachable, density-connected, core point and border point
First of all, there are two parameters we need to set for DBSCAN, Eps, and MinPts.

#data-mining #outlier-detection #python #clustering #dbscan