Search code examples
machine-learningkdb

Machine learning in q/kdb+


If I have a table stored on my hdb process at port 5012.

I have installed PyKX and successfully imported it to the python prompt in terminal.

I then connect to my host=‘localhost’, port=5012 and run a simple query to return my data from hdb q(‘{select name,price,volume,vwap from tab where date>2024.01.01}’)

How do I then use this data in one of the python machine learning algorithms. How do you go about converting the table data into usable python data points to then feed into your selected model? Do you have to extract each column of data and save as a variable of a certain type like running an exec statement in q process?


Solution

  • With PyKX you should be able to convert to a pandas dataframe using the .pd method off the PyKX objects (tables in this case), for your example this would be

    q(‘select name,price,volume,vwap from tab where date>2024.01.01’).pd()
    

    Assuming in the above that the table tab is accessible from q memory and/or you are using a remote q process containing your data