Data Science

Logistic Regression in Python Scikit-Learn

Logistic regression is a popular algorithm for classification problems (despite its name indicating that it is a “regression” algorithm). It belongs to one of the most important algorithms in the machine learning space. Linear Regression Background Let’s review linear regression. Given the training data, we compute a line that fits this training data so that …

Logistic Regression in Python Scikit-Learn Read More »

How to Convert a Boolean Array to an Integer Array in Python?

Problem Formulation Given a NumPy array consisting of Boolean values. How to convert it to an integer array? Convert each True value to integer 1, and Convet each False value to integer 0. Here’s an example Boolean array: What you want is the following integer array: Let’s examine some methods to accomplish this easily. Method …

How to Convert a Boolean Array to an Integer Array in Python? Read More »

Division in Python

The double-frontslash // operator performs integer division and the single-frontslash / operator performs float division. An example for integer division is 40//11 = 3. An example for float division is 40/11 = 3.6363636363636362. A crucial lesson you need to master as a programmer is “division in Python”. What does it mean to divide in Python? …

Division in Python Read More »

[Tutorial] K-Means Clustering with SKLearn in One Line

If there is one clustering algorithm you need to know – whether you are a computer scientist, data scientist, or machine learning expert – it’s the K-Means algorithm. In this tutorial drawn from my book Python One-Liners, you’ll learn the general idea and when and how to use it in a single line of Python …

[Tutorial] K-Means Clustering with SKLearn in One Line Read More »

Smoothing Your Data with the Savitzky-Golay Filter and Python

This article deals with signal processing. More precisely, it shows how to smooth a data set that presents some fluctuations, in order to obtain a resulting signal that is more understandable and easier to be analyzed. In order to smooth a data set, we need to use a filter, i.e. a mathematical procedure that allows …

Smoothing Your Data with the Savitzky-Golay Filter and Python Read More »

Sklearn fit() vs transform() vs fit_transform() – What’s the Difference?

Scikit-learn has a library of transformers to preprocess a data set. These transformers clean, generate, reduce or expand the feature representation of the data set. These transformers provide the fit(), transform() and fit_transform() methods. The fit() method identifies and learns the model parameters from a training data set. For example, standard deviation and mean for …

Sklearn fit() vs transform() vs fit_transform() – What’s the Difference? Read More »

Are Energy Costs and CapEx Invested in Bitcoin Worth It?

Bitcoin capital expenditure and energy overhead are often criticized to be unsustainably high. But are they worth it in relation to the value provided by the Bitcoin network? TLDR; Capex and energy costs are estimated using the USD value of the transaction fees paid by the Bitcoin traders. The value of the Bitcoin monetary system …

Are Energy Costs and CapEx Invested in Bitcoin Worth It? Read More »

How to Get All Transactions for a BTC Address in Python?

Problem Formulation Given a single Bitcoin address in the form of a stream of characters such as the address of the first “Genesis” block ever created on the Bitcoin blockchain: 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX How to get all transactions for this BTC address in a Python script? Solution To get all transactions of a given Bitcoin address, import …

How to Get All Transactions for a BTC Address in Python? Read More »

How to Get Binance API Prices in Python at a Precise Time?

Problem Formulation Say, you want to get the current price of a cryptocurrency using Python’s inofficial binance API. How do you do this for a precise point in time? Step 1: Install Python Binance with pip If you haven’t already, install the Python Binance API using the pip package manager. Run pip install python-binance in …

How to Get Binance API Prices in Python at a Precise Time? Read More »