Multi-State dependent Variable Encoding - encoding

I am a novice in this and am trying to get some knowledge over the pre-processing part I have the following query:
I am aware that if your dependent variable(y) has 2 states, then you might not need feature scaling on the dependent variable. But, in case of multi-state dependent variable like Customer_index(probable customer): no, yes, maybe , NA
If I use OnehotEncoder or LabelEncoder, i might get 0,1,2,3.
But, I believe when I try fitting up a model to this, the algorithm will assume this variables as ordinal/Weighted.
How can I handle this.
Some Useful artifact I found:
https://towardsdatascience.com/all-about-categorical-variable-encoding-305f3361fd02
Thanks for hep in advance.

I have some research on my questions above and I found once we apply encoding, we anyhow must do scaling on our data to apply biasness over the weights of the features and that is true for the multistate variable as well.
Let know your thoughts.

Related

Gather all answer sets into one answer set (ASP)

my question is, if I can gather all answer sets into one answer. I attach the code below for my program. The results that it returns and a description of what I would like to have.
% Main domain predicates definitions
argument(1..3).
element(1).
#show scope/2.
{scope(A, U) : element(U)}:- argument(A).
what I get is shown in the picture below
But what I would like to get is, some predicate that has a unique id for each answer set. For example:
newScope(1,empty)-newScope(2,2,1)-newScope(3,3,1)-....-newScope(8,1,1)|newScope(8,2,1)|newScope(8,3,1)
thanks in advance to whomever has the patience to answer me.
You can't do this, except if you accept an exponential blowup in atoms and even than it isn't that easy. You can't enumerate answer sets in a single answer set (the complexity for enumerating is higher, so you can't solve n NP problems (enumeration) inside one NP problem (except you describe n NP problems in your encoding, which is not practical).
Maybe you can describe what you are trying to achieve and there are other ways of how to do this.
Your problem could be solveable with disjunctive rules, as then the complexity rises to NP^2.
Edit: I found that https://github.com/potassco/guess_and_check could exactly do what you are looking for to describe a NP^2 problem without manually writing the disjunctive logic program.
you can also have a look at section 3.3.2 of the following paper:
https://arxiv.org/abs/2008.06692
The method presented there allows you to compute m different stable models of a logic program by finding m 1-diverse stable models. But note that m has to be given as input, hence the method is not directly applicable to the problem of computing one stable model that contains all stable models of a logic program.

How to pass multiple variables from one model to another model (inner/outer)

Let's say we have the following model:
Collector:
model Collector
Real collect_here;
annotation(defaultComponentPrefixes="inner");
end Collector;
and the following model potentially multiple times:
model Calculator
outer Collector collector;
Real calculatedVariable = 2*time;
equation
calculatedVariable = collector.collect_here;
end Calculator;
The code above works if calcModel is present only once in the system to be simulated. If the model exists more than once I get a singular system. This is demonstrated by the Example below. Changing the parameter works either gives a working or failing system.
model Example
parameter Boolean works = true;
inner Collector collector;
Calculator calculator1;
Calculator calculator2 if not works;
end Example;
Using an array inside the collector to pass multiple variables in it doesn't solve it.
Another possible way to solve this is possible by use of connectors, but I only made it work with one calcModel.
Using multiple instances of Calculator does brake the model, as the single variable calculatedVariable will have multiple equations trying to compute its value. Therefore Dymola complains that the system is structurally singular, in this case meaning that there are more equations than variables in the resulting system of equations.
To give a bit more of an insight: Actually checking Collector will fail, as since Modelica 3.0 every component has to be balanced (meaning it has to have as many unknowns as states), which is not the case for Collector as it does have one unknown but no equation. This strongly limits the possible applications for the inner/outer construct as basically every variable has to be computed where it is defined.
In the given example this is compensated in the overall system if exactly one Calculator is used. So this single combination will work. Although this works, it is something that should not be done - for the obvious reason of being very error-prone (and all sub-models should pass the check).
Your question on how to solve this issue actually misses a description of what the issue actually is. There are some cases in my mind that your approach could be useful for:
You want to plot multiple variables from a single point, which would be collector. For this purpose "variable selections" should be the most straight-forward way to go: see Dymola Manual Vol. 1, Section "4.3.11 Matching and variable selections" on how to apply them.
You want to carry out some mathematical operation on that variables. Then it could be useful to have a vectorized input of variable size. This enables an arbitrary number of connections to this input. For an example of this take a look at: Modelica.Blocks.Math.MultiSum
You want to route multiple signals between different models (which is unlikely judging from your description, but still): Then expandable connectors would be a good possibility. To get an impression of what that does take a look at Modelica.Blocks.Examples.BusUsage.
Hope this helps, otherwise please specify more clearly what you actually want to achieve with your code.
I prepared a demonstrative library for such scenario some days ago. You can access it at https://gist.github.com/beutlich/e630b2bf6cdf3efe96e5e9a637124fe1. If you read the documentation on Example2 you can see the link to an article from H. Elmqvis et. al., which is the clue to your problem. That is, you need a connector, and inherited connects from every Calculator to the one Collector.

Presenting Arima results - Use of Stargazer (or other equivalent package)?

I currently have several ARIMA models in R which I'm looking to present formally within a paper.
I'm just wondering if a tool exists that will allow me to illustrate these results, without having to manually extract this data?
Unless I'm mistaken, I understand stargazer does accommodate arima variations, but not the "Arima" code found within the forecast package. When I have tried to use the latter, I have received an error message telling me it is an "unrecognised object type".
Is there anything else that can be done?
Separately, for other types of diagnostic outputs (e.g. Augmented Dickey-Fuller tests, etc), are there other ways kable, etc, can be used to present these results?
Thanks in advance for any help!

Where can I find good and simple test functions for evolutionary algorithms?

I've started learning evolutionary algorithms (GA, PSO, ...) and I want to implement them in Matlab and play with different parameters to get a hold of the algorithms' structures and how they work.
My problem is, I don't have some simple test functions to use. For example, functions with multiple peaks/valleys, one global minimum and multiple local ones, .... Nothing complicated, just some simple mathematical functions with their formulas.
I can try to make some up with putting some sin/cos/exp together, but it'll take time and is really frustrating!
Anybody knows of a resource (site, book, ...) that have these listed?
Here is a set from our very own #Rody Oldenhuis:
Test functions
You might want to try those in the BBOB benchmark set. There is also some nice accompanying literature to this set in form of the corresponding GECCO workshop.
Some of the classic functions were mentioned by AGS already and include Rastrigin, Rosenbrock and Generalized Rosenbrock, Schwefel, Sphere, Griewank, etc.. We have also implemented these and more in HeuristicLab, so if you want to experiment you can also try that (PSO and GA are included also).

Searching for a concept like 'verbosity' in Modelica

I'm struggling with the size of output files for large Modelica models. Off course, I can protect some objects in order to remove them completely from the result file. However, that gives rise to two problems:
it's not possible to redeclare protected objects
if i want to test my model in detail (eg for a short time period), i need to declare those objects publicly again in order to see their variables
I wonder if there's a trick to set the 'verbosity' of a Modelica model. Maybe what I would like is a third keyword next to public, protected, eg. transparent. Then, when setting up a simulation, I want be able to set the verbosity level to 1, or 2 with the following effect:
1--> consider all transparentelements as protected
2--> consider all transparentelements as public
This effect would propagate to all models and submodels.
I don't think this already exists. But is there an easy workaround?
Thanks,
Roel
As Michael Tiller wrote above, this is not handled the same way in all Modelica tools and there is no definite answer. To give an OpenModelica-specific answer, it's possible to use simulate(ModelName,outputFilter="regex"), to store only the variables that fully match the given regex (default is .*, matching any variable).
Roel,
I know several people wrestling with this issue. At the moment, all of this depends on the tool being used. I don't know how other tools handle filtering of results, but in Dymola you control it (as you point out) by giving the signals special qualifiers (e.g. protected).
One thing I've done in the past is to extend from a model and then add a bunch of output signals for things I'm interested in. Then you can select "Outputs" in Dymola to make sure those get in the results file. This is far from perfect because a) listing everything you want can get tedious and b) referencing protected variables is not strictly allowed (although Dymola lets you get away with it but issues a warning).
At Dassault, we are actively discussing this idea and hope to provide some better functionality along these lines. It isn't clear whether such functionality will be strictly tool specific or whether it will involve the language somehow. But if it is language related, we will (of course) work with the design group to formulate a specification that other tool vendors can support as well.
In SystemModeler, you go to the Settings tab in the Experiment Browswer in Simulation Center. Click on Output on the bottom and select which variables to store.
(The options are state variables, derivatives, algebraic variables, parameters, protected variables and if you mark the Store simulation log-option, you'll get some interesting statistics on events over time and function evaluations, opening another possibility to track down parts of the simulation and model that creates more evaluations)
I am not sure if this helps you, but in Dymola you can go to Simulation->Setup->Output and mark a checkbox saying "Store Protected variables". That way it is possible to declare most variables as protected: during normal simulation they are not stored, but when debugging your model, you just mark that checkbox and they are stored.
Of course that is not the same as your suggested keyword transparent, but maybe it helps a little...
A bit late, but in Dymola 2013 FD01 and later you can select which variables to store based on names (and model names) using the annotation __Dymola_selections, and even filter on user-defined tags - so you could create a tag name "transparent" in the model. See "Matching and variable selections" in the manual.