示例#1
0
    def generate_plots(self, directory):
        # TODO: Enable plots for debug
        # helper.get_dataset_by_name(self.tb_data_handler.data, 'fm_demod')['result_okay']        = False
        # helper.get_dataset_by_name(self.tb_data_handler.data, 'fm_channel_data')['result_okay'] = False
        # helper.get_dataset_by_name(self.tb_data_handler.data, 'audio_mono')['result_okay']      = False
        # helper.get_dataset_by_name(self.tb_data_handler.data, 'pilot')['result_okay']           = False
        # helper.get_dataset_by_name(self.tb_data_handler.data, 'carrier_38k')['result_okay']     = False
        # helper.get_dataset_by_name(self.tb_data_handler.data, 'audio_lrdiff')['result_okay']    = False
        # helper.get_dataset_by_name(self.tb_data_handler.data, 'audio_L')['result_okay']         = False
        # helper.get_dataset_by_name(self.tb_data_handler.data, 'audio_R')['result_okay']         = False

        # Plot
        for i in range(0, len(self.model.data)):
            model_dataset = self.model.data[i]
            tb_dataset = self.tb_data_handler.data[i]

            self.log_info(f"Creating plot for {tb_dataset['name']}")

            tn = np.arange(0, len(tb_dataset['data'])) / tb_dataset['fs']
            data_to_plot = (
                (tn, tb_dataset['data'], "data_out_{}".format(tb_dataset['name'])),
                (tn, from_fixed_point(model_dataset['data']), "self.model.gold_{}".format(model_dataset['name']))
            )
            helper.plotData(data_to_plot,
                            title=tb_dataset['name'],
                            filename="{}/plot_{}.png".format(directory, tb_dataset['name']),
                            show=not tb_dataset['result_okay'])
示例#2
0
## =============== Part 1: Loading and Visualizing Data ================
#  We start the exercise by first loading and visualizing the dataset.
#  The following code will load the dataset into your environment and plot
#  the data.
#

print('Loading and Visualizing Data ...')

# Load from ex6data1:
# You will have X, y in your environment
mat = loadmat('ml/ex6/data/ex6data1.mat')
X = mat["X"]
y = mat["y"]

plotData(X, y)

input('Program paused. Press enter to continue.')

## ==================== Part 2: Training Linear SVM ====================
#  The following code will train a linear SVM on the dataset and plot the
#  decision boundary learned.
#

# Load from ex6data1:
# You will have X, y in your environment
mat = loadmat('ml/ex6/data/ex6data1.mat')
X = mat["X"]
y = mat["y"]

print('Training Linear SVM ...')
示例#3
0
# Load Data
#  The first two columns contains the exam scores and the third column
#  contains the label.
data = np.loadtxt('ml/ex2/ex2data1.txt', delimiter=",")
X = data[:, :2]
y = data[:, 2]

## ==================== Part 1: Plotting ====================
#  We start the exercise by first plotting the data to understand the
#  the problem we are working with.
print(
    'Plotting data with + indicating (y = 1) examples and o indicating (y = 0) examples.'
)

plt, p1, p2 = plotData(X, y)

# # Labels and Legend
plt.xlabel('Exam 1 score')
plt.ylabel('Exam 2 score')
plt.legend((p1, p2), ('Admitted', 'Not Admitted'), numpoints=1, handlelength=0)

plt.show(block=False
         )  # prevents having to close the graph to move forward with ex2.py

input('Program paused. Press enter to continue.\n')
# plt.close()

## ============ Part 2: Compute Cost and Gradient ============
#  In this part of the exercise, you will implement the cost and gradient
#  for logistic regression. You neeed to complete the code in
示例#4
0
    sigModelTPC = ROOT.RooGaussian('signal','signal function TPC', ns, muSigTPC, sigmaSigTPC)

    # bkg 1
    nBkg0TPC = ROOT.RooRealVar(r'N_{bkg0}','counts TPC bkg0', 0, 1e+4)
    tauBkg0TPC = ROOT.RooRealVar(r'#tau_{bkg0}','tau TPC bkg0',-10, 10)
    bkg0ModelTPC = ROOT.RooExponential('bkg0','bkg0 function TPC',ns,tauBkg0TPC)

    nBkg1TPC = ROOT.RooRealVar(r'N_{bkg1}','counts TPC bkg1', 0, 1e+4)
    tauBkg1TPC = ROOT.RooRealVar(r'#tau_{bkg1}','tau TPC bkg1',-10, 10)
    bkg1ModelTPC = ROOT.RooExponential('bkg1','bkg1 function TPC',ns,tauBkg1TPC)

    totModelTPC = ROOT.RooAddPdf('model','tot function TPC', ROOT.RooArgList(sigModelTPC, bkg0ModelTPC, bkg1ModelTPC),ROOT.RooArgList(nSigTPC,nBkg0TPC, nBkg1TPC))

    hTPChist = ROOT.RooDataHist(f"TPCsignalHe3_{he3_mom}", f"TPCsignalHe3_{he3_mom}", ROOT.RooArgList(ns), tpc_histo)

    frame, chi2,fitres = hp.plotData(ns, hTPChist, totModelTPC, 1.1, "SignalHe3", low_edge , sup_edge, f"SignalHe3_{he3_mom}")

    mu_list.append(muSigTPC.getVal())
    mu_error_list.append(muSigTPC.getError())
    sigma_list.append(sigmaSigTPC.getVal())
    sigma_error_list.append(sigmaSigTPC.getError())

    
    frame.Write()


mean_histo = ROOT.TH1D(f"Mean TPCsignal", f"Mean TPCsignal", len(mom_values), mom_values[0] - 0.025, mom_values[-1] + 0.025)
sigma_histo = ROOT.TH1D(f"Sigma TPCsignal", f"Sigma TPCsignal", len(mom_values), mom_values[0] - 0.025, mom_values[-1] + 0.025)

for iBin in range(1, mean_histo.GetNbinsX() + 1):
    mean_histo.SetBinContent(iBin, mu_list[iBin - 1])