Posts

What does “permissionless” mean?

Image
At the heart of the much-hyped “blockchain” technology lies not a blockchain, surprisingly, but a consensus mechanism. A consensus mechanism does what it says; it helps everyone on the network agree, or reach consensus, on a shared computation and records of that computation. In the Bitcoin network, for example, the shared computation is the continual creation of a list of digital currency transactions made between users. In Ethereum it’s the state changes of a globally-accessible virtual machine. A fundamental question in the design of any consensus mechanism is who can participate and how do they participate in order to reach consensus over some shared computation. For many years it was assumed that useful consensus mechanisms could only be developed if the participant computers were identified through channels outside of the decentralized computing system itself. In other words, it had been assumed that useful consensus mechanisms could only be designed as closed or permissioned ...

Hyperparameter optimization with Python

Image
Introduction In the previous articles we introduced several linear techniques, where as you have probably noticed, we provided the algorithms with several parameters. The dependence of machine learning algorithm upon learning parameters is a common case though and one has to check the performance of various parameters to achieve the best results. The task of course is no trifle and is called hyperparameter optimization or model selection. It is the problem of choosing a set of hyperparameters for a learning algorithm, usually with the goal of optimizing a measure of the algorithm's performance on an independent data set. Implementation Grid Search The traditional way of performing hyperparameter optimization is a grid search, or a parameter sweep, which is simply an exhaustive searching through a manually specified subset of the hyperparameter space of a learning algorithm. Scikit-learn provides us with a class GridSearchCV implementing the technique. Let's try to ...

JavaScript Prototype Design Pattern

Image
Let's continue our discussion about JavaScript Design Patterns. We've already talked about Factory and Builder pattern . Today I'll overview the Prototype pattern . The Prototype pattern creates new objects by cloning one of a few stored prototypes. The Prototype pattern has two advantages: it speeds up the instantiation of very large, dynamically loaded classes (when copying objects is faster), and it keeps a record of identifiable parts of a large data structure that can be copied without knowing the subclass from which they were created. Have a look at the following illustration, depicting the pattern: While there is a lot of information about cloning on the internet and even some suggest using it in the prototype design, the external approach is utterly incorrect. However since we are Object Oriented programmers, we would like to clone both public and private members. None of the external approaches will give you such result. On the other hand, if you will...

Gradient Descent with Python

Image
Introduction In the previous two articles, we've talked about linear and logistic regression, covering by it most linear models. And that would be it, if only these models could process data with numerous features, that is x1, x2... xn-1, xn. Let's us see how our classification model deals with Olivetti faces classification dataset: from sklearn import datasets, metrics, linear_model, cross_validation import matplotlib.pyplot as plt import time #Load the digits dataset faces = datasets.fetch_olivetti_faces() start = time.time() X = faces.data Y = faces.target x_train, x_test, y_train, y_test = cross_validation.train_test_split(X, Y) # Create a classifier: a support vector classifier model = linear_model.LogisticRegression(C=10000) # We learn the faces of train set model.fit(x_train, y_train) # Now predict the person on test set expected = y_test predicted = model.predict(x_test) end = time.time() print("%.2f seconds" % (end - start)) # 8.85 seconds ...

JavaScript Builder Design Pattern

Image
Today I would like to continue the series about design patterns we started with Factory Patterns in JavaScript and talk about the Builder pattern . For some reason it's being left behind in any design pattern usage in JavaScript. Maybe it was correct in the front end domain, but surely not in Node.js. Builder pattern separates the construction of a complex object from its representation so that the same construction process can create different representations. The Builder pattern is based on Directors and Builders . Any number of Builder classes can conform to an IBuilder interface, and they can be called by a director to produce a product according to specification. The builders supply parts that the Product objects accumulate until the director is finished with the job. I'll be using the example from the factory pattern article to emphasize the differences between the patterns. Consider the class diagram for the Builder pattern: And the implementation: funct...

How long does it take for a Bitcoin transaction to be confirmed?

Image
Frequently in popular descriptions of Bitcoin and in the user interfaces of wallet software, a distinction is made between “confirmed” and “unconfirmed” transactions. What is the difference? At a high level, a transaction is only confirmed when it is permanently included in the Bitcoin blockchain. The blockchain is a ledger of all transactions in the history of Bitcoin. It is append-only, meaning new data can be added to the end of the ledger, but data can never be removed once included. This ledger is necessary to prevent double-spending, which is a key technical challenge in designing any cryptocurrency - of which we'll talk more in the following articles. How Bitcoins are Transferred Recall that if Alice “owns” some quantity of bitcoins, this really means she knows one or more cryptographic keys which have been designated as the controller of those coins in a transaction on the ledger which transferred the coins to Alice. In order to transfer the coins to another entity, ...

How Anonymous is Bitcoin?

Bitcoin is often described as a way to transact anonymously. But just how anonymous is it? Anonymity vs. privacy First off, it is useful to draw a basic distinction between anonymity and privacy in the context of financial transactions. We will call a transaction “anonymous” if no one knows who you are. We will call a transaction “private” if what you purchased, and for what amount, are unknown. Certain financial transactions are private but not anonymous; for example, the donor wall at the local art museum, which identifies the names of donors but not the amounts donated. Bitcoin, by contrast, is anonymous but not private: identities are nowhere recorded in the bitcoin protocol itself, but every transaction performed with bitcoin is visible on the distributed electronic public ledger known as the blockchain. The anonymity provided by bitcoin is at once a point of attraction and a challenge for financial regulation. As the pace of adoption of the currency grows and as it comes u...