summaryrefslogtreecommitdiff
path: root/python-sealion.spec
blob: e35e15c743e2858e2bee2e603a7a40775b2c7eff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
%global _empty_manifest_terminate_build 0
Name:		python-sealion
Version:	4.4.5
Release:	1
Summary:	SeaLion is a comprehensive machine learning and data science library for beginners and ml-engineers alike.
License:	Apache
URL:		https://github.com/anish-lakkapragada/SeaLion
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/e4/bc/c2f3c5d581eee26bf6ac0084145f5b722caaad00cd001ba5fc5db1eb4afa/sealion-4.4.5.tar.gz
BuildArch:	noarch

Requires:	python3-numpy
Requires:	python3-joblib
Requires:	python3-pandas
Requires:	python3-scipy
Requires:	python3-tqdm
Requires:	python3-multiprocess
Requires:	python3-seaborn
Requires:	python3-Cython
Requires:	python3-setuptools
Requires:	python3-matplotlib
Requires:	python3-dill
Requires:	python3-pytz
Requires:	python3-cycler
Requires:	python3-pillow
Requires:	python3-kiwisolver
Requires:	python3-pyparsing
Requires:	python3-six

%description
<p align="center">
    <img src="https://github.com/anish-lakkapragada/SeaLion/blob/main/logo.png?raw=true" width=300 height=300 >
</p>

# SeaLion

![python](https://img.shields.io/pypi/pyversions/sealion?color=blueviolet&style=plastic)
![License](https://img.shields.io/pypi/l/sealion?color=blue)
[![Documentation Status](https://readthedocs.org/projects/sealion/badge/?version=latest)](https://sealion.readthedocs.io/en/latest/?badge=latest)
![total lines](https://img.shields.io/tokei/lines/github/anish-lakkapragada/SeaLion?color=brightgreen)
![issues](https://img.shields.io/github/issues/anish-lakkapragada/SeaLion?color=yellow&style=plastic)
![pypi](https://img.shields.io/pypi/v/sealion?color=red&style=plastic)
![repo size](https://img.shields.io/github/repo-size/anish-lakkapragada/SeaLion?color=important)
![Deploy to PyPI](https://github.com/anish-lakkapragada/SeaLion/workflows/Deploy%20to%20PyPI/badge.svg)

SeaLion is designed to teach today's aspiring ml-engineers the popular
machine learning concepts of today in a way that gives both intuition and
ways of application. We do this through concise algorithms that do the job 
in the least jargon possible and examples to guide you through every step 
of the way. 

## Quick Demo

<p align="center">
    <img src="https://raw.githubusercontent.com/anish-lakkapragada/SeaLion/main/sealion_demo.gif" width = 580 height = 326>
    <br>
    <i>SeaLion in Action</i>
</p>

## General Usage

For most classifiers you can just do (we'll use Logistic Regression as an
example here) :

```python
from sealion.regression import LogisticRegression
log_reg = LogisticRegression()
```

to initialize, and then to train :

``` python
log_reg.fit(X_train, y_train) 
```

and for testing :

```python
y_pred = log_reg.predict(X_test) 
evaluation = log_reg.evaluate(X_test, y_test) 
```

For the unsupervised clustering algorithms you may do :

```python
from sealion.unsupervised_clustering import KMeans
kmeans = KMeans(k = 3)
```

and then to fit and predict :

```python
predictions = kmeans.fit_predict(X) 
```

Neural networks are a bit more complicated, so you may want to check an example
[here.](https://github.com/anish-lakkapragada/SeaLion/blob/main/examples/deep_learning_example.ipynb)

The syntax of the APIs was designed to be easy to use and familiar to most other ML libraries. This is to make sure both beginners and experts in the field
can comfortably use SeaLion. Of course, none of the source code uses other ML frameworks. 

## Testimonials, Stats, and Reddit Posts

"Super Expansive Python ML Library"
   -   [@Peter Washington](https://twitter.com/peter\_washing/status/1356766327541616644), Stanford PHD candidate in Bio-Engineering

[Analytics Vidhya calls SeaLion's algorithms **beginner-friendly**, **efficient**, and **concise**.](https://www.analyticsvidhya.com/blog/2021/02/6-open-source-data-science-projects-that-provide-an-edge-to-your-portfolio/)

Stats : 
   -   [**1,700+ downloads**](https://pypistats.org/packages/sealion)
   -   **300+ stars**
   -   **15,000 views on GitHub**
   -   **100+ forks/clones**

[r/Python Post](https://www.reddit.com/r/Python/comments/lf59bw/machine_learning_library_by_14year_old_sealion/)

[r/learningmachinelearning Post](https://www.reddit.com/r/learnmachinelearning/comments/lfv72l/a_set_of_jupyter_notebooks_to_help_you_understand/)
    
## Installation

The package is available on PyPI. Install like such :

``` shell
pip install sealion
```

SeaLion can only support Python 3, so please make sure you are on the
newest version.


## General Information

SeaLion was built by Anish Lakkapragada, a freshman in high school, starting in Thanksgiving of 2020
and has continued onto early 2021. The library is meant for beginners to
use when solving the standard libraries like iris, breast cancer, swiss
roll, the moons dataset, MNIST, etc. 
    
## Documentation

WE HAVE DOCS NOW! Thanks [@Patrick Huang](http://github.com/phuang1024)! All available here: [docs](https://sealion.readthedocs.io/). 
Also, use the examples to your advantage!

### Updates for v4.1 and up!
First things first - thank you for all of the support. The two reddit posts did much better than I expected (1.6k upvotes, about 200 comments) and I got a lot
of feedback and advice. Thank you to anyone who participated in r/Python or r/learnmachinelearning.

SeaLion has also taken off with the posts. We currently have had 3 issues (1 closed) and have reached 195 stars and 20 forks. I wasn't expecting this and I am grateful for everyone who has shown their appreciation for this library. 

Also some issues have popped up. Most of them can be easily solved by just deleting sealion manually (going into the folder where the source is and just deleting it - not pip uninstall) and then reinstalling the usual way, but feel free to put an issue up anytime. 

In versions 4.1+ we are hoping to polish the library more. Currently 4.1 comes with Bernoulli Naive Bayes and we also have added precision, recall, and the f1 metric in the utils module. We are hoping to include Gaussian Mixture Models and Batch Normalization in the future. Code examples for these new algorithms will be created within a day or two after release. Thank you! 

### Updates for v3.0.0!

SeaLion v3.0 and up has had a lot of major milestones.

The first thing is that all the code examples (in jupyter notebooks) for
basically all of the modules in sealion are put into the examples
directory. Most of them go over using actual datasets like iris, breast
cancer, moons, blobs, MNIST, etc. These were all built using v3.0.8
-hopefully that clears up any confusion. I hope you enjoy them.

Perhaps the biggest change in v3.0 is how we have changed the Cython
compilation. A quick primer on Cython if you are unfamiliar - you take
your python code (in .py files), change it and add some return types and
type declarations, put that in a .pyx file, and compile it to a .so
file. The .so file is then imported in the python module which you use.

The main bug fixed was that the .so file is actually specific to the
architecture of the user. I use macOS and compiled all my files in .so,
so prior v3.0 I would just give those .so files to anybody else. However
other architectures and OSs like Ubuntu would not be able to recognize
those files. Instead what we do know is just store the .pyx files
(universal for all computers) in the source code, and the first time you
import sealion all of those .pyx files will get compiled into .so files
(so they will work for whatever you are using.) This means the first
import will take about 40 seconds, but after that it will be as quick as
any other import.

## Machine Learning Algorithms

The machine learning algorithms of SeaLion are listed below. Please note
that the stucture of the listing isn't meant to resemble that of
SeaLion's APIs and that hyperlinked algorithms are for those that are new/niche. 
Of course, new algorithms are being made right now.

1.  **Deep Neural Networks**
    -   Optimizers
        -   Gradient Descent (and mini-batch gradient descent)
        -   Momentum Optimization w/ Nesterov Accelerated Gradient
        -   Stochastic gradient descent (w/ momentum + nesterov)
        -   AdaGrad
        -   RMSprop
        -   Adam
        -   Nadam
        -   [AdaBelief](https://arxiv.org/abs/2010.07468)
    -   Layers
        -   Flatten (turn 2D+ data to 2D matrices)
        -   Dense (fully-connected layers)
        -   Batch Normalization! 
    -   Regularization
        -   Dropout
    -   Activations
        -   ReLU
        -   Tanh
        -   Sigmoid
        -   Softmax
        -   Leaky ReLU
        -   [PReLU](https://arxiv.org/abs/1502.01852)
        -   ELU
        -   SELU
        -   Swish
    -   Loss Functions
        -   MSE (for regression)
        -   CrossEntropy (for classification)
    -   Transfer Learning
        -   Save weights (in a pickle file)
        -   reload them and then enter them into the same neural network
        -   this is so you don't have to start training from scratch

2.  **Regression**

    -   Linear Regression (Normal Equation, closed-form)
    -   Ridge Regression (L2 regularization, closed-form solution)
    -   Lasso Regression (L1 regularization)
    -   Elastic-Net Regression
    -   Logistic Regression
    -   Softmax Regression
    -   Exponential Regression
    -   Polynomial Regression

3.  **Dimensionality Reduction**
    -   Principal Component Analysis (PCA)
    -   t-distributed Stochastic Neighbor Embedding (tSNE)

4.  **Gaussian Mixture Models (GMMs)**
    - unsupervised clustering with "soft" predictions
    - anomaly detection
    - AIC & BIC calculation methods
   
5.  **Unsupervised Clustering**
    -   KMeans (w/ KMeans++)
    -   DBSCAN

6.  **Naive Bayes**
    -   Multinomial Naive Bayes
    -   Gaussian Naive Bayes
    -   Bernoulli Naive Bayes

7.  **Trees**
    -   Decision Tree (with max\_branches, min\_samples regularization +
        CART training)

8.  **Ensemble Learning**
    -   Random Forests
    -   Ensemble/Voting Classifier

9.  **Nearest Neighbors**
    -   k-nearest neighbors

10.  **Utils**
    -   one\_hot encoder function (one\_hot())
    -   plot confusion matrix function (confusion\_matrix())
    -   revert one hot encoding to 1D Array (revert\_one\_hot())
    -   revert softmax predictions to 1D Array (revert\_softmax())

## Algorithms in progress

Some of the algorithms we are working on right now.

1.  **Barnes Hut t-SNE** (please, please contribute for this one)

## Contributing

First, install the required libraries:
```bash
pip install -r requirements.txt
```

If you feel you can do something better than how it is right now in
SeaLion, please do! Believe me, you will find great joy in simplifying
my code (probably using numpy) and speeding it up. The major problem
right now is speed, some algorithms like PCA can handle 10000+ data
points, whereas tSNE is unscalable with O(n\^2) time complexity. We have
solved this problem with Cython + parallel processing (thanks joblib),
so algorithms (aside from neural networks) are working well with \<1000
points. Getting to the next level will need some help.

Most of the modules I use are numpy, pandas, joblib, and tqdm. I prefer
using less dependencies in the code, so please keep it down to a
minimum.

Other than that, thanks for contributing!

## Acknowledgements

Plenty of articles and people helped me a long way. Some of the tougher
questions I dealt with were Automatic Differentiation in neural
networks, in which this
[tutorial](https://www.youtube.com/watch?v=o64FV-ez6Gw) helped me. I
also got some help on the `O(n^2)` time complexity problem of the
denominator of t-SNE from this
[article](https://nlml.github.io/in-raw-numpy/in-raw-numpy-t-sne/) and
understood the mathematical derivation for the gradients (original paper
didn't go over it) from
[here](http://pages.di.unipi.it/errica/assets/files/sne_tsne.pdf). Also
I used the PCA method from handsonml so thanks for that too Aurélien
Géron. Lastly special thanks to Evan M. Kim and Peter Washington for
helping make the normal equation and cauchy distribution in tSNE make
sense. Also thanks to [@Kento Nishi](http://github.com/KentoNishi) for
helping me understand open-source.

## Feedback, comments, or questions

If you have any feedback or something you would like to tell me, please
do not hesitate to share! Feel free to comment here on github or reach
out to me through <anish.lakkapragada@gmail.com>!

©Anish Lakkapragada 2021




%package -n python3-sealion
Summary:	SeaLion is a comprehensive machine learning and data science library for beginners and ml-engineers alike.
Provides:	python-sealion
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-sealion
<p align="center">
    <img src="https://github.com/anish-lakkapragada/SeaLion/blob/main/logo.png?raw=true" width=300 height=300 >
</p>

# SeaLion

![python](https://img.shields.io/pypi/pyversions/sealion?color=blueviolet&style=plastic)
![License](https://img.shields.io/pypi/l/sealion?color=blue)
[![Documentation Status](https://readthedocs.org/projects/sealion/badge/?version=latest)](https://sealion.readthedocs.io/en/latest/?badge=latest)
![total lines](https://img.shields.io/tokei/lines/github/anish-lakkapragada/SeaLion?color=brightgreen)
![issues](https://img.shields.io/github/issues/anish-lakkapragada/SeaLion?color=yellow&style=plastic)
![pypi](https://img.shields.io/pypi/v/sealion?color=red&style=plastic)
![repo size](https://img.shields.io/github/repo-size/anish-lakkapragada/SeaLion?color=important)
![Deploy to PyPI](https://github.com/anish-lakkapragada/SeaLion/workflows/Deploy%20to%20PyPI/badge.svg)

SeaLion is designed to teach today's aspiring ml-engineers the popular
machine learning concepts of today in a way that gives both intuition and
ways of application. We do this through concise algorithms that do the job 
in the least jargon possible and examples to guide you through every step 
of the way. 

## Quick Demo

<p align="center">
    <img src="https://raw.githubusercontent.com/anish-lakkapragada/SeaLion/main/sealion_demo.gif" width = 580 height = 326>
    <br>
    <i>SeaLion in Action</i>
</p>

## General Usage

For most classifiers you can just do (we'll use Logistic Regression as an
example here) :

```python
from sealion.regression import LogisticRegression
log_reg = LogisticRegression()
```

to initialize, and then to train :

``` python
log_reg.fit(X_train, y_train) 
```

and for testing :

```python
y_pred = log_reg.predict(X_test) 
evaluation = log_reg.evaluate(X_test, y_test) 
```

For the unsupervised clustering algorithms you may do :

```python
from sealion.unsupervised_clustering import KMeans
kmeans = KMeans(k = 3)
```

and then to fit and predict :

```python
predictions = kmeans.fit_predict(X) 
```

Neural networks are a bit more complicated, so you may want to check an example
[here.](https://github.com/anish-lakkapragada/SeaLion/blob/main/examples/deep_learning_example.ipynb)

The syntax of the APIs was designed to be easy to use and familiar to most other ML libraries. This is to make sure both beginners and experts in the field
can comfortably use SeaLion. Of course, none of the source code uses other ML frameworks. 

## Testimonials, Stats, and Reddit Posts

"Super Expansive Python ML Library"
   -   [@Peter Washington](https://twitter.com/peter\_washing/status/1356766327541616644), Stanford PHD candidate in Bio-Engineering

[Analytics Vidhya calls SeaLion's algorithms **beginner-friendly**, **efficient**, and **concise**.](https://www.analyticsvidhya.com/blog/2021/02/6-open-source-data-science-projects-that-provide-an-edge-to-your-portfolio/)

Stats : 
   -   [**1,700+ downloads**](https://pypistats.org/packages/sealion)
   -   **300+ stars**
   -   **15,000 views on GitHub**
   -   **100+ forks/clones**

[r/Python Post](https://www.reddit.com/r/Python/comments/lf59bw/machine_learning_library_by_14year_old_sealion/)

[r/learningmachinelearning Post](https://www.reddit.com/r/learnmachinelearning/comments/lfv72l/a_set_of_jupyter_notebooks_to_help_you_understand/)
    
## Installation

The package is available on PyPI. Install like such :

``` shell
pip install sealion
```

SeaLion can only support Python 3, so please make sure you are on the
newest version.


## General Information

SeaLion was built by Anish Lakkapragada, a freshman in high school, starting in Thanksgiving of 2020
and has continued onto early 2021. The library is meant for beginners to
use when solving the standard libraries like iris, breast cancer, swiss
roll, the moons dataset, MNIST, etc. 
    
## Documentation

WE HAVE DOCS NOW! Thanks [@Patrick Huang](http://github.com/phuang1024)! All available here: [docs](https://sealion.readthedocs.io/). 
Also, use the examples to your advantage!

### Updates for v4.1 and up!
First things first - thank you for all of the support. The two reddit posts did much better than I expected (1.6k upvotes, about 200 comments) and I got a lot
of feedback and advice. Thank you to anyone who participated in r/Python or r/learnmachinelearning.

SeaLion has also taken off with the posts. We currently have had 3 issues (1 closed) and have reached 195 stars and 20 forks. I wasn't expecting this and I am grateful for everyone who has shown their appreciation for this library. 

Also some issues have popped up. Most of them can be easily solved by just deleting sealion manually (going into the folder where the source is and just deleting it - not pip uninstall) and then reinstalling the usual way, but feel free to put an issue up anytime. 

In versions 4.1+ we are hoping to polish the library more. Currently 4.1 comes with Bernoulli Naive Bayes and we also have added precision, recall, and the f1 metric in the utils module. We are hoping to include Gaussian Mixture Models and Batch Normalization in the future. Code examples for these new algorithms will be created within a day or two after release. Thank you! 

### Updates for v3.0.0!

SeaLion v3.0 and up has had a lot of major milestones.

The first thing is that all the code examples (in jupyter notebooks) for
basically all of the modules in sealion are put into the examples
directory. Most of them go over using actual datasets like iris, breast
cancer, moons, blobs, MNIST, etc. These were all built using v3.0.8
-hopefully that clears up any confusion. I hope you enjoy them.

Perhaps the biggest change in v3.0 is how we have changed the Cython
compilation. A quick primer on Cython if you are unfamiliar - you take
your python code (in .py files), change it and add some return types and
type declarations, put that in a .pyx file, and compile it to a .so
file. The .so file is then imported in the python module which you use.

The main bug fixed was that the .so file is actually specific to the
architecture of the user. I use macOS and compiled all my files in .so,
so prior v3.0 I would just give those .so files to anybody else. However
other architectures and OSs like Ubuntu would not be able to recognize
those files. Instead what we do know is just store the .pyx files
(universal for all computers) in the source code, and the first time you
import sealion all of those .pyx files will get compiled into .so files
(so they will work for whatever you are using.) This means the first
import will take about 40 seconds, but after that it will be as quick as
any other import.

## Machine Learning Algorithms

The machine learning algorithms of SeaLion are listed below. Please note
that the stucture of the listing isn't meant to resemble that of
SeaLion's APIs and that hyperlinked algorithms are for those that are new/niche. 
Of course, new algorithms are being made right now.

1.  **Deep Neural Networks**
    -   Optimizers
        -   Gradient Descent (and mini-batch gradient descent)
        -   Momentum Optimization w/ Nesterov Accelerated Gradient
        -   Stochastic gradient descent (w/ momentum + nesterov)
        -   AdaGrad
        -   RMSprop
        -   Adam
        -   Nadam
        -   [AdaBelief](https://arxiv.org/abs/2010.07468)
    -   Layers
        -   Flatten (turn 2D+ data to 2D matrices)
        -   Dense (fully-connected layers)
        -   Batch Normalization! 
    -   Regularization
        -   Dropout
    -   Activations
        -   ReLU
        -   Tanh
        -   Sigmoid
        -   Softmax
        -   Leaky ReLU
        -   [PReLU](https://arxiv.org/abs/1502.01852)
        -   ELU
        -   SELU
        -   Swish
    -   Loss Functions
        -   MSE (for regression)
        -   CrossEntropy (for classification)
    -   Transfer Learning
        -   Save weights (in a pickle file)
        -   reload them and then enter them into the same neural network
        -   this is so you don't have to start training from scratch

2.  **Regression**

    -   Linear Regression (Normal Equation, closed-form)
    -   Ridge Regression (L2 regularization, closed-form solution)
    -   Lasso Regression (L1 regularization)
    -   Elastic-Net Regression
    -   Logistic Regression
    -   Softmax Regression
    -   Exponential Regression
    -   Polynomial Regression

3.  **Dimensionality Reduction**
    -   Principal Component Analysis (PCA)
    -   t-distributed Stochastic Neighbor Embedding (tSNE)

4.  **Gaussian Mixture Models (GMMs)**
    - unsupervised clustering with "soft" predictions
    - anomaly detection
    - AIC & BIC calculation methods
   
5.  **Unsupervised Clustering**
    -   KMeans (w/ KMeans++)
    -   DBSCAN

6.  **Naive Bayes**
    -   Multinomial Naive Bayes
    -   Gaussian Naive Bayes
    -   Bernoulli Naive Bayes

7.  **Trees**
    -   Decision Tree (with max\_branches, min\_samples regularization +
        CART training)

8.  **Ensemble Learning**
    -   Random Forests
    -   Ensemble/Voting Classifier

9.  **Nearest Neighbors**
    -   k-nearest neighbors

10.  **Utils**
    -   one\_hot encoder function (one\_hot())
    -   plot confusion matrix function (confusion\_matrix())
    -   revert one hot encoding to 1D Array (revert\_one\_hot())
    -   revert softmax predictions to 1D Array (revert\_softmax())

## Algorithms in progress

Some of the algorithms we are working on right now.

1.  **Barnes Hut t-SNE** (please, please contribute for this one)

## Contributing

First, install the required libraries:
```bash
pip install -r requirements.txt
```

If you feel you can do something better than how it is right now in
SeaLion, please do! Believe me, you will find great joy in simplifying
my code (probably using numpy) and speeding it up. The major problem
right now is speed, some algorithms like PCA can handle 10000+ data
points, whereas tSNE is unscalable with O(n\^2) time complexity. We have
solved this problem with Cython + parallel processing (thanks joblib),
so algorithms (aside from neural networks) are working well with \<1000
points. Getting to the next level will need some help.

Most of the modules I use are numpy, pandas, joblib, and tqdm. I prefer
using less dependencies in the code, so please keep it down to a
minimum.

Other than that, thanks for contributing!

## Acknowledgements

Plenty of articles and people helped me a long way. Some of the tougher
questions I dealt with were Automatic Differentiation in neural
networks, in which this
[tutorial](https://www.youtube.com/watch?v=o64FV-ez6Gw) helped me. I
also got some help on the `O(n^2)` time complexity problem of the
denominator of t-SNE from this
[article](https://nlml.github.io/in-raw-numpy/in-raw-numpy-t-sne/) and
understood the mathematical derivation for the gradients (original paper
didn't go over it) from
[here](http://pages.di.unipi.it/errica/assets/files/sne_tsne.pdf). Also
I used the PCA method from handsonml so thanks for that too Aurélien
Géron. Lastly special thanks to Evan M. Kim and Peter Washington for
helping make the normal equation and cauchy distribution in tSNE make
sense. Also thanks to [@Kento Nishi](http://github.com/KentoNishi) for
helping me understand open-source.

## Feedback, comments, or questions

If you have any feedback or something you would like to tell me, please
do not hesitate to share! Feel free to comment here on github or reach
out to me through <anish.lakkapragada@gmail.com>!

©Anish Lakkapragada 2021




%package help
Summary:	Development documents and examples for sealion
Provides:	python3-sealion-doc
%description help
<p align="center">
    <img src="https://github.com/anish-lakkapragada/SeaLion/blob/main/logo.png?raw=true" width=300 height=300 >
</p>

# SeaLion

![python](https://img.shields.io/pypi/pyversions/sealion?color=blueviolet&style=plastic)
![License](https://img.shields.io/pypi/l/sealion?color=blue)
[![Documentation Status](https://readthedocs.org/projects/sealion/badge/?version=latest)](https://sealion.readthedocs.io/en/latest/?badge=latest)
![total lines](https://img.shields.io/tokei/lines/github/anish-lakkapragada/SeaLion?color=brightgreen)
![issues](https://img.shields.io/github/issues/anish-lakkapragada/SeaLion?color=yellow&style=plastic)
![pypi](https://img.shields.io/pypi/v/sealion?color=red&style=plastic)
![repo size](https://img.shields.io/github/repo-size/anish-lakkapragada/SeaLion?color=important)
![Deploy to PyPI](https://github.com/anish-lakkapragada/SeaLion/workflows/Deploy%20to%20PyPI/badge.svg)

SeaLion is designed to teach today's aspiring ml-engineers the popular
machine learning concepts of today in a way that gives both intuition and
ways of application. We do this through concise algorithms that do the job 
in the least jargon possible and examples to guide you through every step 
of the way. 

## Quick Demo

<p align="center">
    <img src="https://raw.githubusercontent.com/anish-lakkapragada/SeaLion/main/sealion_demo.gif" width = 580 height = 326>
    <br>
    <i>SeaLion in Action</i>
</p>

## General Usage

For most classifiers you can just do (we'll use Logistic Regression as an
example here) :

```python
from sealion.regression import LogisticRegression
log_reg = LogisticRegression()
```

to initialize, and then to train :

``` python
log_reg.fit(X_train, y_train) 
```

and for testing :

```python
y_pred = log_reg.predict(X_test) 
evaluation = log_reg.evaluate(X_test, y_test) 
```

For the unsupervised clustering algorithms you may do :

```python
from sealion.unsupervised_clustering import KMeans
kmeans = KMeans(k = 3)
```

and then to fit and predict :

```python
predictions = kmeans.fit_predict(X) 
```

Neural networks are a bit more complicated, so you may want to check an example
[here.](https://github.com/anish-lakkapragada/SeaLion/blob/main/examples/deep_learning_example.ipynb)

The syntax of the APIs was designed to be easy to use and familiar to most other ML libraries. This is to make sure both beginners and experts in the field
can comfortably use SeaLion. Of course, none of the source code uses other ML frameworks. 

## Testimonials, Stats, and Reddit Posts

"Super Expansive Python ML Library"
   -   [@Peter Washington](https://twitter.com/peter\_washing/status/1356766327541616644), Stanford PHD candidate in Bio-Engineering

[Analytics Vidhya calls SeaLion's algorithms **beginner-friendly**, **efficient**, and **concise**.](https://www.analyticsvidhya.com/blog/2021/02/6-open-source-data-science-projects-that-provide-an-edge-to-your-portfolio/)

Stats : 
   -   [**1,700+ downloads**](https://pypistats.org/packages/sealion)
   -   **300+ stars**
   -   **15,000 views on GitHub**
   -   **100+ forks/clones**

[r/Python Post](https://www.reddit.com/r/Python/comments/lf59bw/machine_learning_library_by_14year_old_sealion/)

[r/learningmachinelearning Post](https://www.reddit.com/r/learnmachinelearning/comments/lfv72l/a_set_of_jupyter_notebooks_to_help_you_understand/)
    
## Installation

The package is available on PyPI. Install like such :

``` shell
pip install sealion
```

SeaLion can only support Python 3, so please make sure you are on the
newest version.


## General Information

SeaLion was built by Anish Lakkapragada, a freshman in high school, starting in Thanksgiving of 2020
and has continued onto early 2021. The library is meant for beginners to
use when solving the standard libraries like iris, breast cancer, swiss
roll, the moons dataset, MNIST, etc. 
    
## Documentation

WE HAVE DOCS NOW! Thanks [@Patrick Huang](http://github.com/phuang1024)! All available here: [docs](https://sealion.readthedocs.io/). 
Also, use the examples to your advantage!

### Updates for v4.1 and up!
First things first - thank you for all of the support. The two reddit posts did much better than I expected (1.6k upvotes, about 200 comments) and I got a lot
of feedback and advice. Thank you to anyone who participated in r/Python or r/learnmachinelearning.

SeaLion has also taken off with the posts. We currently have had 3 issues (1 closed) and have reached 195 stars and 20 forks. I wasn't expecting this and I am grateful for everyone who has shown their appreciation for this library. 

Also some issues have popped up. Most of them can be easily solved by just deleting sealion manually (going into the folder where the source is and just deleting it - not pip uninstall) and then reinstalling the usual way, but feel free to put an issue up anytime. 

In versions 4.1+ we are hoping to polish the library more. Currently 4.1 comes with Bernoulli Naive Bayes and we also have added precision, recall, and the f1 metric in the utils module. We are hoping to include Gaussian Mixture Models and Batch Normalization in the future. Code examples for these new algorithms will be created within a day or two after release. Thank you! 

### Updates for v3.0.0!

SeaLion v3.0 and up has had a lot of major milestones.

The first thing is that all the code examples (in jupyter notebooks) for
basically all of the modules in sealion are put into the examples
directory. Most of them go over using actual datasets like iris, breast
cancer, moons, blobs, MNIST, etc. These were all built using v3.0.8
-hopefully that clears up any confusion. I hope you enjoy them.

Perhaps the biggest change in v3.0 is how we have changed the Cython
compilation. A quick primer on Cython if you are unfamiliar - you take
your python code (in .py files), change it and add some return types and
type declarations, put that in a .pyx file, and compile it to a .so
file. The .so file is then imported in the python module which you use.

The main bug fixed was that the .so file is actually specific to the
architecture of the user. I use macOS and compiled all my files in .so,
so prior v3.0 I would just give those .so files to anybody else. However
other architectures and OSs like Ubuntu would not be able to recognize
those files. Instead what we do know is just store the .pyx files
(universal for all computers) in the source code, and the first time you
import sealion all of those .pyx files will get compiled into .so files
(so they will work for whatever you are using.) This means the first
import will take about 40 seconds, but after that it will be as quick as
any other import.

## Machine Learning Algorithms

The machine learning algorithms of SeaLion are listed below. Please note
that the stucture of the listing isn't meant to resemble that of
SeaLion's APIs and that hyperlinked algorithms are for those that are new/niche. 
Of course, new algorithms are being made right now.

1.  **Deep Neural Networks**
    -   Optimizers
        -   Gradient Descent (and mini-batch gradient descent)
        -   Momentum Optimization w/ Nesterov Accelerated Gradient
        -   Stochastic gradient descent (w/ momentum + nesterov)
        -   AdaGrad
        -   RMSprop
        -   Adam
        -   Nadam
        -   [AdaBelief](https://arxiv.org/abs/2010.07468)
    -   Layers
        -   Flatten (turn 2D+ data to 2D matrices)
        -   Dense (fully-connected layers)
        -   Batch Normalization! 
    -   Regularization
        -   Dropout
    -   Activations
        -   ReLU
        -   Tanh
        -   Sigmoid
        -   Softmax
        -   Leaky ReLU
        -   [PReLU](https://arxiv.org/abs/1502.01852)
        -   ELU
        -   SELU
        -   Swish
    -   Loss Functions
        -   MSE (for regression)
        -   CrossEntropy (for classification)
    -   Transfer Learning
        -   Save weights (in a pickle file)
        -   reload them and then enter them into the same neural network
        -   this is so you don't have to start training from scratch

2.  **Regression**

    -   Linear Regression (Normal Equation, closed-form)
    -   Ridge Regression (L2 regularization, closed-form solution)
    -   Lasso Regression (L1 regularization)
    -   Elastic-Net Regression
    -   Logistic Regression
    -   Softmax Regression
    -   Exponential Regression
    -   Polynomial Regression

3.  **Dimensionality Reduction**
    -   Principal Component Analysis (PCA)
    -   t-distributed Stochastic Neighbor Embedding (tSNE)

4.  **Gaussian Mixture Models (GMMs)**
    - unsupervised clustering with "soft" predictions
    - anomaly detection
    - AIC & BIC calculation methods
   
5.  **Unsupervised Clustering**
    -   KMeans (w/ KMeans++)
    -   DBSCAN

6.  **Naive Bayes**
    -   Multinomial Naive Bayes
    -   Gaussian Naive Bayes
    -   Bernoulli Naive Bayes

7.  **Trees**
    -   Decision Tree (with max\_branches, min\_samples regularization +
        CART training)

8.  **Ensemble Learning**
    -   Random Forests
    -   Ensemble/Voting Classifier

9.  **Nearest Neighbors**
    -   k-nearest neighbors

10.  **Utils**
    -   one\_hot encoder function (one\_hot())
    -   plot confusion matrix function (confusion\_matrix())
    -   revert one hot encoding to 1D Array (revert\_one\_hot())
    -   revert softmax predictions to 1D Array (revert\_softmax())

## Algorithms in progress

Some of the algorithms we are working on right now.

1.  **Barnes Hut t-SNE** (please, please contribute for this one)

## Contributing

First, install the required libraries:
```bash
pip install -r requirements.txt
```

If you feel you can do something better than how it is right now in
SeaLion, please do! Believe me, you will find great joy in simplifying
my code (probably using numpy) and speeding it up. The major problem
right now is speed, some algorithms like PCA can handle 10000+ data
points, whereas tSNE is unscalable with O(n\^2) time complexity. We have
solved this problem with Cython + parallel processing (thanks joblib),
so algorithms (aside from neural networks) are working well with \<1000
points. Getting to the next level will need some help.

Most of the modules I use are numpy, pandas, joblib, and tqdm. I prefer
using less dependencies in the code, so please keep it down to a
minimum.

Other than that, thanks for contributing!

## Acknowledgements

Plenty of articles and people helped me a long way. Some of the tougher
questions I dealt with were Automatic Differentiation in neural
networks, in which this
[tutorial](https://www.youtube.com/watch?v=o64FV-ez6Gw) helped me. I
also got some help on the `O(n^2)` time complexity problem of the
denominator of t-SNE from this
[article](https://nlml.github.io/in-raw-numpy/in-raw-numpy-t-sne/) and
understood the mathematical derivation for the gradients (original paper
didn't go over it) from
[here](http://pages.di.unipi.it/errica/assets/files/sne_tsne.pdf). Also
I used the PCA method from handsonml so thanks for that too Aurélien
Géron. Lastly special thanks to Evan M. Kim and Peter Washington for
helping make the normal equation and cauchy distribution in tSNE make
sense. Also thanks to [@Kento Nishi](http://github.com/KentoNishi) for
helping me understand open-source.

## Feedback, comments, or questions

If you have any feedback or something you would like to tell me, please
do not hesitate to share! Feel free to comment here on github or reach
out to me through <anish.lakkapragada@gmail.com>!

©Anish Lakkapragada 2021




%prep
%autosetup -n sealion-4.4.5

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-sealion -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Mon May 15 2023 Python_Bot <Python_Bot@openeuler.org> - 4.4.5-1
- Package Spec generated