0

How can I call a method with array as transform param? Like

my_array = [a, b]
pipeline.make_pipeline(my_array)

So if I write

pipeline.make_pipeline(my_array[0], my_array[1])

it works.

a and b are objects from sklearn.

I tried to convert the array to string and eval it:

pipeline_string = eval((', '.join(map(str, my_array))).replace("\n", ""))
pipeline.make_pipeline(pipeline_string)

To change or add a function in make_pipeline is no option

Thanks

Antoine Delia
  • 1,728
  • 5
  • 26
  • 42
GeoRie
  • 21
  • 4
  • 2
    Is [argument unpacking](https://docs.python.org/3.7/tutorial/controlflow.html#unpacking-argument-lists) what you're looking for? If so this is probably [a duplicate](https://stackoverflow.com/questions/3480184/unpack-a-list-in-python). – ShapeOfMatter Oct 09 '19 at 13:08
  • `foo(*array)` to unpack array. and `foo(**_dict_)` to unpack dictionary. – Poojan Oct 09 '19 at 13:10
  • 1
    Hello and welcome to SO. It's impossible to post a _serious_ answer without knowing (at least) what `pipeline.make_pipeline` expects as arguments. If it comes from a 3rd part lib, please mention it explicitely in your question (NOT in a comment), preferably with a link to the relevant doc. Else post the function or method definition (at least the signature). – bruno desthuilliers Oct 09 '19 at 15:31

0 Answers0