Implementing your own k-nearest neighbour algorithm using Python
This method just brings together the previous functions and should be relatively self-explanatory. One potentially confusing point may be the very end of the script – instead of just calling main() to run the script, it is useful to instead first check if name "main" . This would make no difference at all if you only want to run this script as is from the command line or in an interactive shell – when reading the source code, the Python interpreter would set the special name variable to "main" and run everything. However, say that you wanted to just import the functions to another module (another .py
Nov-30-2016, 22:40:27 GMT
- Industry:
- Technology: