* Adding new file to the machine_learning directory
* Adding initial documentation
* importing modules
* Adding Normal_gen function
* Adding Y_gen function
* Adding mean_calc function
* Adding prob_calc function
* Adding var_calc function
* Adding predict function
* Adding accuracy function
* Adding main function
* Renaming LDA file
* Adding requested changes
* Renaming some of functions
* Refactoring str.format() statements to f-string
* Removing unnecessary list objects inside two functions
* changing code style in some lines
* Fixing y_generator function
* Refactoring 'predict_y_values' function by using list comprehensions
* Changing code style in import statements
* Refactoring CLI code block
* fixup! Format Python code with psf/black push
* No lines longer than 88 characters
* Remove code with side effects from main
When running tests withy pytest, some modules execute code in main scope
and open plot or browser windows.
Moves such code under `if __name__ == "__main__"`.
* fixup! Format Python code with psf/black push
* Added Pytests for Decission Tree
Modified the mean_squared_error to be a static method
Created the Test_Decision_Tree class
Consists of two methods
1. helper_mean_squared_error_test: This method calculates the mean squared error manually without using
numpy. Instead a for loop is used for the same.
2. test_one_mean_squared_error: This method considers a simple test case and compares the results by the
helper function and the original mean_squared_error method of Decision_Tree class. This is done using asert
keyword.
Execution:
PyTest installation
pip3 install pytest OR pip install pytest
Test function execution
pytest decision_tree.py
* Modified the pytests to be compatible with the doctest
Added 2 doctest in the mean_squared_error method
For its verification a static method helper_mean_squared_error(labels, prediction) is used
It uses a for loop to calculate the error instead of the numpy inbuilt methods
Execution
```
pytest .\decision_tree.py --doctest-modules
```
* Added dbscan in two formats. A jupyter notebook file for the
storytelling and a .py file for people that just want to look at the
code. The code in both is essentially the same. With a few things
different in the .py file for plotting the clusters.
* fixed LGTM problems
* Some requested changes implemented.
Still need to do docstring
* implememted all changes as requested
* svm.py
for issue #840
I would like to add the Support Vector Machine algorithm implemented in Python 3.6.7
Requirements:
- sklearn
* update svm.py
* update svm.py
* Update and renamed to sorted_vector_machines.py
* Updated sorted_vector_machines.py
* Travis CI: Add pytest --doctest-modules neural_network
Fixes#987
```
neural_network/perceptron.py:123: in <module>
sample.insert(i, float(input('value: ')))
../lib/python3.7/site-packages/_pytest/capture.py:693: in read
raise IOError("reading from stdin while output is captured")
E OSError: reading from stdin while output is captured
-------------------------------------------------------------------------------- Captured stdout --------------------------------------------------------------------------------
('\nEpoch:\n', 399)
------------------------
value:
```
* Adding fix from #1056 -- thanks @QuantumNovice
* if __name__ == '__main__':
* pytest --ignore=virtualenv # do not test our dependencies
I've implemented a basic decision tree in python as an example of how they work. Although the class I've created only works on one dimensional data sets, the reader should be able to generalize it to higher dimensions should they need to.