Posts

Classifier Boosting with Python

Image
Introduction Remember we've talked about random forest and how it was used to improve the performance of a single Decision Tree classifier . The idea of fitting a number of decision tree classifiers on various sub-samples of the dataset and using averaging to improve the predictive accuracy can be used to other algorithms as well and it's called boosting. There are several boosting techniques, which can be used to improve our algorithm, we'll cover the most used ones: AdaBoost and Bagging boost. AdaBoost An AdaBoost classifier begins by fitting a classifier on the original dataset and then fits additional copies of the classifier on the same dataset, but where the weights of incorrectly classified instances are adjusted such that subsequent classifiers focus more on difficult cases. Bagging boost A Bagging classifier fits base classifiers each on random subsets of the original dataset and then aggregate their individual predictions to form a final prediction. I...

K-means clustering with Python

Image
Introduction K-means is one of the simplest unsupervised learning algorithms that solve the well known clustering problem. The procedure follows a simple and easy way to classify a given data set through a certain K number of clusters. The main idea is to define K centroids, one for each cluster. The next step is to take each point belonging to a given data set and associate it to the nearest centroid. At this point we need to re-calculate K new centroids of the clusters resulting from the previous step. After we have these K new centroids, a new binding has to be done between the same data set points and the nearest new centroid. As a result of this loop we may notice that the K centroids change their location step by step until no more changes are done. Implementation Scikit-learn provides with full implementation of K-means algorithm though KMeans class. Let's have a look at several interesting situations, which might occur during data clustering: import numpy ...

What Happens After We’ve Mined all 21M Bitcoin?

Image
There can never be more than 21 million bitcoin. From an investment standpoint, this is a good thing: Bitcoin can have long-term value because it’s finite. Additionally, we won’t have mined all the bitcoin until 2140. But the ever-decreasing availability of new bitcoins is already affecting the market and will have serious consequences way before 2140. In fact, we’ll have mined close to 100% of bitcoin by 2040. Though bitcoin mining will still be theoretically possible for another 100 years, bitcoin’s price and the nature of its transactions will never be the same. Here’s what you should know about the impending cap on one of the world’s most valuable currencies. We’ll Have Mined all 21M Bitcoin by 2140 2140 is the theoretical year we will create the last bitcoin block. Thereafter, it will be impossible to make even a fraction of a new bitcoin—no matter the demand. Per the law of supply and demand, bitcoin’s value could increase significantly once its supply becomes fixed. What pe...

Naïve Bayes with Python

Image
Introduction The Naive Bayes algorithm is based on conditional probabilities. It uses Bayes' Theorem , a formula that calculates a probability by counting the frequency of values and combinations of values in the historical data. Bayes' Theorem finds the probability of an event occurring given the probability of another event that has already occurred. If B represents the dependent event and A represents the prior event, Bayes' theorem can be stated as follows. To calculate the probability of B given A , the algorithm counts the number of cases where A and B occur together and divides it by the number of cases where A occurs alone. Implementation Scikit-learn provides implementation of Naïve Bayes algorithm of 3 flavors: MultinomialNB implementing the naive Bayes algorithm for multinomially distributed data ; GaussianNB implementing the Gaussian Naive Bayes algorithm for classification; and BernoulliNB implements the naive Bayes training and classificat...

Python for Data Scientists - Rodeo

Image
Introduction I love Python, I really do and that goes for IPython as well - it's a great tool and simplifies the work by a lot. But.. there is always a but, isn't it? RStudio is so much better and until recently we, the Python data enthusiasts, could only nervously look at RStudio while working on somewhat beloved, somewhat limped brother IPython. Well, no more. Let me introduce you Rodeo The IDE is free and super easy to use, it's very similar to RStudio and after you watch the introduction video above, you'll be ready to go.

Random Forest with Python

Image
Introduction In the article about decision tree we've talked about it's drawbacks of being sensitive to small variations or noise in the data. Today we'll see how to deal with them by introducing a random forest. It belongs to a larger class of machine learning algorithms called ensemble methods , which use multiple learning algorithms to obtain better predictive performance than could be obtained from any of the constituent learning algorithms. So which models does random forest aggregate? You might already know the answer - the decision trees. It fits a number of decision tree classifiers on various sub-samples of the dataset and use averaging to improve the predictive accuracy and control over-fitting. Implementation Scikit-learn provides us with two classes RandomForestClassifier and RandomForestRegressor for classification and regression problems respectively. Let's use the code from the previous example and see how the result will different, using rand...

Bitcoin (BTC) vs Bitcoin Cash (BCH)

Image
Bitcoin (BTC) vs Bitcoin Cash (BCH), two coins that came from the same blockchain but offer distinct solutions. In 2017, Bitcoin experienced a “hard fork,” meaning that a group of developers decided to take the currency in an entirely new direction. What is Bitcoin and what is Bitcoin Cash? Do you know the difference between the two? Bitcoin (BTC) vs Bitcoin Cash (BCH) are far from the same thing. Bitcoin vs Bitcoin Cash: Two Answers to One Problem Before 2017, there was only one kind of Bitcoin (BTC), and it was facing a big problem: could it scale enough to be used as actual currency? The issue of Bitcoin’s scalability, which gave us Bitcoin vs Bitcoin Cash, goes back to its structure. For a Bitcoin exchange to occur, i.e., for it to be added to the blockchain, another party has to verify it. The verification process is called ‘consensus.’ When asking, “What is blockchain,” the most important thing to remember is that blockchain is decentralized. Transactions that occur on it ...