Machine Learning with Python

Goodmorning everyone.
I am a developer and I am new on home assistant. I would like to implement some sort of machine learning on my smart home. I implement a script on python which is called and developed a response which I will see on the dashboard as an entity.
How can I use this pipeline? Can home assistant read python codes?

either use appdaemon or pyscript
both are worth looking into

maybe consider writing a custom component as you have direct access to the event bus.
a look at the dev docs might be a good start