import numpy as np
import matplotlib.pyplot as plt
def plot_quadratic_coefficients(coefficients):
"""
Plots y = ax^2 + bx + c for each set of coefficients within specified x and y ranges.
Parameters:
- coefficients: dict, a dictionary of coefficient sets with 'a', 'b', and 'c' for each key.
"""
x_values = np.linspace(0, 25, 400) # Generate 400 points from 0 to 15 for smooth curves.
plt.figure(figsize=(10, 6))
for label, coef in coefficients.items():
a, b, c = coef['a'], coef['b'], coef['c']
y_values = a * x_values**2 + b * x_values + c
plt.plot(x_values, y_values, label=label)
plt.ylim(0, 1.5) # Set the y-axis range from 0 to 1.5.
plt.xlim(0, 25) # Set the x-axis range from 0 to 15 for clarity.
plt.xlabel('X Axis')
plt.ylabel('Y Axis')
plt.title('Quadratic Coefficients Graph')
plt.legend()
plt.grid(True)
plt.show()
coefficients = {
"clip_aesthetic": {"a": -0.01028806584362138, "b": 0.21913580246913555, "c": 0.08518518518518595},
"log_pixels": {"a": -0.0005806010928961671, "b": 0.024132513661202018, "c": 0.7775409836065581},
"twitter_aesthetic_v2": {"a": -0.003809523809523807, "b": 0.08952380952380948, "c": 0.6228571428571431},
"year_since_2000": {"a": 0.0012500000000000011, "b": -0.03000000000000003, "c": 1.1},
"transformed_views_per_react": {"a": 0.0031488978857400285, "b": -0.12474134053081526, "c": 2.0626180836707224},
"log_norm_pseudo_engagement_ratio": {"a": -0.00023088023088022288, "b": 0.03763347763347757, "c": 0.8}
}
plot_quadratic_coefficients(coefficients)
Created
March 28, 2024 18:26
-
-
Save trojblue/8c0b3fed28b19d07150a135ad5a1c9c9 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment