The Central Limit Theorem, a hands-on introduction
The Glowing Python
by JustGlowing
3y ago
The central limit theorem can be informally summarized in few words: The sum of x1, x2, ... xn samples from the same distribution is normally distributed, provided that n is big enough and that the distribution has a finite variance. to show this in an experimental way, let's define a function that sums n samples from the same distrubution for 100000 times: import numpy as npimport scipy.stats as spsimport matplotlib.pyplot as pltdef sum_random_variables(*kwarg, sp_distribution, n): # returns the sum of n random samples # drawn from sp_distribution v = [sp_distribution.rvs(*kwarg, si ..read more
Visit website
A Simple model that earned a Silver medal in predicting the results of the NCAAW tournament
The Glowing Python
by JustGlowing
3y ago
This year I decided to join the March Machine Learning Mania 2021 - NCAAW challenge on Kaggle. It proposes to predict the outcome of each game into the basketball NCAAW tournament, which is a tournament for women at college level. Participants can assign a probability to each outcome and they're ranked on the leaderboard according to the accuracy of their prediction. One of the most attractive elements of the challenge is that the leaderboard is updated after each game throughout the tournament. Since I have limited knowledge of basketball I decided to use a minimalistic model: It uses three ..read more
Visit website
Visualize the Dictionary of Obscure Words with T-SNE
The Glowing Python
by JustGlowing
3y ago
I recently published on a wrapper around The Dictionary of Obscure Words (originally from this website http://phrontistery.info) for Python and in this post we'll see how to create a visualization to highlight few entries from the dictionary using the dimensionality reduction technique called T-SNE. The dictionary is available on github at this address https://github.com/JustGlowing/obscure_words and can be installed as follows: pip install git+https://github.com/JustGlowing/obscure_words We can now import the dictionary and create a vectorial representation of each word: import matplotlib ..read more
Visit website
Solving the Travelling Salesman Problem with MiniSom
The Glowing Python
by JustGlowing
3y ago
Have you ever heard of the Travelling Salesman Problem? I'm pretty sure you do, but let's refresh our mind looking at its formulation: "Given a list of points and the distances between each pair of points, what is the shortest possible path that visits each point and returns to the starting point?". What makes this problem so famous and so studied is the fact that it has no "quick" solution as the complexity of calculating the best path increases adding more points. And the complexity increases so fast that, even with modern hardware, it can be impossible to compute an exact solution in a reas ..read more
Visit website
Neural Networks Regularization made easy with sklearn and matplotlib
The Glowing Python
by JustGlowing
3y ago
Using regularization has many benefits, the most common are reduction of overfitting and solving multicollinearity issues. All of this is covered very well in literature, especially in (Hastie et all). Howerver, wihout touching too many details we can have a very straigthforward interpretation of regularization. Regularization is a way to constrain a model in order to learn less from the data. In this post we will experimentally show what are the effects of regularization on a Neural Network (Multilayer Perceptron) validating this interpretation. Let's define a goal for our Neural Network. We ..read more
Visit website
Tornado plots with matplotlib
The Glowing Python
by JustGlowing
3y ago
Lately there's a bit of attention about charts where the values of a time series are plotted against the change point by point. This thanks to this rather colorful and cluttered Tornado plot. In this post we will see how to make one of those charts with our favorite plotting library, matplotlib, and we'll also try to understand how to read them. Let's start loading the records of the concentration of CO2 in the atmosphere and aggregate the values on month level. After that we can plot straight away the value of the concentration against the change compared to the previous month: import panda ..read more
Visit website
Recoloring NoIR images on the Raspberry Pi with OpenCV
The Glowing Python
by JustGlowing
3y ago
Not too long ago I've been gifted a Raspberry Pi camera, after taking some pictures I realized that it produced very weird colors and I discovered that it was a NoIR camera! It means that it has no infrared filter and that it can take pictures in the darkness using an infrared LED. Since I never found an application that required taking pictures without proper lighting I started wondering if I could recolor the images processing them with some Python magic. While it's clear that the problem is ill posed, once the camera takes a picture sensing the wrong colors, the original colors are lost. It ..read more
Visit website
What makes a word beautiful?
The Glowing Python
by JustGlowing
3y ago
What makes a word beautiful? Answering this question is not easy because of the inherent complexity and ambiguity in defining what it means to be beautiful. Let's tackle the question with a quantitative approach introducing the Aesthetic Potential, a metric that aims to quantify the beaty of a word w as follows: where w+ is a word labelled as beautifu, w- as ugly and the function s is a similarity function between two words. In a nutshell, AP is the difference of the average similarity to beautiful words minus the average similarity to ugly words. This metric is positive for beautiful words ..read more
Visit website
Ridgeline plots in pure matplotlib
The Glowing Python
by JustGlowing
3y ago
A Ridgeline plot (also called Joyplot) allows us to compare several statistical distributions. In this plot each distribution is shown with a density plot, and all the distributions are aligned to the same horizontal axis and, sometimes, presented with a slight overlap. There are many options to make a Ridgeline plot in Python (joypy being one of them) but I decided to make my own function using matplotlib to have full flexibility and minimal dependencies: from scipy.stats.kde import gaussian_kdefrom scipy.stats import normimport numpy as npimport matplotlib.pyplot as pltdef ridgeline(data ..read more
Visit website
Organizing movie covers with Neural Networks
The Glowing Python
by JustGlowing
3y ago
In this post we will see how to organize a set of movie covers by similarity on a 2D grid using a particular type of Neural Network called Self Organizing Map (SOM). First, let's load the movie covers of the top 100 movies according to IMDB (the files can be downloaded here) and convert the images in samples that we can use to feed the Neural Network: import numpy as npimport imageiofrom glob import globfrom sklearn.preprocessing import StandardScaler# covers of the top 100 movies on www.imdb.com/chart/top # (the 13th of August 2019)# images downloaded from www.themoviedb.orgdata = []all_cove ..read more
Visit website

Follow The Glowing Python on FeedSpot

Continue with Google
Continue with Apple
OR