Commit Graph

55 Commits

Author SHA1 Message Date
ELNS
f4a7c5066c converting generator object to a list object (#1602)
* converting generator object to a list object

* Refactor: converting generator object to a list object

* fixup! Format Python code with psf/black push
2019-11-28 17:21:34 +01:00
ELNS
140b79b4b2 Adding Linear Discriminant Analysis (#1592)
* 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
2019-11-26 12:57:53 +01:00
Mantas Zimnickas
12f69a86f5 Remove code with side effects from main (#1577)
* 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
2019-11-17 19:38:48 +01:00
Ankur Chattopadhyay
7592cba417 psf/black code formatting (#1421)
* added sol3.py for problem_20

* added sol4.py for problem_06

* ran `black .` on `\Python`
2019-10-22 19:13:48 +02:00
Christian Clauss
4531ea425e
Transfer .ipynb files to TheAlgorithms/Jupyter (#1414) 2019-10-22 08:45:03 +02:00
Hrishikesh Suslade
4590363806 Added Pytests for Decission Tree mean_squared_error method (#1374)
* 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
```
2019-10-18 20:23:37 +02:00
archit kaushal
2197bfa029 #840 adds polymonial regression program in python (#1235)
* #840 adds polymonial regression program in python

* Update polymonial_regression.py

* Update polymonial_regression.py
2019-10-18 08:20:22 +02:00
Phyllipe Bezerra
455509acee Add Topological Sort (#1302)
* add topological sort

* fix topological sort?

* running black

* renaming file
2019-10-18 08:13:58 +02:00
Kaushik Amar Das
25701a9877 added doctests to scoring_functions.py (#1300)
* added doctests to scoring_functions.py

* dedented lines
2019-10-08 13:12:27 +05:00
Parth Paradkar
b1a769cf44 Add pure implementation of K-Nearest Neighbours (#1278)
* Pure implementation of KNN added

* Comments and test case added

* doctest added
2019-10-06 23:50:50 +05:00
William Zhang
9eac17a408 psf/black code formatting (#1277) 2019-10-05 10:14:13 +05:00
Kaushik Amar Das
4617aa78b2 DBSCAN algorithm (#1207)
* 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
2019-09-29 10:44:41 +02:00
Holden-Lin
837bfffd99 Rename sorted_vector_machines.py to support_vector_machines.py (#1195)
SVM stands for support vector machines. Intuitively, a support vector is the vector right near the decision boundary.
2019-09-22 16:56:32 +02:00
BAKEZQ
a2b5a90c11 Added sequential minimum optimization algorithm for SVM (#508)
* Implementation of sequential minimal optimization algorithm

* Update smo.py

* Add demonstration of svm partition boundary

1:Use matplotlib show svm's partition boundary
2:Automatically download test dataset

* Update smo.py

* Update smo.py

* Rename smo.py to sequential_minimum_optimization.py

* Update doc and simplify the code.

Fix filename typo error in doc.
Use ternary conditional operator in predict()

* Update doc.
2019-09-18 22:01:05 +08:00
Riemann
2f8516e561 implementation of sorted vector machines (#1156)
* 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
2019-08-28 12:56:43 +02:00
Christian Clauss
47a9ea2b0b
Simplify code by dropping support for legacy Python (#1143)
* Simplify code by dropping support for legacy Python

* sort() --> sorted()
2019-08-19 15:37:49 +02:00
Christian Clauss
36684db278
Travis CI: Add pytest --doctest-modules machine_learning (#1016)
* 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
2019-08-10 22:48:00 +02:00
Amrit Khera
32c0418f63 Infinite loop was fixed. (#1105)
* Infinite loop was fixed.
Removed issue of unused variables.

* Update logistic_regression.py

* Update logistic_regression.py

* correct spacing according to PEP8
2019-08-07 21:39:44 +02:00
Christian Clauss
89acf5d017 print() is a function just like every other function (#1101)
* print() is a function just like every other function
2019-08-06 12:14:23 +02:00
Christian Clauss
a9ecdb33ca Validate Python filenames (#1086) 2019-07-30 15:32:13 +05:30
Rakshit Parashar
0d61539883 Log_likelihood update (#1008)
* Add files via upload

This is a simple exploratory notebook that heavily expolits pandas and seaborn

* Update logistic_regression.py

* Update logistic_regression.py

* Rename Food wastage analysis from 1961-2013 (FAO).ipynb to other/Food wastage analysis from 1961-2013 (FAO).ipynb

* Update logistic_regression.py

* Update logistic_regression.py

* Update logistic_regression.py

* Update logistic_regression.py

* Update logistic_regression.py

* Update logistic_regression.py

* Update logistic_regression.py
2019-07-13 21:54:38 +02:00
Anup Kumar Panwar
4e413c0183 Updated README 2019-07-06 11:11:20 +05:30
Dhandarah
afb98e6c23 KNN (#944)
Creates an example of KNN algorithm using sklearn library.
2019-07-05 14:17:18 +05:30
Erfan Alimohammadi
1b3affc2ed fix typo (#902) 2019-06-16 02:07:23 +05:30
Satyam-Bhalla
49fc9a1aed Random Forest Classification added 2018-10-27 08:12:16 +05:30
Satyam-Bhalla
349450b957 Random Forest Regression Added 2018-10-27 08:08:03 +05:30
Harshil
3fa8f7bc2f
Update logistic_regression.py 2018-10-24 21:20:28 +02:00
Alex Brown
ea2ddaaf6a all valid python 3 2018-10-20 14:45:08 -05:00
Alex Brown
b566055e4b Merge branch 'master' of https://github.com/TheAlgorithms/Python 2018-10-20 14:15:21 -05:00
Alex Brown
91fccecb56 snake_case all the things 2018-10-19 17:14:25 -05:00
Harshil
116ab0fa96 Merge branch 'master' of git://github.com/epicalyx/Python into epicalyx-master 2018-10-19 15:44:30 +02:00
Harshil
81dc87aeb1 Merge branch 'master' of git://github.com/Himani2000/Python into Himani2000-master 2018-10-19 15:13:52 +02:00
Parth Shandilya
5d1f72604d
Improved Code and removed Warnings (#483) 2018-10-19 14:00:31 +05:30
Parth Shandilya
07451a6ca4
Improved Code and removed warnings (#482)
Improved Code and removed warnings
2018-10-19 13:28:21 +05:30
ParthS007
0856a61859 Remove Multiple Unused Imports and Variable 2018-10-18 02:58:57 +05:30
Taru
7105f6f648
minor changes
requested changes are addressed
2018-10-17 01:07:29 +05:30
Taru
f018ddc4c0
requested changes addressed 2018-10-17 00:52:32 +05:30
Taru
ade3ed3784
Logistic regression implementation
implementation of logistic regression for binary classification
2018-10-17 00:22:44 +05:30
Harshil
4fc68bbb4c
Update Reuters - OneVsRestClassifier.ipynb 2018-10-12 18:50:00 +02:00
Harshil
67a31e4b2f Reuters - OneVsRestClassifier (I'd also uploaded the same at: https://www.kaggle.com/harshildarji/reuters-onevsrestclassifier) 2018-10-12 18:46:45 +02:00
Himani Negi
ee8c01179d
Add files via upload 2018-10-09 01:51:14 +05:30
cclauss
4ee0e620cb Modernize Python 2 code to get ready for Python 3 AGAIN 2018-01-21 08:25:19 +01:00
cclauss
2ed1bad747
Merge branch 'master' into modernize-python2-code 2017-12-13 16:32:28 +01:00
cclauss
e31c780d94 Modernize Python 2 code to get ready for Python 3 2017-11-25 12:41:55 +01:00
cclauss
4e06949072 Modernize Python 2 code to get ready for Python 3 2017-11-25 10:23:50 +01:00
himangSharatun
80bdfbb9f9 add mean bias deviation in scoring functions 2017-11-18 10:34:07 +07:00
Harshil
6bc30c7182 Merge pull request #139 from anuragkumarak95/master
added k means clustering algorithm, usage doc inside.
2017-10-17 18:50:48 +05:30
Nathan Berger
37967bd0cf Fixed case where function didn't return where it should
I added these return statements so that invalid inputs or valid end cases would no longer continue running through the rest of the function.
2017-10-09 12:42:51 -05:00
Nathan Berger
8fb1eb7bdf Implementation of a regression tree in python
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.
2017-10-09 12:36:33 -05:00
Anurag Kumar
07fb7d695a added k means clustering algorithm, usage doc inside. 2017-10-02 21:13:43 +05:30