Created
September 1, 2023 09:20
-
-
Save Lulzx/331dda51ce372d8c3a7da6ea7a1377b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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