import pandas as pd
from sklearn.linear_model import LinearRegression
# Prepare the data
data = {
'total_plays': [408000, 1110000],
'monthly_playtime': [62, 68],
'total_new': [1418, 17000],
'%_new_players': [0.002, 0.015],
'average_retention': [11/12, 25],
'payout': [16500, 83000]
}
df = pd.DataFrame(data)
# Features and target
X = df[['total_plays', 'monthly_playtime', 'total_new', '%_new_players', 'average_retention']]
y = df['payout']
# Train the model
model = LinearRegression()
model.fit(X, y)
# Function to estimate payout
def estimate_payout(total_plays, monthly_playtime, total_new, perc_new_players, average_retention):
plays_playtime = (total_plays / 1000) * monthly_playtime
input_data = pd.DataFrame({
'total_plays': [total_plays],
'monthly_playtime': [monthly_playtime],
'total_new': [total_new],
'%_new_players': [perc_new_players],
'average_retention': [average_retention]
})
estimated_payout = model.predict(input_data)
return estimated_payout[0]
# Console App
if __name__ == "__main__":
print("Payout Estimator")
# User input
total_plays = int(input("Enter the total number of plays: "))
monthly_playtime = float(input("Enter the monthly playtime in minutes: "))
total_new = int(input("Enter the total number of new players: "))
perc_new_players = float(input("Enter the percentage of new players (e.g., 0.002): "))
average_retention = float(input("Enter the average retention (e.g., 11/12): "))
# Calculate the payout
estimated_payout = estimate_payout(total_plays, monthly_playtime, total_new, perc_new_players, average_retention)
# Display the result
print(f"\nEstimated payout: ${estimated_payout:.2f}") Click Run or press shift + ENTER to run code