Commit Graph

139 Commits

Author SHA1 Message Date
Dhruv
48357cea5b
Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
Abdoulaye Balde
7446e69571
Gradient Boosting Regressor (#2298)
* Stock market prediction using greadient boosting

* To reverse a string using stack

* To reverse string using stack

* Predict Stock Prices Python & Machine Learning

* Gradient boosting regressor on boston dataset

* Gradient boosting regressor implementation

* Gradient boosting regressor

* Gradient boosting regressor

* Gradient boosting regressor

* Removing files

* GradientBoostingRegressor example

* Demo Gradient Boosting

* Demo Gradient boosting

* demo of gradient boosting

* gradient boosting demo

* Fix spelling mistake

* Fix formatting

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-09-26 16:58:29 +02:00
Du Yuanchao
4d0a8f2355
Optimized recursive_bubble_sort (#2410)
* optimized recursive_bubble_sort

* Fixed doctest error due whitespace

* reduce loop times for optimization

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-10 10:31:26 +02:00
Tanuj Dhiman
25946e4570
Update scoring_functions.py (#2291)
* Update scoring_functions.py

We can find accuracy by manually if we are not going to use sklearn library.

* Update scoring_functions.py

* Update machine_learning/scoring_functions.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-09 19:04:46 +02:00
Shubham Shaswat
a1d1a44f51
added idf-smooth (#2174)
* added idf-smooth

* added idf-smooth

* added idf-smooth
2020-09-02 19:33:12 +02:00
BAKEZQ
d402cd0b6e
Fix SettingWithCopy warning by pandas (#2346)
* Fix SettingWithCopy warning in pandas

https://github.com/TheAlgorithms/Python/issues/2282

* Update k_means_clust.py

* Update k_means_clust.py

* Update k_means_clust.py

* Update k_means_clust.py

* Update k_means_clust.py

* Update k_means_clust.py
2020-08-23 13:40:57 +02:00
Dan Murphy
1f1c3b0e4b
Added Normalization and Standardization Algorithms (#2192)
* Added Standardization and Normalization algorithms with built-in stats

* Implement ndigits for rounding

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-07-10 15:36:51 +02:00
Christian Clauss
5f4da5d616
isort --profile black . (#2181)
* updating DIRECTORY.md

* isort --profile black .

* Black after

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-07-06 09:44:19 +02:00
Christian Clauss
cd3e8f95a0
isort --profile black --recursive . (#2170)
* isort --profile black --recursive .

* Update codespell.yml

* typo: vertices

* typo: Explanation

* typo: Explanation

* Fix typos
2020-07-06 08:48:18 +05:30
vinayak
2d3d660155
black fixes and Travis CI fixes (#2160)
* black format

* updating DIRECTORY.md

* fixes

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-07-02 20:02:15 +05:30
Christian Clauss
8ab84fd794
Only one carriage return (#2155)
* updating DIRECTORY.md

* touch

* fixup! Format Python code with psf/black push

* Update word_frequency_functions.py

* updating DIRECTORY.md

* Update word_frequency_functions.py

* Update lfu_cache.py

* Update sol1.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-25 19:15:30 +02:00
Dan Murphy
b368b1ecfd
NLP Word Frequency Algorithms (#2142)
* NLP Word Frequency Algorithms

* Added type hints and Wikipedia link to tf-idf

* Update machine_learning/word_frequency_functions.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update machine_learning/word_frequency_functions.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update machine_learning/word_frequency_functions.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update machine_learning/word_frequency_functions.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Fix line length for flake8

* Fix line length for flake8 V2

* Add line escapes and change int to float

* Corrected doctests

* Fix for TravisCI

* Fix for TravisCI V2

* Tests passing locally

* Tests passing locally

* Update machine_learning/word_frequency_functions.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update machine_learning/word_frequency_functions.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update machine_learning/word_frequency_functions.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update machine_learning/word_frequency_functions.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Add doctest examples and clean up docstrings

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-25 10:00:43 +02:00
beqakd
d034add61f
add visualization of k means clustering as excel format (#2104)
* add visualization of kmneas clust as excel format

* style changes

* style changes

* Add doctest and typehint!

* style change

* Update machine_learning/k_means_clust.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update machine_learning/k_means_clust.py

Co-authored-by: Christian Clauss <cclauss@me.com>

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-19 17:55:13 +02:00
Christian Clauss
9316e7c014
Set the Python file maximum line length to 88 characters (#2122)
* flake8 --max-line-length=88

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-16 10:09:19 +02:00
Christian Clauss
1f8a21d727
Tighten up psf/black and flake8 (#2024)
* Tighten up psf/black and flake8

* Fix some tests

* Fix some E741

* Fix some E741

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-22 08:10:11 +02:00
Erwin Lejeune
21ed8968c0
Fixes in Bidirectional A* (#2020)
* implement bidirectional astar

* add type hints

* add wikipedia url

* format with black

* changes from review

* fix collision check

* Add testmod()

* # doctest: +NORMALIZE_WHITESPACE

* Codespell: euclidean

* Codespell: coordinates

* Codespell: traversal

* Codespell: remaining

Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-21 21:50:52 +02:00
Christian Clauss
a7cd633bb6
Fix astar (#1966)
* Fix astar

Single character variable names are old school.

* fixup! Format Python code with psf/black push

* Tuple

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-10 20:49:40 +05:30
Jeffin Francis
77c3e5b74b
Added A* algorithm (#1913)
* a* algorithm

* changes after build error

* intent changes

* fix after review

* ImportMissmatchError

* Build failed fix

* doctest changes

* doctest changes
2020-05-10 00:37:36 +05:30
Jeffin Francis
8a8527f1bd
Added Lstm example for stock predection (#1908)
* Added Lstm example for stock predection

* Changes after review

* changes after build failed

* Add Kiera’s to requirements.txt

* requirements.txt: Add keras and tensorflow

* psf/black

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-07 08:53:44 +02:00
QuantumNovice
9bb57fbbfe
support_vector_machines.py increase error tolerance to suppress convergence warnings (#1929)
* Update support_vector_machines.py

* Update support_vector_machines.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-02 21:19:45 +02:00
Christian Clauss
6acd7fb5ce
Wrap lines that go beyond GitHub Editor (#1925)
* Wrap lines that go beyond GiHub Editor

* flake8 --count --select=E501 --max-line-length=127

* updating DIRECTORY.md

* Update strassen_matrix_multiplication.py

* fixup! Format Python code with psf/black push

* Update decision_tree.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-01 23:36:35 +02:00
Prince Gangurde
8c01da20d6
Update random_forest_regressor.py (#1880) 2020-04-17 12:43:50 +02:00
Prince Gangurde
b64c4af296
Create gaussian_naive_bayes.py (#1861)
* Create Gaussian_Naive_Bayes.py

Added Gaussian Naive Bayes algorithm in the module machine learning

* Rename Gaussian_Naive_Bayes.py to gaussian_naive_bayes.py

* requirements.txt: pip install xgboost

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-04-17 09:38:44 +08:00
Prince Gangurde
7ffdef2636
Fix some typos in random forest classifier (#1858) 2020-04-13 02:15:48 +02:00
Miggelito
10fc90c7bd
Added Random Forest Classifier (#1738)
* Added Random Forest Regressor

* Updated file to standard

* Added Random Forest Classifier (Iris dataset) and a Confusion Matrix for result visualization
2020-03-13 09:13:43 +01:00
matkosoric
7f04e5cd34
contribution guidelines checks (#1787)
* spelling corrections

* review

* improved documentation, removed redundant variables, added testing

* added type hint

* camel case to snake case

* spelling fix

* review

* python --> Python # it is a brand name, not a snake

* explicit cast to int

* spaces in int list

* "!= None" to "is not None"

* Update comb_sort.py

* various spelling corrections in documentation & several variables naming conventions fix

* + char in file name

* import dependency - bug fix

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-03-04 13:40:28 +01:00
Miggelito
f52b97f2c5
Added Random Forest Regressor and tested with flake8 (#1733)
* Added Random Forest Regressor

* Updated file to standard
2020-02-08 00:07:14 +05:30
Christian Clauss
bfcb95b297
Create codespell.yml (#1698)
* fixup! Format Python code with psf/black push

* Create codespell.yml

* fixup! Format Python code with psf/black push
2020-01-18 13:24:33 +01:00
Christian Clauss
28419cf839 pyupgrade --py37-plus **/*.py (#1654)
* pyupgrade --py37-plus **/*.py

* fixup! Format Python code with psf/black push
2020-01-03 22:25:36 +08:00
Christian Clauss
b9bff8f3a7
Remove \r from strings (#1622)
* Remove \r from strings

* Satisfy tensorflow with numpy>=1.17.4
2019-12-10 15:53:50 +01:00
ELNS
43905efe29 Adding doctests into LDA algorithm (#1621)
* Adding doctests into <gaussian_distribution> function

* Adding doctests into <y_generator> function

* Adding doctests into <calculate_mean> function

* Adding doctests into <calculate_probabilities> function

* Adding doctests into <calculate_variance> function

* Adding doctests into <predict_y_values> function

* Adding doctests into <accuracy> function

* fixup! Format Python code with psf/black push

* Update convex_hull.py

* Update convex_hull.py
2019-12-08 23:15:17 +01:00
Christian Clauss
26b0803319
Simplify sudoku.is_completed() using builtin all() (#1608)
* Simplify sudoku.is_completed() using builtin all()

Simplify __sudoku.is_completed()__ using Python builtin function [__all()__](https://docs.python.org/3/library/functions.html#all).

* fixup! Format Python code with psf/black push

* Update sudoku.py

* fixup! Format Python code with psf/black push

* Old style exception -> new style for Python 3

* updating DIRECTORY.md

* Update convex_hull.py

* fixup! Format Python code with psf/black push

* e.args[0] = "msg"

* ValueError: could not convert string to float: 'pi'

* Update convex_hull.py

* fixup! Format Python code with psf/black push
2019-12-08 22:42:17 +01:00
GeorgeChambi
9eb50cc223 Improved readability (#1615)
* improved readability

* further readability improvements

* removed csv file and added f
2019-12-07 06:39:59 +01:00
QuantumNovice
caad74466a Added Multilayer Perceptron (sklearn) (#1609)
* Added Multilayer Perceptron ( sklearn)

* Rename MLPClassifier.py to multilayer_preceptron_classifier.py

* Rename multilayer_preceptron_classifier.py to multilayer_perceptron_classifier.py

* Update multilayer_perceptron_classifier.py
2019-12-03 12:17:42 +01:00
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
Anup Kumar Panwar
f5fc930c1b Merge pull request #108 from frmatias/master
Perceptron - one neuron
2017-09-03 13:04:51 +05:30
Francisco Matias
a51be755d4 Perceptron - one neuron 2017-08-29 13:43:42 -03:00
sthkindacrazy
5b03d56cd6 scoring functions added 2017-08-19 14:23:00 +09:00
yashLadha
1727d79d97 Added Linear regression 2017-06-27 17:56:27 +05:30
=
64d29ef2ad -Added Gradient Descent Algorithm 2017-06-23 02:09:42 +05:30