Vern  Greenholt

Vern Greenholt

1598049780

Eigen Theory From Scratch

In machine learning and data science, we often use the Eigen theory. It is widely used in the data dimensionality reduction technique; PCA. Also, even Google’s search algorithm ‘PageRank’ is based on this concept. Once you read this article you will be able to understand what exactly the Eigen theory is and how it can be used to solve problems.


In linear algebra, we can represent an object with combinations of multiple vectors. When we apply any kind of transformation on an object, we shall observe its impact on all the vectors.

When a transformation is applied, some vectors end up staying in the same position. These vectors are called eigenvectors. The factor by which eigenvectors are scaled after the transformation is called eigenvalues.

Now let us understand this with an example of a square shown below(figure1). Although the square is made up of millions of vectors, for our ease of understanding we consider only 3 vectors r, s, v. Vector r, s, v are on plane1, plane3, plane2 respectively.

Image for post

Figure 1

Image for post

Image for post

Transformation Matrix A

We apply transformation and let A be our transformation matrix.

Let’s have a very quick overview of what exactly the transformation matrix is.

When vector(s) are represented by a matrix, it must be read column-wise to identify vector(s).

Now, let’s see what exactly our transformation matrix A is doing to vector s. The x coordinate of vector s is 1 and the **y-**coordinate is also 1. (Make sure you are reading matrix A column-wise!)

When transformation matrix A is applied, x coordinate of s will move 1 unit in the x-direction and 0 unit in y-direction whereas y cordinate of s will move 0 unit in the x-direction and 2 unit in the y-direction.

Image for post

Transformation of vector s

So, we can see that after transformation coordinates of **s**are (1, 2).

The same transformation we apply to all the vector r, s, and v. Once the transformation is applied, our new coordinates are (0, 2), (1, 2), and (1, 0) respectively.

#data-science #machine-learning #mathematics #linear-algebra #eigenvectors #deep learning

What is GEEK

Buddha Community

Eigen Theory From Scratch
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

Vern  Greenholt

Vern Greenholt

1598049780

Eigen Theory From Scratch

In machine learning and data science, we often use the Eigen theory. It is widely used in the data dimensionality reduction technique; PCA. Also, even Google’s search algorithm ‘PageRank’ is based on this concept. Once you read this article you will be able to understand what exactly the Eigen theory is and how it can be used to solve problems.


In linear algebra, we can represent an object with combinations of multiple vectors. When we apply any kind of transformation on an object, we shall observe its impact on all the vectors.

When a transformation is applied, some vectors end up staying in the same position. These vectors are called eigenvectors. The factor by which eigenvectors are scaled after the transformation is called eigenvalues.

Now let us understand this with an example of a square shown below(figure1). Although the square is made up of millions of vectors, for our ease of understanding we consider only 3 vectors r, s, v. Vector r, s, v are on plane1, plane3, plane2 respectively.

Image for post

Figure 1

Image for post

Image for post

Transformation Matrix A

We apply transformation and let A be our transformation matrix.

Let’s have a very quick overview of what exactly the transformation matrix is.

When vector(s) are represented by a matrix, it must be read column-wise to identify vector(s).

Now, let’s see what exactly our transformation matrix A is doing to vector s. The x coordinate of vector s is 1 and the **y-**coordinate is also 1. (Make sure you are reading matrix A column-wise!)

When transformation matrix A is applied, x coordinate of s will move 1 unit in the x-direction and 0 unit in y-direction whereas y cordinate of s will move 0 unit in the x-direction and 2 unit in the y-direction.

Image for post

Transformation of vector s

So, we can see that after transformation coordinates of **s**are (1, 2).

The same transformation we apply to all the vector r, s, and v. Once the transformation is applied, our new coordinates are (0, 2), (1, 2), and (1, 0) respectively.

#data-science #machine-learning #mathematics #linear-algebra #eigenvectors #deep learning

rick william

1622088103

MAGENTO 2 SCRATCH COUPON CARD

Customers can scratch coupon card with the movement to win tempting discounts and get using promocode. Magento 2 Scratch coupon card extension helps to increase website use usability by engaged customers to the store. This extension helps to increase site traffic, website functionality.

#magento 2 scratch coupon card #scratch coupon card #magento 2