The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
I think I mentioned this to you before, but I have a fascination with the visual salience of decision tree rule structures rendered into relatively simple ui's [^]
I like to give my students this example to test their logical thinking in terms of how they perceive what the most relevant criteria are:
AIRFARE DISCOUNT from visual-paradigm's old website
Infant passengers under two years old are offered a discount of 80% on domestic flights.
Infant passengers under two years old are offered a discount of 70% on international flights.
Youth passengers (between two and sixteen) are offered a discount of 10%, for any kind of destination.
Passengers who make reservation five months before their journey are offered a discount of 10%.
For international flights, passengers are offered 15% discount if they travel during off-seasons.
There would be no discount for international flights, except that when the passenger is an infant passenger or when travelling during off-season.
Frequent flyer enjoys a discount of 15%.
The amount of discount is accumulated.
The maximum amount of discount for infant passengers is 80%
The maximum amount of discount for non-infant passengers is 20%.
Now, some students immediately grok that "age" is the criteria here with the most "organizing power." Others don't have a clue.
The challenge I see is how to take a set of "rules" like this and "prune" the matrix of possible combinations down to the essential set.
In my head this also relates to the general area of "business rules," and even DSL's.
Hope you found this interesting; my head is not on very straight these daze.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
Coding a decision tree structure is one thing, but the problem I see with generating code for it is making it work in the general sense - a similar problem with state machines. As in, sure I can make one of these things, but it will be suitable toward one particular task - like your airfare example. I don't see a lot of opportunity to generalize the algorithm. As I said, I ran into the same problem with state machines.
It's just really painful. It ought to be possible to define a cleansyntax that was far more expressive of common data manipulation on dataframes and translate into a series of pandas calls. It could be done as a pre-processor step prior to trying to merge into baseline Python.
It would be interesting to try to define this as an abstract and be able to translate into python/pandas code, LINQ, R, SQL, etc
Those of us who've been here long enough will remember Osmodian (I might have that name wrong) where he went on and on about English language to code generation. In many ways, I think that's still the Holy Grail - when I was 20 or so, at a computer convention in SF (think Apple ][, Commodore, Trash-80, Atari, Sinclair, etc) there were quite a few demonstrations of code being generated from sentences. It was touted as "this is the future".
Yeah, and it's not wrong either. Mac users DO stink!
Anything that is unrelated to elephants is irrelephant Anonymous - The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944 - Never argue with a fool. Onlookers may not be able to tell the difference. Mark Twain