To be more specific, I want to modify some functions in scikit-learn
and import it to python. But I do not know how to work.
I tried to modify .py files directly from where the sklearn stores in my local directory, but there are some files I could not open to modify, such as those with .cp36-win_amd64
.
Any advice would be helpful!
You should never edit an installed package. Instead, install a forked version of package. If you need to edit the code frequently, DO NOT install the package via pip install something and edit the code in '.../site_packages/...' Put your changes in a version control system, and tell pip to install it explicitly.
Just rename the scikit-learn root folder (the folder that contains the setup.py file) to something like myScikitLearn). Install it using "pip install -e myScikitLearn/".
We can import modules from packages using the dot (.) operator. Now, if this module contains a function named select_difficulty() , we must use the full name to reference it. Now we can directly call this function.
Delete the scikit-learn package, clone the version you are interested in from github. Go to the directory where you've cloned it and run:
pip3 install -e ./
This will install the package in development mode. Any changes you make will take effect the next time you run your application.
Modifying source files is not a good idea...especially if you want to use the "unmodified" version later on. My advice would to:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With