diff --git a/examples/tmva/plot_multiclass.py b/examples/tmva/plot_multiclass.py index ce42356..319c603 100644 --- a/examples/tmva/plot_multiclass.py +++ b/examples/tmva/plot_multiclass.py @@ -47,18 +47,18 @@ # The following line is necessary if events have been added individually: factory.PrepareTrainingAndTestTree(TCut('1'), 'NormMode=EqualNumEvents') -# Train a BDT -factory.BookMethod('BDT', 'BDTG', - 'nCuts=20:NTrees=20:MaxDepth=4:' - 'BoostType=Grad:Shrinkage=0.10') +# Train an MLP +factory.BookMethod('MLP', 'MLP', + 'NeuronType=tanh:NCycles=200:HiddenLayers=N+2,2:' + 'TestRate=5:EstimatorType=MSE') factory.TrainAllMethods() # Classify the test dataset with the BDT reader = TMVA.Reader() for n in range(2): reader.AddVariable('f{0}'.format(n), array('f', [0.])) -reader.BookMVA('BDT', 'weights/classifier_BDTG.weights.xml') -class_proba = evaluate_reader(reader, 'BDT', X_test) +reader.BookMVA('MLP', 'weights/classifier_MLP.weights.xml') +class_proba = evaluate_reader(reader, 'MLP', X_test) # Plot the decision boundaries plot_colors = "rgb" @@ -72,11 +72,10 @@ xx, yy = np.meshgrid(np.arange(x_min, x_max, plot_step), np.arange(y_min, y_max, plot_step)) -Z = evaluate_reader(reader, 'BDT', np.c_[xx.ravel(), yy.ravel()]) +Z = evaluate_reader(reader, 'MLP', np.c_[xx.ravel(), yy.ravel()]) Z = np.argmax(Z, axis=1) - 1 Z = Z.reshape(xx.shape) -plt.contourf(xx, yy, Z, cmap=cmap, vmin=Z.min(), vmax=Z.max(), - levels=np.linspace(Z.min(), Z.max(), 50)) +plt.contourf(xx, yy, Z, cmap=cmap, alpha=0.5) plt.axis("tight") # Plot the training points