Jigme Tenzin - Fab Futures - Data Science
Home About

Example 1: Quadratic dataset¶

In [4]:
import matplotlib.pyplot as plt

# Example: Quadratic dataset
x = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]
y = [66, 41, 22, 9, 2, 1, 0, 5, 16, 33, 56]

plt.plot(x, y, marker='o')
plt.xlabel("x")
plt.ylabel("y")
plt.title("Quadratic Function Plot")
plt.grid(True)
plt.show()
No description has been provided for this image

Example 2: Polynomial Fitting With Noise¶

What the data represents¶

image.png

In [6]:
import matplotlib.pyplot as plt

x = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]
y = [-113, -50, -19, -2, 5, 2, -1, 6, 23, 50, 97]

plt.plot(x, y, marker='o')
plt.xlabel("x")
plt.ylabel("y")
plt.title("Cubic Function: y = x³ - 4x + 2")
plt.grid(True)
plt.show()
No description has been provided for this image

This graph demonstrates how we can use a polynomial to model real-world data that contains noise (random variation).¶