I have just finished a project for my bootcamp. However, no matter how I do the profit calculation or bootstrapping, I continue to get a risk of loss of zero. I’m not sure how to fix this.
### Key Values for Profit Calculation
BUDGET = 100 * 10**6 # $100 million
REVENUE_PER_BARREL = 4.5 # $4.5 per barrel
WELLS_SELECTED = 200 # Number of wells selected for development
COST_PER_WELL = BUDGET / WELLS_SELECTED # Cost per well
sufficient_volume = COST_PER_WELL / REVENUE_PER_BARREL
### Profit Calculation Function
def calculate_profit(predictions, target, n_wells, revenue_per_barrel, cost_per_well):
selected_indices = predictions.sort_values(ascending=False).head(n_wells).index
selected_reserves = target.loc[selected_indices].sum()
revenue = selected_reserves * revenue_per_barrel * 1000
profit = revenue - (cost_per_well * n_wells)
return profit
### Bootstrapping Technique
def bootstrap_profit(predictions, target, n_wells, revenue_per_barrel, cost_per_well, n_samples=1000):
state = np.random.RandomState(42)
profits = []
for _ in range(n_samples):
sample_indices = state.choice(predictions.index, size=n_wells, replace=True)
sample_predictions = predictions.loc[sample_indices]
sample_target = target.loc[sample_indices]
profit = calculate_profit(sample_predictions, sample_target, n_wells, revenue_per_barrel, cost_per_well)
profits.append(profit)
profits = pd.Series(profits)
mean_profit = profits.mean()
lower_bound = profits.quantile(0.025)
upper_bound = profits.quantile(0.975)
risk_of_loss = (profits < 0).mean() * 100
return mean_profit, (lower_bound, upper_bound), risk_of_loss
New contributor
KingJ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.