expectedparrot / edsl

Design, conduct and analyze results of AI-powered surveys and experiments. Simulate social science and market research with large numbers of AI agents and LLMs.
https://docs.expectedparrot.com
MIT License
189 stars 19 forks source link

Modify `pretty_labels` to make it possible to use `question_text` when there is no question id #856

Open rbyh opened 3 months ago

rbyh commented 3 months ago

Currently it is not possible to use question_text as a pretty_label when there is no question id -- eg, for any survey created using Conjure.

This is the typical way to do it:

from edsl import QuestionFreeText

q = QuestionFreeText.example()
results = q.run()
results.select("answer.*").print(pretty_labels={"answer.how_are_you":q.question_text})

But if there is no question id it is not possible -- eg this does not work:

from edsl import QuestionFreeText

results = QuestionFreeText.example().run()
results.select("answer.*").print(pretty_labels={"answer.how_are_you":q.question_text})

This does not work either:

results.select("answer.*").print(pretty_labels={"answer.how_are_you":question_text.how_are_you_question_text})
rbyh commented 3 months ago

Perhaps we could add an optional parameter to print()?

results.select("answer.*").print(format="rich, question_text_headers=True)
rbyh commented 3 months ago

You might also want to use the question_names.

johnjosephhorton commented 2 months ago

So I think I have a solution - we're going to re-factor ScenarioList + Dataset so that each has an optional 'codebook' entry. @rbyh this is used, for example, when you do the "valid identifier" conversion for a ScenarioList but I'm not currently serializing this. This codebook would let us, say, do more sophisticated printing things such as replace the columns with question_text without tediously re-writing them. Right now, the problem is when you get to a 'print' the Dataset in question doesn't know it came from a Result object, for example.

@apostolosfilippas - this would mean adding a new field to both ScenarioList and Dataset objects. I know we don't serialize/store Datasets, so no issue there, but for ScenarioList, this would be a breaking change. That being said, it's an optional parameter.

rbyh commented 2 months ago

Bumping this. Eg, we should make this work (it does not):

image