Python Collage and Contour

This set of Python programs is about creating a collage and then adding a contour to it. import numpy as np import matplotlib.pyplot as plt import matplotlib.image as im import random random.seed(123) l = [] a = list(range(1, 37)) random.shuffle(a) for i in a: if i == 35: continue image = im.imread(‘images/collagephoto{}.jpg’.format(i)) l.append(image) l1 = […]

Natural Language Processing with Dante

In this period, I’m studying natural language processing and its applications. One of my favourite tricks is generating text which reminds someone’s style. For example, here I will show an AI (trained for 100 minutes and just two epochs) that has learned to fake Dante’s Divine Comedy. import tensorflow as tffrom tensorflow import kerasimport numpy […]

An Old Birthday Gift

This is an old birthday gift for a special person. It was the first time I tried to plot something using python, and I wasn’t very familiar with matplotlib, so I used the turtle library. import turtleimport timedef auguri(): colors = [‘blue’, ‘red’, ‘green’, ‘yellow’, ‘orange’, ‘purple’] turtle.pensize(5) turtle.bgcolor(‘black’) turtle.speed(1000) for x in range(360): turtle.pencolor(colors[x […]

Plotting 3D Lines

In Python as you know there’s the option of plotting 3D graphs, so why not fully exploiting such possibilities? In this example I will show a sort of an irregular spiral figure. import matplotlib as mplimport numpy as npimport matplotlib.pyplot as pltmpl.rcParams[‘legend.fontsize’] = 10fig = plt.figure()ax = fig.gca(projection=’3d’)theta = np.linspace(-4 * np.pi, 4 * np.pi, […]

Multiple Days Stock Predictor

The last stock predictor could only predict the following day based on the last n days. Now it can predict any number of days ahead. Since when you try to predict more days ahead some may overlap, this plot is made by taking the mean of all the overlapping days. Hence, it’s not very accurate, […]

Plotting Epicycloids

An epicycloid is the figure that a fixed point of a circle draws when the circle rotates on the circumference of another one. How to plot such things in Python? There is a trick: such figures depend on the ratio of the still circle’s and the rotating circle’s radius. Let’s say we have an integer […]

AI Artist

A nice programming challenge is writing a program that modifies an image to give using the style from another image, which in my case is Van Gogh’s Starry Night. Let’s take a look at the input image. A take of the houses of parliament at night. Now let’s see the output image after 7000 iterations. […]

Scroll to top