React Hooks are functions that allow us to work with state and lifecycle features in React function components. Previously this was only possible when using classes but Hooks give us an alternative way to use these important class features outside of classes.
The State Hook (useState) is the most commonly used Hook for building React components — it lets us add state to our function components without having to convert them to classes.
class MyClass extends React.Component {
constructor(props) {
super(props);
this.state = {
name: 'Medium'
};
}
import React, { useState } from 'react';function MyFunction() {
const [name, setName] = useState('Medium')…
Disclaimer: If you haven’t already read the first three parts, click here for parts one and two and click here for part three.
A cryptographic hash function is a special type of function that takes an input string of a given length and converts it into an alphanumeric string of fixed length. In the case of Bitcoin, a “Message” is inputted, and a hash function, known as SHA-256 (Secure Hashing Algorithm 256), gives an output known as a “Hash” or “Message Digest”. This means that however long the string of data (limit of 2²⁵⁶- 1 bits), the output will always be 256-bits in length. The process of hashing is not a method of encryption as it is only a one- way process and therefore cannot be reversed (decrypted). By running multiple outputs through SHA-256, we can see how different the output becomes, even when only changing a single character in the message. We can also see that despite having an input of longer length, the output length is the exact same (table 5.1). …
Disclaimer: If you haven’t already read the first two parts, click here to read.
Bitcoin uses public-key cryptography to generate a pair of keys; the public key and the private key. The private key is used to digitally sign transactions as a method of proving a transaction has come from the rightful owner. This should be kept private to prevent other users from creating transactions and signing them with your signature. Private keys can be created from Bitcoin software that generates a random number of 256-bit length, displayed in hexadecimal format (1 hex digit = 4 bits). For example:
Private Key (k) =…
Cryptocurrencies are digital-based currencies that use cryptographic techniques to regulate the generation of currency and verify the transfer of funds; without the need for a trusted third party. The currencies are based on blockchain technology; a secure public ledger that can be programmed to record digital information. The first and most well-known cryptocurrency, known as Bitcoin was proposed in 2008 by an anonymous developer(s) Satoshi Nakamoto in the whitepaper ‘Bitcoin: A Peer-to-peer Electronic Cash System’.
Bitcoin consists of a network of computers connected through the internet called nodes. Anyone with a computer and internet connection can join the network by running a Bitcoin software. Every node on the network contains an identical copy of a distributed ledger; a database containing all previous transaction history on the network. This is also known as the blockchain. As anyone can join the network, nodes are unable to fully trust each other and to combat this, all transaction history is made public, relying on all nodes to agree on one single truth. This, however, does not compromise the user’s anonymity as the database does not contain any personal information, only the user’s public Bitcoin address and transaction history. …
Nobody likes a model with lots of errors. But how can we decide which models have a higher error than others? If our data is skewed, using a simple accuracy measure can give us misleading results. For example, consider a car classifier that predicts that a car is a Mercedes 100% of the time. Now, imagine you showed your classifier 10,000 images in which 9500 of them were Mercedes (y=1) and the other 500 were Audis (y=0). Our model would give us a 95% accuracy, good right? Well not quite, if we were to then test this model with 10,000 new images in which only 1000 were Mercedes and the other 9000 were Audis, we would only get an accuracy of 10%. …
When building machine learning models, it is important we take great care in ensuring our models don’t under/overfit our training data. We cannot say that we have a ‘good’ model until it is able to not only give us a low error on our training data but also give us a low error on new, relevant data (it generalizes well).
About