Re: Re: Re: Untitled

From Bistre Marmoset, 3 Months ago, written in Plain Text, viewed 58 times. This paste is a reply to Re: Re: Untitled from Bitty Macaw - view diff
URL http://codebin.org/view/1d5ed649 Embed
Download Paste or View Raw
  1. import pandas as pd
  2. import numpy as np
  3.  
  4. # открываем файлы
  5. # возьмём индекс '0', чтобы перевести данные в pd.Series
  6. target = pd.read_csv('/datasets/eng_target.csv')['0']
  7. probabilities = pd.read_csv('/datasets/eng_probabilities.csv')['0']
  8.  
  9. def revenue(target, probabilities, count):
  10.     probs_sorted = probabilities.sort_values(ascending=False)
  11.     selected = target[probs_sorted.index][:count]
  12.     return 1000 * selected.sum()
  13.  
  14. state = np.random.RandomState(12345)
  15.    
  16. values = []
  17. for i in range(1000):
  18.     target_subsample = target.sample(frac=1, replace=True, random_state=state)
  19.     probs_subsample = probabilities[target_subsample.index]
  20.     values.append(target_subsample.sum())
  21.  
  22. values = pd.Series(values)
  23. lower = values.quantile(0.01)
  24.  
  25. mean = values.mean()
  26. print("Средняя выручка:", mean)
  27. print("1%-квантиль:", lower)

Reply to "Re: Re: Re: Untitled"

Here you can reply to the paste above