tree = dtModel.stages[-1]
print(tree) #visualize the decision tree model
AttributeError Traceback (most recent call
last)
AttributeError: 'DecisionTreeClassificationModel' object has no
attribute 'stages'
Please click the picture link to see more details. Thanks
Stages are used for pipeline models, if you fit your model using pipeline you can call model.stages.
Here is one example.
For normal decision tree models you should just call model.toDebugString
Hope this answers your question.
Related
I am going through the tutorial for Model simulation of Enterprise Architect. In the Dynamic Simulations, under section of CreateObject, it says that the Output action pin stores the created object and can be passed via an object flow to another action. The attributes of the created object can be then accessed in the destination action. See EA Help and
Breakpoint 1: A CreateObject Action creates an Object ´cb´ and the local variable
Breakpoint 2: The created object passed to Action3 via an object flow in action pins, the control is passed with control flow.
However, as you can see that the object cb is nowhere to be seen in Action3. I would really appreciate if someone can help me in this and explain how it works.
So, I tried a lot of things to do this. And I somehow figured out a way to do part of it. So here is the answer.
Pre-Requisite: A class with a few attributes and operation. Along with the behavior of the operation to be performed. Like in the below example, following is the behavior defined for add operation.
this.x=x;
this.y=y;
return x+y;
Steps:
Create a CreateObject Action Element (Toolbar (space) > Action > Create Object).
In element properties (docked) set the Classifier. (Properties > Element tab > CreateObjectAction section > Classifier > {Class, Actor, Activity}).
The CreateObject has a 'result' ActionPin. Drag the ActionPin to the diagram from the browser on the CreateObjectAction Element.
Assign the ActionPin(result) of type as the classifier object from Element Properties of ActionPin.
Add an object flow to a new action or the destination action, on which the object is being passed.
Follow step 4 for the new action pin generated.
Add the control flow from the create object to a destination action(might be same or different than the action of Step 5).
Drag the Class to the activity diagram and create it's instance with a unique name. (IT'S STRANGE THAT WE NEED TO DO THIS, BUT IT DOESN'T WORK WITHOUT THIS)
Finally after completion of diagram. We can perform simulation. The newly created object can be seen in the Local window as UID.
This is the created object which can be used to access the operation and the attributes of instance. In order to do this, copy this name and use it in the effect field of action.
this.result = DFB9AEAD91_990D_4cec_AE54_93A8A3BC684F.add(7,7);
The output then can be seen in the local window.
NOTE: The object "cb" is still nowhere to be seen. However, an object is definitely created with a unique id as shown in the above code snippet. A part of the question still remains unanswered is the role of action pins.
I'd like to have two plants in the same builder and scene graph. (I don't want them on the same plant because I'd like to separate their dynamics, but I'd like them to affect each other, hence keeping them on the same builder and scene graph.)
My implementation is the following:
from pydrake.multibody.plant import AddMultibodyPlantSceneGraph
from pydrake.systems.framework import DiagramBuilder
builder = DiagramBuilder()
plant1, scene_graph = AddMultibodyPlantSceneGraph(builder, 0.0)
plant2 = AddMultibodyPlantSceneGraph(builder, 0.0, scene_graph)
When I run this, I get the error:
Traceback (most recent call last):
File "/filepath/2plants1scene.py", line 6, in <module>
plant2 = AddMultibodyPlantSceneGraph(builder, 0.0, scene_graph)
RuntimeError: C++ object must be owned by pybind11 when attempting to release to C++
Is this a bindings issue? The documentation for AddMultibodyPlantSceneGraph makes it seem as though it can add plants to already existing scenes.
The error messages look similar to this issue from 2018: https://github.com/RobotLocomotion/drake/issues/8160
Thanks in advance for any ideas.
Is this a bindings issue?
Regarding your specific error message, you are trying to take one object (whose ownership is governed by unique_ptr<>) and trying to pass it off its owned data twice (or more).
From C++ API:
https://drake.mit.edu/doxygen_cxx/classdrake_1_1multibody_1_1_multibody_plant.html#aac66563a5f3eb9e2041bd4fa8d438827
Note that the scene_graph argument is unique_ptr<>.
So, it's a bindings error insofar as the error message is kinda bad; however, it's more of a semantics issue w/ C++ API.
The documentation for AddMultibodyPlantSceneGraph makes it seem as though it can add plants to already existing scenes.
For reference, here is the core implementation of that method:
https://github.com/RobotLocomotion/drake/blob/v0.32.0/multibody/plant/multibody_plant.cc#L3346-L3370
For your use case, you should only add the SceneGraph to the DiagramBuilder once. Since you want to connect one SceneGraph to multiple MultibodyPlant instances, I would advise that you do not use AddMultibodyPlantSceneGraph, as that is sugar for a 1:1 pairing.
Instead, you should register and connect the SceneGraph manually; I think it would look something like this:
def register_plant_with_scene_graph(scene_graph, plant):
plant.RegsterAsSourceForSceneGraph(scene_graph)
builder.Connect(
plant.get_geometry_poses_output_port(),
scene_graph.get_source_pose_port(plant.get_source_id()),
)
builder.Connect(
scene_graph.get_query_output_port(),
plant.get_geometry_query_input_port(),
)
builder = DiagramBuilder()
scene_graph = builder.AddSystem(SceneGraph())
plant_1 = builder.AddSystem(MultibodyPlant(time_step=0.0))
register_plant_with_scene_graph(scene_graph, plant_1)
plant_2 = builder.AddSystem(MultibodyPlant(time_step=0.0))
register_plant_with_scene_graph(scene_graph, plant_2)
As Sean warned above, you will need to be careful with this pairing.
This only seems to happen when I try to view some model objects.
I get the following when I visit the history page for an object in the admin page:
__str__ returned non-string (type NoneType)
Full traceback:
https://dpaste.com/EQMTDXK5H
EDIT: Looks like the issue was that the str for my model was returning an integer, which Django seemed happy with but django-simple-history was not. I added str() into my str to convert the integer to a string and all works now.
Looking at the code here and here
Seems that the __str__ of the HistoryRecords module looks for the __str__ of your model to build it's own, and also uses it on the template for the history build.
Check that your model has __str__ implemented.
I try to do a model-to-model transformation using Epsilon. The target model is UML.
If I validate the output model in Eclipse I get the following error message:
"Element 'Activity test' must be owned, but it has no owner."
So I tried to add a statement to my ETL file that adds owners for my activities.
But:
"Internal error: java.lang.IllegalArgumentException: The feature 'owner' is not a valid changeable feature"
Do I have to modify the UML ecore file in order to make 'owner' changeable? If so, how would I do that?
What exactly should be the owner of an activity? Another model element?
Best regards.
The feature Element.owner (which Activity inherits) is a container reference. In order to set it, you have to set the opposite, which is the containment reference Element.ownedElement. The activity should be contained in your root Package or Model in the feature packagedElements.
I'm playing with DIXF and following Alex's blog http://ax2012aifintegration.blogspot.com/2014/05/microsoft-dynamics-ax-2012-file_4600.html?showComment=1405542006070#c2497509467713291887
I'm stuck on creating a batch job that has two tasks -- one for getting data from staging table and another for exporting teh data from staging table to a flat file.
The first task requires that I invoke DMFStagingWriter class. The AX-shipped version doesn't have the canGoBatchJournal set to true; so the class doesn't show in the task list. I overrode that method and returned a value of true. I compiled the class and generated an incremental CIL. However, when I try to use that class in the batch task list, it doesn't show. If I type it in, AX says it is an invalid class.
What am I missing?
Thank you.
I found my own solution. It was a matter of simply getting out of Ax and coming back in to resolve the issue.