13 from root_pandas 
import to_root
 
   16 from matplotlib 
import pyplot 
as plt
 
   19 def train_mva_method(file_name):
 
   21     weight_file = 
"weightfile.root" 
   23     general_options = basf2_mva.GeneralOptions()
 
   24     general_options.m_datafiles = basf2_mva.vector(file_name)
 
   25     general_options.m_treename = 
"tree" 
   26     general_options.m_identifier = weight_file
 
   27     general_options.m_variables = basf2_mva.vector(
'A', 
'B')
 
   28     general_options.m_target_variable = 
'C' 
   30     regression_fastbdt_options = basf2_mva.RegressionFastBDTOptions()
 
   32     regression_fastbdt_options.setMaximalBinNumber(20)
 
   37     basf2_mva.teacher(general_options, regression_fastbdt_options)
 
   42 def create_random_data():
 
   43     file_name = 
"data.root" 
   46     df = pd.DataFrame({
"A": np.random.rand(1000), 
"B": np.random.rand(1000)})
 
   47     df[
"C"] = (df.A + df.B) / 2
 
   49     to_root(df, file_name, store_index=
False, key=
"tree")
 
   53 def apply_expert(file_name, weight_file):
 
   54     output_file = 
'expert.root' 
   55     basf2_mva.expert(basf2_mva.vector(weight_file), basf2_mva.vector(file_name), 
'tree', output_file)
 
   59 def create_plot(expert_file):
 
   60     df = uproot.open(expert_file)[
"variables"].arrays(library=
"pd")
 
   61     df.plot.scatter(
"weightfile__ptroot_C", 
"weightfile__ptroot", ax=plt.gca())
 
   64     plt.savefig(
"result.pdf")
 
   67 if __name__ == 
"__main__":
 
   68     from basf2 
import conditions
 
   70     conditions.testing_payloads = [
 
   71         'localdb/database.txt' 
   75     file_name = create_random_data()
 
   78     weight_file = train_mva_method(file_name)
 
   81     expert_file = apply_expert(file_name, weight_file)
 
   84     create_plot(expert_file)