Skip to content

Instantly share code, notes, and snippets.

@Lulzx
Created September 1, 2023 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lulzx/331dda51ce372d8c3a7da6ea7a1377b3 to your computer and use it in GitHub Desktop.
Save Lulzx/331dda51ce372d8c3a7da6ea7a1377b3 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
def calc_score(discount_percentage, average_rating):
return 1 / (1 + np.exp(-((2 * discount_percentage / 100) + (average_rating / 5) - np.maximum(0, 4 - average_rating))))
discount_percentages = np.linspace(0, 50, 100)
average_ratings = np.linspace(0, 5, 100)
X, Y = np.meshgrid(average_ratings, discount_percentages)
Z = calc_score(Y, X)
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, Z, cmap='viridis')
ax.set_xlabel('Average Rating')
ax.set_ylabel('Discount Percentage')
ax.set_zlabel('Score')
ax.set_title('Score as a function of Average Rating and Discount Percentage')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment