Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
313 commits
Select commit Hold shift + click to select a range
bae08ad
README.md: Lose LGTM badge because we don't use it (#7063)
cclauss Oct 12, 2022
e2cd982
Weird numbers (#6871)
Variiiest Oct 12, 2022
07e991d
Add pep8-naming to pre-commit hooks and fixes incorrect naming conven…
CaedenPH Oct 12, 2022
1aa7bd9
Added barcode_validator.py (#6771)
Abinashbunty Oct 12, 2022
6118b05
Convert snake_case to camelCase or PascalCase (#7028) (#7034)
carlos3dx Oct 13, 2022
7ad6c64
Add typing to maths/add.py (#7064)
saksham-chawla Oct 13, 2022
9b0909d
Add typing and snake casing to maths/decimal_isolate.py (#7066)
saksham-chawla Oct 13, 2022
c73cb7e
Add typing to maths/sum_of_arithmetic_series.py (#7065)
saksham-chawla Oct 13, 2022
e661b98
Binary Search Tree Inorder Traversal Algorithm (#6840)
SinghGurneet21 Oct 13, 2022
d5a9f64
Add flake8-builtins to pre-commit and fix errors (#7105)
CaedenPH Oct 13, 2022
f176786
Update open_google_results.py (#7085)
cj-praveen Oct 13, 2022
4d0c830
Add flake8 pluin flake8 bugbear to pre-commit (#7132)
CaedenPH Oct 13, 2022
71353ed
refined readme.md (#7081)
jpyces Oct 13, 2022
3deb4a3
Create binary_search_matrix.py (#6995)
anuragshuklajec Oct 13, 2022
05e1912
Create norgate.py (#7133)
AkshajV1309 Oct 13, 2022
26fe4c6
Remove extra Semicolon (#7152)
mahiuddin-dev Oct 14, 2022
e40c7b4
refactor: move flake8 config (#7167)
dhruvmanila Oct 14, 2022
fd5ab45
Doctest output simpler version (#7116)
Abinashbunty Oct 14, 2022
0c06b25
Create speed_conversions.py (#7128)
Abinashbunty Oct 14, 2022
2058775
refactor: Make code more understandable (#7196)
CaedenPH Oct 14, 2022
5dc0dc4
remove useless bool() call (#7189)
Luk-ESC Oct 14, 2022
dcca535
Added astronomical_length_scale_conversion.py (#7183)
Claudiocli Oct 14, 2022
6e69181
refactor: Replace `list()` and `dict()` calls with literals (#7198)
CaedenPH Oct 15, 2022
70b60dc
chore: remove inactive user from CODEOWNERS (#7205)
dhruvmanila Oct 15, 2022
6be9500
chore: remove checkbox in feature issue template (#7212)
cclauss Oct 15, 2022
98a4c24
feat: Binary tree node sum (#7020) (#7162)
CaedenPH Oct 15, 2022
a652905
Add Flake8 comprehensions to pre-commit (#7235)
CaedenPH Oct 15, 2022
553624f
Add algorithm for Casimir Effect (#7141)
ZeroDayOwl Oct 15, 2022
c94e215
types: Update binary search tree typehints (#7197)
CaedenPH Oct 15, 2022
0469853
Misc fixes across multiple algorithms (#6912)
CenTdemeern1 Oct 16, 2022
e7b6d28
Change to https. (#7277)
girisagar46 Oct 16, 2022
7776411
Create q_full_adder.py (#6735)
KevinJoven11 Oct 16, 2022
c6582b3
refactor: Move constants outside of variable scope (#7262)
CaedenPH Oct 16, 2022
d728f5a
Added some more comments to volume.py in maths folder (#7080)
jpyces Oct 16, 2022
b5b1eb2
Fix broken links by PR #7277 (#7319)
girisagar46 Oct 16, 2022
6d20e2b
Add `flake8-broken-line` to `pre-commit` (#7338)
CaedenPH Oct 16, 2022
7f6e0b6
Corrected the directory of Fractional Knapsack algorithm (#7086)
SudhanshuSuman Oct 16, 2022
f15cc2f
Follow Flake8 pep3101 and remove modulo formatting (#7339)
CaedenPH Oct 16, 2022
a34b756
ci: Add ``yesqa`` (flake8-plugin) to ``pre-commit`` (#7340)
CaedenPH Oct 16, 2022
0c7c5fa
[pre-commit.ci] pre-commit autoupdate (#7387)
pre-commit-ci[bot] Oct 17, 2022
3448ae5
[Binary Tree] Different views of binary tree added (#6965)
kondekarshubham123 Oct 17, 2022
49cd46a
Update convolve function namespace (#7390)
tianyizheng02 Oct 18, 2022
6d1e009
Remove depreciated np.float (#7394)
tianyizheng02 Oct 18, 2022
2ca695b
[Matrix] Max area of island problem solved DFS algorithm (#6918)
kondekarshubham123 Oct 18, 2022
5bfcab1
Create minmax.py (#7409)
ManishKumar219 Oct 18, 2022
b90ec30
Create combination_sum.py (#7403)
creatornadiran Oct 18, 2022
80ff25e
Update gaussian_naive_bayes.py (#7406)
mvsg2 Oct 19, 2022
b8281d7
Fixed a typo of 'a' and 'an' and used f string in print statement (#7…
Oct 19, 2022
50da472
Implemented Gelu Function (#7368)
Oct 19, 2022
2859d4b
Remove references to depreciated QasmSimulator (#7417)
tianyizheng02 Oct 19, 2022
4829fea
Create graphs/dijkstra_alternate.py (#7405)
AtulRajput01 Oct 20, 2022
831280c
Add quantum_random.py (#7446)
Alanzz Oct 20, 2022
42b56f2
XGBoost Classifier (#7106)
Moddy2024 Oct 20, 2022
717f0e4
Maclaurin series approximation of sin (#7451)
ChrisO345 Oct 21, 2022
cc10b20
Remove some print statements within algorithmic functions (#7499)
tianyizheng02 Oct 22, 2022
a5dd07c
Maclaurin approximation of cos (#7507)
ChrisO345 Oct 22, 2022
ed12703
Created sum_of_harmonic_series.py (#7504)
AkshitGulyan Oct 23, 2022
f32f78a
Basic string grammar fix (#7534)
abhishekchak52 Oct 23, 2022
a0cbc20
refactor: Make code more simple in maclaurin_series (#7522)
CaedenPH Oct 23, 2022
1bbb009
Add signum function (#7526)
arjitarora26 Oct 23, 2022
b092f99
XGB Regressor (#7107)
Moddy2024 Oct 23, 2022
a3383ce
Reduced Time Complexity to O(sqrt(n)) (#7429)
Hannibal404 Oct 23, 2022
a536279
Create superdense_coding.py (#7349)
KevinJoven11 Oct 23, 2022
d5f322f
fix: Replace deprecated `qasm_simulator` with `aer_simulator` (#7308)…
CaedenPH Oct 23, 2022
81ccf54
Rename xgboostclassifier.py to xgboost_classifier.py (#7550)
cclauss Oct 23, 2022
0f06a0b
Add web program to fetch top 10 real time billionaires using the forb…
girisagar46 Oct 23, 2022
393b960
refactor: Replace doctest traceback with `...` (#7558)
CaedenPH Oct 23, 2022
10b6e7a
fix: Fix line too long in doctest (#7566)
CaedenPH Oct 23, 2022
0dc95c0
Update comments in check_pangram.py script (#7564)
SwayamSahu Oct 23, 2022
b8b6346
My favorite palindrome (#7455)
cclauss Oct 23, 2022
39a99b4
check whether integer is even or odd using bit manupulation (#7099)
Lauquik Oct 23, 2022
e2a83b3
Update knapsack.py (#7271)
creatornadiran Oct 23, 2022
bd49061
Add function for AND gate (#7593)
arjitarora26 Oct 24, 2022
bb07854
Update count_number_of_one_bits.py (#7589)
JatinR05 Oct 24, 2022
d8ab8a0
Add Spain National ID validator (#7574) (#7575)
carlos3dx Oct 24, 2022
a041b64
feat: add Project Euler problem 073 solution 1 (#6273)
MaximSmolskiy Oct 24, 2022
d407476
fix: increase str conversion limit where required (#7604)
MaximSmolskiy Oct 25, 2022
a662d96
Add function for xor gate (#7588)
arjitarora26 Oct 25, 2022
cbdbe07
Create kinetic_energy.py (#7620)
SparshRastogi Oct 25, 2022
4508423
Arc Length Algorithm (#7610)
havishs9 Oct 25, 2022
103c9e0
Added Implementation of NAND, OR ,XNOR and NOT gates in python (#7596)
karthiks2611 Oct 25, 2022
d25187e
Remove type cast in combinations algorithm (#7607)
tianyizheng02 Oct 25, 2022
7e3dff1
Docs: correct the shape of trajectory (#6255)
AryaSamik Oct 25, 2022
2c959a7
Update documentation of cnn_classification.py (#7486)
harshyadavcs Oct 25, 2022
c3bcfbf
Add Cramer's rule for solving system of linear equations in two varia…
kituuu Oct 25, 2022
c31ef5e
Add longest common substring (#7488)
RohitSingh107 Oct 25, 2022
505c5e2
Included area of n sided regular polygon (#7438)
mislah Oct 25, 2022
68f6e9a
Added function that checks if a string is an isogram (#7608)
M3talM0nk3y Oct 26, 2022
abf0909
Write a proper implementation for base16 (#6909)
CenTdemeern1 Oct 26, 2022
9390565
added support for inverse of 3x3 matrix (#7355)
kituuu Oct 26, 2022
8fd06ef
Create minimums_squares_to_represent_a_number.py (#7595)
JatinR05 Oct 26, 2022
5c8a939
Create largest_square_area_in_matrix.py (#7673)
kondekarshubham123 Oct 26, 2022
614274a
Update spiral_print.py (#7674)
kondekarshubham123 Oct 26, 2022
74325d0
Rename quantum_random.py to quantum_random.py.DISABLED.txt (#7683)
cclauss Oct 26, 2022
b46b92a
Add function for highest set bit location (#7586)
arjitarora26 Oct 26, 2022
71c7c0b
Updated a typo in print statement (#7696)
SwayamSahu Oct 26, 2022
d33f9b3
Calculate GST Amount (#7694)
sushant4191 Oct 26, 2022
e906a51
Create malus_law.py (#7710)
SparshRastogi Oct 27, 2022
e891509
refactor: Fix matrix display deprecation (#7729)
CaedenPH Oct 27, 2022
9bba42e
refactor: Indent ... for visual purposes (#7744)
CaedenPH Oct 27, 2022
71e8ed8
Added spheres union (#6879)
matteomessmer Oct 27, 2022
501a1cf
Remove unnecessary else statement (#7759)
AlexandreVelloso Oct 27, 2022
61eedc1
Remove useless code in doctests (#7733)
CaedenPH Oct 27, 2022
de3271e
Refactoring the syntax using list comprehension (#7749)
SwayamSahu Oct 27, 2022
25757e6
Binary tree path sum (#7748)
CaedenPH Oct 27, 2022
15c93e5
fix typo in caesar_cipher.py (#7761)
MoPaMo Oct 27, 2022
19bff00
Adopt Python >= 3.8 assignment expressions using auto-walrus (#7737)
cclauss Oct 28, 2022
3a671b5
Implemented Swish Function (#7357)
Oct 28, 2022
26cecea
Create fetch_amazon_product_data.py (#7585)
SparshRastogi Oct 28, 2022
d9efd7e
Update PR template (#7794)
Cjkjvfnby Oct 28, 2022
528b129
Update maximum_subarray.py (#7757)
pronoym99 Oct 28, 2022
fe5819c
Create combination_sum_iv.py (#7672)
kondekarshubham123 Oct 28, 2022
762afc0
Update breadth_first_search_2.py (#7765)
Cjkjvfnby Oct 28, 2022
cf08d9f
Format docs (#7821)
Cjkjvfnby Oct 29, 2022
301a520
Create potential_energy.py (#7666)
SparshRastogi Oct 29, 2022
a9bd68d
Add running doctest to pytest default (#7840)
Cjkjvfnby Oct 29, 2022
6e809a2
Rename files (#7819)
Cjkjvfnby Oct 29, 2022
327c38d
Srilankan phone number validation (#7706)
sinsankio Oct 29, 2022
b0f68a0
Create centripetal_force.py (#7778)
tarushirastogi Oct 29, 2022
18ffc4d
Update password_generator.py (#7745)
pronoym99 Oct 29, 2022
584e743
Fix yesqa hook (#7843)
Cjkjvfnby Oct 29, 2022
93ad7db
Create recursive_approach_knapsack.py (#7587)
JatinR05 Oct 29, 2022
efb4a3a
added algo for finding permutations of an array (#7614)
rajansh87 Oct 29, 2022
7b521b6
Add Viterbi algorithm (#7509)
carlos3dx Oct 29, 2022
038f8a0
add electric conductivity algorithm (#7449)
sadiqebrahim Oct 29, 2022
a02e7a1
Added algorithm for Text Justification in Strings (#7354)
TheLameOne Oct 29, 2022
d844523
Correcting typos in CONTRIBUTING.md (#7845)
dmorozov001 Oct 29, 2022
bd50a30
Resonant Frequency & Electrical Impedance (#6983)
SKVKPandey Oct 29, 2022
47ddba1
Added cosine similarity (#7001)
KushagraMakharia Oct 29, 2022
1550731
Remove file-level flake8 suppression (#7844)
Cjkjvfnby Oct 29, 2022
3ec0aa8
Update kinetic_energy.py (#7848)
SparshRastogi Oct 29, 2022
7b7b3dd
matrix/count_paths.py (#7533)
deprecatedjd Oct 30, 2022
2d39850
Fix grammatical mistakes in `simple_keyword_cypher.py` (#6385)
Itssxxsalman Oct 30, 2022
f340bde
Add simple neural network (#6452)
CaioCordeiro Oct 30, 2022
0c5f1c0
Increased Readability Of Variables (#6400)
ok-open-sc Oct 30, 2022
f87de60
fizzbuzz complete (#6504)
lostybtw Oct 30, 2022
17d93ca
Added Manhattan distance algorithm (#7790)
carlos3dx Oct 30, 2022
57ccabb
Update docs (#7867)
Cjkjvfnby Oct 30, 2022
5ba5c54
Updated info (#7866)
sushant4191 Oct 30, 2022
87a5d91
quantum_teleportation.py (#6632)
KevinJoven11 Oct 30, 2022
00dfad9
Simplify climbing stairs and use constant memory (#6628)
giladwo Oct 30, 2022
84facb7
Project Euler: 092 decreased the time (#6627)
Saksham1970 Oct 30, 2022
48a73a2
fix(quantum): Correct simulator deprecation (#7869)
CaedenPH Oct 30, 2022
ba576a9
Create README.md (#6642)
devesh-0419 Oct 30, 2022
ca92338
Description of Double hasing (#6467)
silam Oct 30, 2022
c0b0b12
Add Ideal Gas Law for physics (#6503)
kavienanj Oct 30, 2022
b32903d
Add root mean square speed of gas molecules to physics (#6569)
kavienanj Oct 30, 2022
fcfe35c
For the better understanding of time taken. (#6583)
samyakpagariya Oct 30, 2022
00fc53d
added sumset.py Fixes: #{6563} (#6742)
happiestbee Oct 30, 2022
6b6d8cc
Adding ELFHash Algorithm (#6731)
micaelalex Oct 30, 2022
cc42300
Added Readme file to document the hashing algorithm. (#6743)
pravinkori Oct 30, 2022
b5d7f18
Polynomial (#6745)
Emmastro Oct 30, 2022
9278d0c
Added archimedes principle (physics) (#7143)
DIvkov575 Oct 30, 2022
cafbbab
shortened code using abs() and inplace ops (#7191)
Luk-ESC Oct 30, 2022
ab9d8f3
Adding a Quine in Python. (#6807)
j3r3mias Oct 30, 2022
94b51f6
Added Builtin Voltage (#7850)
sadiqebrahim Oct 30, 2022
69d04ff
Added mean absolute error in linear regression (#7003)
KushagraMakharia Oct 30, 2022
2c65597
addition_without_arithmetic (#6830)
kumarsurajsk Oct 30, 2022
cf915e7
add Levinstein distance with Dynamic Programming: up -> down approach…
alexpantyukhin Oct 30, 2022
d1430aa
Implemented a Pascal triangle generator (#7317)
wissamfawaz Oct 30, 2022
47100b9
Added code for palindrome partitioning problem under dynamic programm…
agnivg Oct 30, 2022
11e6c6f
Added algorithm for finding index of rightmost set bit (#7234)
GautamChaurasia Oct 30, 2022
e12516d
Shear stress: typo + WIkipedia URL (#7896)
abhishekchak52 Oct 30, 2022
c0168cd
Created equivalent_resistance under Electronics (#6782)
Gmuslow Oct 30, 2022
f8958eb
Add print_multiplication_table.py (#6607)
himanshit0304 Oct 30, 2022
39e5bc5
Refactor bottom-up edit distance function to be class method (#7347)
tianyizheng02 Oct 31, 2022
0fd1ccb
Adding inductive reactance calculation (#6625)
RobisLV Oct 31, 2022
b2165a6
Added Radix Tree in data structures (#6616)
acrulopez Oct 31, 2022
a31edd4
Test on Python 3.11 (#6591)
cclauss Oct 31, 2022
fecbf59
Modified 'pascal_triangle.py' program (#7901)
TechFreak107 Oct 31, 2022
506b63f
Create convert_number_to_words.py (#6788)
s18k Oct 31, 2022
ded5dea
Dodecahedron surface area and volume (#6606)
shri30yans Oct 31, 2022
21601a4
create quantum_fourier_transform (#6682)
KevinJoven11 Oct 31, 2022
6cd7c49
[pre-commit.ci] pre-commit autoupdate (#7920)
pre-commit-ci[bot] Oct 31, 2022
6c15f52
Added Torus surface area (#7906)
Paradact Oct 31, 2022
7addbcc
Torus volume (#7905)
Paradact Oct 31, 2022
74aa9ef
Added a Hubble Parameter calculator file (#7921)
Gustavobflh Oct 31, 2022
7d139ee
refactor(abs): Condense `abs_min` and `abs_max` (#7881)
CaedenPH Nov 1, 2022
d23e709
maths/sum_of_digits.py: Streamline benchmarks (#7914)
cclauss Nov 1, 2022
4e6c1c0
Is power of two (#7936)
alexpantyukhin Nov 1, 2022
f512b4d
refactor: Move pascals triange to maths/ (#7932)
CaedenPH Nov 1, 2022
f05baa2
add dp up - down minimum cost for tickets (#7934)
alexpantyukhin Nov 2, 2022
598f6a2
refactor: Condense `password` related files in one (#7939)
CaedenPH Nov 2, 2022
45b3383
Flake8: Drop ignore of issue A003 (#7949)
cclauss Nov 2, 2022
db5215f
Reduce the complexity of linear_algebra/src/polynom_for_points.py (#7…
MaximSmolskiy Nov 2, 2022
a02de96
Reduce the complexity of graphs/minimum_spanning_tree_prims.py (#7952)
MaximSmolskiy Nov 2, 2022
978414b
Reduce the complexity of other/graham_scan.py (#7953)
MaximSmolskiy Nov 2, 2022
3e1cb70
add algorithm to check binary search tree (#7947)
alexpantyukhin Nov 3, 2022
7f1a552
add prefix sum (#7959)
alexpantyukhin Nov 4, 2022
5170853
Update 3n_plus_1.py (#7966)
SandersLin Nov 6, 2022
daa1c75
Raise error not string (#7945)
CaedenPH Nov 6, 2022
6aaf0a2
maths/number_of_digits.py: Streamline benchmarks (#7913)
cclauss Nov 8, 2022
8951d85
BB84 QKD algorithm (#7898)
abhishekchak52 Nov 8, 2022
3f9aae1
feat: Add automorphic number implementation (#7978)
itsAkshayDubey Nov 9, 2022
076193e
feat: Add pronic number implementation (#7979)
itsAkshayDubey Nov 10, 2022
4cddb26
atbash.py: Tighten up the benchmarks (#7977)
cclauss Nov 10, 2022
5c92b73
prime_numbers.py: Tighten up the benchmarks (#7976)
cclauss Nov 10, 2022
7b2eca0
add distribute coins (#7975)
alexpantyukhin Nov 10, 2022
e1be882
algorithm: Twin prime (#7980)
itsAkshayDubey Nov 10, 2022
316e71b
Additional intro blockchain doc (#7974)
GK3077 Nov 15, 2022
3bf86b9
fix: no implicit optional (#7984)
dhruvmanila Nov 15, 2022
4ce8ad9
algorithm: Liouville lambda function (#7986)
itsAkshayDubey Nov 15, 2022
8bfd1c8
fix: mypy 0.991 issues (#7988)
dhruvmanila Nov 15, 2022
0684ccd
[pre-commit.ci] pre-commit autoupdate (#7983)
pre-commit-ci[bot] Nov 15, 2022
b33ea81
algorithm: Add juggler sequence (#7985)
itsAkshayDubey Nov 18, 2022
f01a1af
Bi directional dijkstra (#7982)
SwayamInSync Nov 20, 2022
a25c53e
Fix argument validation for count_1s_brian_kernighan_method (#7994)
alexpantyukhin Nov 20, 2022
f32d611
clean of unnecessary checks, imports, calls (#7993)
marksmayo Nov 20, 2022
08c2245
Upgrade to flake8 v6 (#8007)
cclauss Nov 29, 2022
361ddaf
[pre-commit.ci] pre-commit autoupdate (#8006)
pre-commit-ci[bot] Nov 29, 2022
47bf3f5
fix validation condition and add tests (#7997)
alexpantyukhin Nov 29, 2022
6a86fe4
Add backtrack word search in matrix (#8005)
alexpantyukhin Nov 29, 2022
5654c62
algorithm: Hexagonal number (#8003)
itsAkshayDubey Nov 29, 2022
d141fa8
[pre-commit.ci] pre-commit autoupdate (#8017)
pre-commit-ci[bot] Dec 5, 2022
b25915a
Add algorithm to convert decimal number to its simplest fraction form…
iaaryanraj Dec 11, 2022
40f165b
[pre-commit.ci] pre-commit autoupdate (#8026)
pre-commit-ci[bot] Dec 12, 2022
af8d520
Update is_even.py (#8028)
rga2 Dec 15, 2022
30277f8
add numbers different signs algorithm. (#8008)
alexpantyukhin Dec 15, 2022
3f8b2af
Add autoclave cipher (#8029)
VictorRS27 Dec 18, 2022
d4c5b22
[pre-commit.ci] pre-commit autoupdate (#8037)
pre-commit-ci[bot] Dec 19, 2022
79ef431
Reduce the complexity of sorts/merge_insertion_sort.py (#7954)
MaximSmolskiy Dec 24, 2022
27d56ba
[pre-commit.ci] pre-commit autoupdate (#8047)
pre-commit-ci[bot] Dec 26, 2022
90686e3
Add LZ77 compression algorithm (#8059)
LuciaHarcekova Dec 28, 2022
b72d068
Remove extra imports in gamma.py doctests (#8060)
tianyizheng02 Dec 29, 2022
c6223c7
add word_break dynamic approach up -> down. (#8039)
alexpantyukhin Dec 30, 2022
d29afca
Fix get_top_billioners.py file name typo (#8066)
tianyizheng02 Jan 1, 2023
7c1d23d
Change prime_sieve_eratosthenes.py to return list (#8062)
tianyizheng02 Jan 2, 2023
725731c
Refactor `local_weighted_learning.py` to use `np.array` (#8069)
tianyizheng02 Jan 2, 2023
9f041e9
Refactor `sierpinski_triangle.py` (#8068)
tianyizheng02 Jan 2, 2023
32a1ff9
Update is_palindrome.py (#8022)
abhishekmulik Jan 4, 2023
4939e84
Create cached fibonacci algorithm (#8084)
CaedenPH Jan 7, 2023
1a27258
gcd_of_n_numbers (#8057)
balakhaniyan Jan 10, 2023
c00af45
feat: Concatenate both factorial implementations (#8099)
CaedenPH Jan 26, 2023
57c12fa
Fix `mypy` errors in `lorentz_transformation_four_vector.py` (#8075)
tianyizheng02 Jan 26, 2023
ed0a581
[pre-commit.ci] pre-commit autoupdate (#8107)
pre-commit-ci[bot] Jan 30, 2023
c909da9
pre-commit: Upgrade psf/black for stable style 2023 (#8110)
cclauss Feb 1, 2023
77b4fa8
fix_ci_badge (#8134)
SheriffHobo Feb 12, 2023
126e89d
[pre-commit.ci] pre-commit autoupdate (#8141)
pre-commit-ci[bot] Feb 13, 2023
1bf0388
Update bogo_sort.py (#8144)
yanvoi Feb 19, 2023
67676c3
[pre-commit.ci] pre-commit autoupdate (#8149)
pre-commit-ci[bot] Feb 21, 2023
1c15cdf
[pre-commit.ci] pre-commit autoupdate (#8160)
pre-commit-ci[bot] Feb 27, 2023
64543fa
Make some ruff fixes (#8154)
cclauss Mar 1, 2023
069a14b
Add Project Euler problem 082 solution 1 (#6282)
MaximSmolskiy Mar 2, 2023
ee77812
Reduce the complexity of other/scoring_algorithm.py (#8045)
MaximSmolskiy Mar 2, 2023
9720e6a
Add Project Euler problem 117 solution 1 (#6872)
MaximSmolskiy Mar 2, 2023
41b633a
[pre-commit.ci] pre-commit autoupdate (#8168)
pre-commit-ci[bot] Mar 6, 2023
9e28ecc
Add circular convolution (#8158)
subhendudash02 Mar 7, 2023
f9cc252
Reduce the complexity of backtracking/word_search.py (#8166)
MaximSmolskiy Mar 10, 2023
8959211
[pre-commit.ci] pre-commit autoupdate (#8177)
pre-commit-ci[bot] Mar 13, 2023
b797e43
Add hashmap implementation (#7967)
Cjkjvfnby Mar 14, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor local_weighted_learning.py to use np.array (TheAlgorithm…
…s#8069) * updating DIRECTORY.md * Format local_weighted_learning.py doctests for clarity * Refactor local_weighted_learning.py to use np.array instead of np.mat The np.matrix class is planned to be eventually depreciated in favor of np.array, and current use of the class raises warnings in pytest * Update local_weighted_learning.py documentation Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
  • Loading branch information
tianyizheng02 and github-actions authored Jan 2, 2023
commit 725731c8d289f742bfde3f159a538a47d19c27dc
3 changes: 2 additions & 1 deletion DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
* [Huffman](compression/huffman.py)
* [Lempel Ziv](compression/lempel_ziv.py)
* [Lempel Ziv Decompress](compression/lempel_ziv_decompress.py)
* [Lz77](compression/lz77.py)
* [Peak Signal To Noise Ratio](compression/peak_signal_to_noise_ratio.py)
* [Run Length Encoding](compression/run_length_encoding.py)

Expand Down Expand Up @@ -1162,7 +1163,7 @@
* [Get Amazon Product Data](web_programming/get_amazon_product_data.py)
* [Get Imdb Top 250 Movies Csv](web_programming/get_imdb_top_250_movies_csv.py)
* [Get Imdbtop](web_programming/get_imdbtop.py)
* [Get Top Billioners](web_programming/get_top_billioners.py)
* [Get Top Billionaires](web_programming/get_top_billionaires.py)
* [Get Top Hn Posts](web_programming/get_top_hn_posts.py)
* [Get User Tweets](web_programming/get_user_tweets.py)
* [Giphy](web_programming/giphy.py)
Expand Down
116 changes: 66 additions & 50 deletions machine_learning/local_weighted_learning/local_weighted_learning.py
Original file line number Diff line number Diff line change
@@ -1,116 +1,128 @@
# Required imports to run this file
import matplotlib.pyplot as plt
import numpy as np


# weighted matrix
def weighted_matrix(point: np.mat, training_data_x: np.mat, bandwidth: float) -> np.mat:
def weighted_matrix(
point: np.array, training_data_x: np.array, bandwidth: float
) -> np.array:
"""
Calculate the weight for every point in the
data set. It takes training_point , query_point, and tau
Here Tau is not a fixed value it can be varied depends on output.
tau --> bandwidth
xmat -->Training data
point --> the x where we want to make predictions
>>> weighted_matrix(np.array([1., 1.]),np.mat([[16.99, 10.34], [21.01,23.68],
... [24.59,25.69]]), 0.6)
matrix([[1.43807972e-207, 0.00000000e+000, 0.00000000e+000],
[0.00000000e+000, 0.00000000e+000, 0.00000000e+000],
[0.00000000e+000, 0.00000000e+000, 0.00000000e+000]])
Calculate the weight for every point in the data set.
point --> the x value at which we want to make predictions
>>> weighted_matrix(
... np.array([1., 1.]),
... np.array([[16.99, 10.34], [21.01,23.68], [24.59,25.69]]),
... 0.6
... )
array([[1.43807972e-207, 0.00000000e+000, 0.00000000e+000],
[0.00000000e+000, 0.00000000e+000, 0.00000000e+000],
[0.00000000e+000, 0.00000000e+000, 0.00000000e+000]])
"""
# m is the number of training samples
m, n = np.shape(training_data_x)
# Initializing weights as identity matrix
weights = np.mat(np.eye(m))
m, _ = np.shape(training_data_x) # m is the number of training samples
weights = np.eye(m) # Initializing weights as identity matrix

# calculating weights for all training examples [x(i)'s]
for j in range(m):
diff = point - training_data_x[j]
weights[j, j] = np.exp(diff * diff.T / (-2.0 * bandwidth**2))
weights[j, j] = np.exp(diff @ diff.T / (-2.0 * bandwidth**2))
return weights


def local_weight(
point: np.mat, training_data_x: np.mat, training_data_y: np.mat, bandwidth: float
) -> np.mat:
point: np.array,
training_data_x: np.array,
training_data_y: np.array,
bandwidth: float,
) -> np.array:
"""
Calculate the local weights using the weight_matrix function on training data.
Return the weighted matrix.
>>> local_weight(np.array([1., 1.]),np.mat([[16.99, 10.34], [21.01,23.68],
... [24.59,25.69]]),np.mat([[1.01, 1.66, 3.5]]), 0.6)
matrix([[0.00873174],
[0.08272556]])
>>> local_weight(
... np.array([1., 1.]),
... np.array([[16.99, 10.34], [21.01,23.68], [24.59,25.69]]),
... np.array([[1.01, 1.66, 3.5]]),
... 0.6
... )
array([[0.00873174],
[0.08272556]])
"""
weight = weighted_matrix(point, training_data_x, bandwidth)
w = (training_data_x.T * (weight * training_data_x)).I * (
training_data_x.T * weight * training_data_y.T
w = np.linalg.inv(training_data_x.T @ (weight @ training_data_x)) @ (
training_data_x.T @ weight @ training_data_y.T
)

return w


def local_weight_regression(
training_data_x: np.mat, training_data_y: np.mat, bandwidth: float
) -> np.mat:
training_data_x: np.array, training_data_y: np.array, bandwidth: float
) -> np.array:
"""
Calculate predictions for each data point on axis.
>>> local_weight_regression(np.mat([[16.99, 10.34], [21.01,23.68],
... [24.59,25.69]]),np.mat([[1.01, 1.66, 3.5]]), 0.6)
Calculate predictions for each data point on axis
>>> local_weight_regression(
... np.array([[16.99, 10.34], [21.01, 23.68], [24.59, 25.69]]),
... np.array([[1.01, 1.66, 3.5]]),
... 0.6
... )
array([1.07173261, 1.65970737, 3.50160179])
"""
m, n = np.shape(training_data_x)
m, _ = np.shape(training_data_x)
ypred = np.zeros(m)

for i, item in enumerate(training_data_x):
ypred[i] = item * local_weight(
ypred[i] = item @ local_weight(
item, training_data_x, training_data_y, bandwidth
)

return ypred


def load_data(dataset_name: str, cola_name: str, colb_name: str) -> np.mat:
def load_data(
dataset_name: str, cola_name: str, colb_name: str
) -> tuple[np.array, np.array, np.array, np.array]:
"""
Function used for loading data from the seaborn splitting into x and y points
Load data from seaborn and split it into x and y points
"""
import seaborn as sns

data = sns.load_dataset(dataset_name)
col_a = np.array(data[cola_name]) # total_bill
col_b = np.array(data[colb_name]) # tip

mcol_a = np.mat(col_a)
mcol_b = np.mat(col_b)
mcol_a = col_a.copy()
mcol_b = col_b.copy()

m = np.shape(mcol_b)[1]
one = np.ones((1, m), dtype=int)
one = np.ones(np.shape(mcol_b)[0], dtype=int)

# horizontal stacking
training_data_x = np.hstack((one.T, mcol_a.T))
# pairing elements of one and mcol_a
training_data_x = np.column_stack((one, mcol_a))

return training_data_x, mcol_b, col_a, col_b


def get_preds(training_data_x: np.mat, mcol_b: np.mat, tau: float) -> np.ndarray:
def get_preds(training_data_x: np.array, mcol_b: np.array, tau: float) -> np.array:
"""
Get predictions with minimum error for each training data
>>> get_preds(np.mat([[16.99, 10.34], [21.01,23.68],
... [24.59,25.69]]),np.mat([[1.01, 1.66, 3.5]]), 0.6)
>>> get_preds(
... np.array([[16.99, 10.34], [21.01, 23.68], [24.59, 25.69]]),
... np.array([[1.01, 1.66, 3.5]]),
... 0.6
... )
array([1.07173261, 1.65970737, 3.50160179])
"""
ypred = local_weight_regression(training_data_x, mcol_b, tau)
return ypred


def plot_preds(
training_data_x: np.mat,
predictions: np.ndarray,
col_x: np.ndarray,
col_y: np.ndarray,
training_data_x: np.array,
predictions: np.array,
col_x: np.array,
col_y: np.array,
cola_name: str,
colb_name: str,
) -> plt.plot:
"""
This function used to plot predictions and display the graph
Plot predictions and display the graph
"""
xsort = training_data_x.copy()
xsort.sort(axis=0)
Expand All @@ -128,6 +140,10 @@ def plot_preds(


if __name__ == "__main__":
import doctest

doctest.testmod()

training_data_x, mcol_b, col_a, col_b = load_data("tips", "total_bill", "tip")
predictions = get_preds(training_data_x, mcol_b, 0.5)
plot_preds(training_data_x, predictions, col_a, col_b, "total_bill", "tip")