[Fixed] Unknown label type: ‘continuous’ in sklearn LogisticRegression

Summary: Use SKLearn’s LogisticRegression Model for classification problems only. The Y variable is a category (e.g., binary [0,1]), not continuous (e.g. float numbers 3.4, 7.9). If the Y variable is non-categorical (i.e., continuous), the potential fixes are as follows. Re-examine the data. Try to encode the continuous Y variable into categories (e.g., use SKLearn’s LabelEncoder preprocessor). Re-examine … 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 … Read more

How To Plot SKLearn Confusion Matrix With Labels?

Summary: The best way to plot a Confusion Matrix with labels, is to use the ConfusionMatrixDisplay object from the sklearn.metrics module. Another simple and elegant way is to use the seaborn.heatmap() function. Note: All the solutions provided below have been verified using Python 3.9.0b5. Problem Formulation Imagine the following lists of Actual and Predicted values … Read more

How To Remove All Non-Alphabet Characters From A String?

? Summary: This blog explores the steps to remove all non-alphabet characters from a given string. The ‘re’ module in Python provides regular expression operations, to process text. One uses these operations to manipulate text in strings. The compile() method in conjunction with the sub() method can remove all non-alphabet characters from a given string. Note: … Read more

How To Sort A Set Of Values?

Summary: This blog explores the steps to sort elements of a Set. Python offers the built-in sorted() function to sort elements in container objects such as a set or a list. For example: sorted({1, 5, 2}) sorts the elements in the set and returns the sorted list [1, 2, 5]. Note: All the solutions provided … Read more

How To Extract All Emojis From Text in Python?

Summary: This blog explains the various ways one can extract commonly used Emojis embedded within text. Note: All the solutions provided below have been verified using Python 3.9.0b5. Problem Formulation One has a list with normal text words and emojis, all mixed together, as shown below.  How does one extract only the emojis, into a … Read more

What’s New in Python 3.9

Each year, volunteers from all over the world, work on improvements to the Python Language. The official Python 3.9 version was released on October 5, 2020. This version is an improvement made to Python 3.8. The official, detailed explanation of these improvements is available at the Python Website. This blog article attempts to explain these … Read more

How To Eliminate All The Whitespace From A String?

In this article, you’ll learn the ultimate answer to the following question: How To Eliminate All The Whitespace From A String—on Both Ends, and In-Between Words? Summary: Use the string methods join(), split(), strip(), rstrip(), lstrip() and or replace()—in specific combinations—to remove any whitespace in a given string. The simplest way to remove all whitespaces … Read more