Skip to content

Commit fdaa32d

Browse files
committed
Preparing the tabular datasets via Scikit-learn's toy datasets module
1 parent 8992194 commit fdaa32d

File tree

8 files changed

+253
-9
lines changed

8 files changed

+253
-9
lines changed

.idea/FromCodingToDeepLearning.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fundamentals/vectorization_based_programming/vectorization.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# Author: Nguyen Truong Thinh
22
# Contact me: [email protected] || +84393280504
33
# Programming via Vectorization
4+
45
import jax.numpy as jnp
6+
import n1 as n1
7+
import n2
8+
import n3
59
import numpy as np
10+
import timeit
11+
import r3
612
from jax import jit
713

814

@@ -52,8 +58,8 @@ def cov_loops(x_matrix):
5258
print(np.sum((X1 - X2) * (X1 - X2)))
5359

5460

55-
# %timeit clip_loops(X)
56-
# %timeit np.clip(X, 0, 1)
61+
timeit.timeit(clip_loops(X))
62+
timeit.timeit(np.clip(X, 0, 1))
5763

5864

5965
def cov_vec_cpu(x_matrix):
@@ -71,18 +77,18 @@ def cov_jax_gpu(x_matrix):
7177
# Compare
7278
a_matrix = np.random.normal(size=(300, 784))
7379

74-
# %timeit -n1 -r1 cov_loops(a_matrix)
75-
# %timeit -n2 -r2 cov_vec_cpu(a_matrix)
76-
# %timeit -n3 -r3 cov_jax_gpu(a_matrix)
80+
# timeit.timeit(-n1, -r1, cov_loops(a_matrix))
81+
# timeit.timeit(-n2, -r2, cov_vec_cpu(a_matrix))
82+
# timeit.timeit(-n3, -r3, cov_jax_gpu(a_matrix))
7783
b_matrix = cov_loops(a_matrix)
7884
c_matrix = cov_vec_cpu(a_matrix)
7985
d_matrix = cov_jax_gpu(a_matrix)
8086
print(np.trace(b_matrix), np.trace(c_matrix), np.trace(d_matrix))
8187

8288
a_matrix = np.random.normal(size=(5000, 784))
8389

84-
# %timeit cov_vec_cpu(a_matrix)
85-
# %timeit cov_jax_gpu(a_matrix)
90+
timeit.timeit(cov_vec_cpu(a_matrix))
91+
timeit.timeit(cov_jax_gpu(a_matrix))
8692

8793
c_matrix = cov_vec_cpu(a_matrix)
8894
d_matrix = cov_jax_gpu(a_matrix)
91.3 KB
Loading
47 KB
Loading
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
alcohol,malic_acid,ash,alcalinity_of_ash,magnesium,total_phenols,flavanoids,nonflavanoid_phenols,proanthocyanins,color_intensity,hue,od280/od315_of_diluted_wines,proline,target
2+
0.5,0.40909090909090917,0.716577540106952,0.5360824742268042,0.2826086956521739,0.1931034482758621,0.033755274261603366,0.7547169811320755,0.10725552050473187,0.28327645051194533,0.23577235772357727,0.380952380952381,0.2296718972895863,2
3+
0.34473684210526323,0.3379446640316206,0.5882352941176471,0.5360824742268042,0.30434782608695654,0.5448275862068966,0.3734177215189873,0.39622641509433965,0.2839116719242903,0.1296928327645051,0.2601626016260163,0.7728937728937728,0.11412268188302425,1
4+
0.744736842105263,0.15217391304347827,0.7005347593582887,0.7422680412371134,0.17391304347826086,0.6793103448275863,0.5316455696202531,0.15094339622641506,0.46056782334384866,0.17918088737201363,0.7154471544715448,0.6923076923076924,0.09415121255349501,1
5+
0.5894736842105263,0.699604743083004,0.4812834224598929,0.48453608247422686,0.5434782608695652,0.21034482758620693,0.07383966244725737,0.5660377358490566,0.2965299684542587,0.7610921501706485,0.08943089430894308,0.10622710622710624,0.39728958630527816,2
6+
0.3210526315789475,0.7865612648221344,0.6310160427807486,0.5360824742268042,0.20652173913043478,0.1379310344827586,0.02742616033755273,0.7547169811320755,0.12302839116719246,0.21928327645051196,0.21951219512195125,0.0,0.3152639087018545,2
7+
0.43947368421052624,0.6185770750988142,0.5561497326203207,0.6391752577319588,0.33695652173913043,0.6379310344827587,0.4662447257383966,0.5660377358490566,0.4858044164037855,0.1100682593856655,0.5772357723577236,0.6813186813186812,0.13195435092724678,1
8+
0.3526315789473683,0.1758893280632411,0.5026737967914437,0.7164948453608249,0.1956521739130435,0.4275862068965518,0.4451476793248946,0.5094339622641509,0.47003154574132494,0.07167235494880546,0.33333333333333337,0.553113553113553,0.0456490727532097,1
9+
0.8394736842105265,0.6422924901185771,0.6149732620320855,0.13402061855670103,0.6304347826086957,0.6965517241379311,0.569620253164557,0.1320754716981132,0.526813880126183,0.32593856655290093,0.33333333333333337,0.8278388278388278,0.3437945791726106,0
10+
0.43684210526315786,0.15612648221343875,0.4812834224598929,0.520618556701031,0.10869565217391304,0.1379310344827586,0.2362869198312236,0.8490566037735848,0.3817034700315458,0.1510238907849829,0.3902439024390244,0.2893772893772894,0.15477888730385164,1
11+
0.6710526315789475,0.18181818181818182,0.53475935828877,0.4381443298969073,0.391304347826087,0.6482758620689655,0.6012658227848101,0.16981132075471697,0.4858044164037855,0.47952218430034127,0.4959349593495936,0.5897435897435896,0.8823109843081313,0
12+
0.7657894736842105,0.1956521739130435,0.48663101604278075,0.35051546391752575,0.41304347826086957,0.6551724137931034,0.6751054852320675,0.3584905660377358,0.526813880126183,0.6501706484641638,0.5203252032520326,0.6703296703296704,0.7004279600570613,0
13+
0.8078947368421052,0.2529644268774704,0.5561497326203207,0.42268041237113413,0.358695652173913,0.6103448275862069,0.5443037974683544,0.3584905660377358,0.6214511041009464,0.4197952218430034,0.47967479674796754,0.5421245421245421,0.557774607703281,0
14+
0.3210526315789475,0.1956521739130435,0.40641711229946526,0.43298969072164956,0.10869565217391304,0.23103448275862068,0.3565400843881856,0.45283018867924524,0.38485804416403785,0.18088737201365188,0.42276422764227645,0.6959706959706959,0.16547788873038516,1
15+
0.25526315789473697,0.03557312252964428,0.3422459893048128,0.43298969072164956,0.17391304347826086,0.496551724137931,0.40506329113924044,0.320754716981132,0.3217665615141956,0.10409556313993173,0.7317073170731707,0.6776556776556777,0.0,1
16+
0.2973684210526317,0.17193675889328067,0.5080213903743316,0.6288659793814434,0.21739130434782608,0.27586206896551724,0.28481012658227844,0.5660377358490566,0.36277602523659314,0.09982935153583619,0.6910569105691058,0.36263736263736257,0.15477888730385164,1
17+
0.7394736842105263,0.6679841897233202,0.5454545454545454,0.4587628865979382,0.20652173913043478,0.2827586206896552,0.10337552742616032,0.660377358490566,0.36277602523659314,0.6595563139931739,0.07317073170731705,0.1355311355311355,0.14407988587731813,2
18+
0.5473684210526315,0.22924901185770752,0.7433155080213903,0.7680412371134021,0.5,0.42068965517241386,0.19831223628691982,0.24528301886792453,0.36277602523659314,0.49658703071672344,0.10569105691056911,0.021978021978021997,0.10485021398002853,2
19+
0.5473684210526315,0.05335968379446641,0.18181818181818174,0.22680412371134023,0.08695652173913043,0.6896551724137931,0.5991561181434599,0.24528301886792453,0.5899053627760252,0.3430034129692832,0.5203252032520326,0.6996336996336997,0.15977175463623394,1
20+
0.45789473684210524,0.3260869565217392,0.4919786096256683,0.4587628865979382,0.17391304347826086,0.14137931034482756,0.03586497890295358,0.660377358490566,0.07255520504731862,0.7354947952218429,0.07317073170731705,0.13186813186813182,0.1369472182596291,2
21+
0.5710526315789473,0.2055335968379447,0.4171122994652407,0.030927835051546376,0.32608695652173914,0.5758620689655173,0.510548523206751,0.24528301886792453,0.2744479495268139,0.26450511945392485,0.46341463414634154,0.7802197802197802,0.550641940085592,0
22+
0.5815789473684212,0.36561264822134387,0.8074866310160428,0.5360824742268042,0.5217391304347826,0.6275862068965516,0.4957805907172996,0.49056603773584906,0.4447949526813881,0.2593856655290102,0.4552845528455285,0.6080586080586081,0.325962910128388,0
23+
0.8236842105263158,0.34980237154150196,0.5989304812834224,0.48453608247422686,0.22826086956521738,0.24137931034482757,0.07594936708860758,0.5849056603773585,0.26182965299684546,0.7184300341296928,0.11382113821138212,0.16117216117216115,0.2724679029957204,2
24+
0.6947368421052632,0.10079051383399211,0.29946524064171115,0.3814432989690722,0.2608695652173913,0.3862068965517242,0.3059071729957806,0.3584905660377358,0.10094637223974764,0.21501706484641633,0.6097560975609756,0.4358974358974359,0.25106990014265335,1
25+
0.31052631578947404,0.08893280632411067,0.2085561497326203,0.31958762886597947,0.8804347826086957,0.30000000000000004,0.19831223628691982,0.018867924528301903,0.6593059936908517,0.13395904436860068,0.6504065040650407,0.6593406593406593,0.31383737517831667,1
26+
0.8842105263157897,0.22332015810276684,0.5828877005347595,0.2061855670103093,0.2826086956521739,0.5241379310344828,0.459915611814346,0.320754716981132,0.49526813880126186,0.3387372013651877,0.4390243902439025,0.8461538461538461,0.7218259629101283,0
27+
0.5315789473684213,0.20355731225296445,0.39572192513368987,0.3298969072164949,0.40217391304347827,0.6965517241379311,0.5611814345991561,0.28301886792452835,0.5110410094637223,0.3208191126279863,0.3252032520325204,0.761904761904762,0.43295292439372324,0
28+
0.8368421052631582,0.6521739130434783,0.5775401069518716,0.42783505154639173,0.44565217391304346,0.6448275862068966,0.4873417721518987,0.320754716981132,0.26498422712933756,0.3378839590443686,0.3170731707317073,0.7545787545787546,0.572039942938659,0
29+
0.11315789473684247,0.5928853754940712,0.2459893048128342,0.4587628865979382,0.40217391304347827,0.7586206896551725,0.47257383966244726,0.2075471698113207,1.0,0.13822525597269622,0.21951219512195125,0.5641025641025641,0.20256776034236804,1
30+
0.5263157894736841,0.031620553359683806,0.18716577540106946,0.2783505154639176,0.17391304347826086,0.33448275862068966,0.3565400843881856,0.2075471698113207,0.3312302839116719,0.28327645051194533,0.5772357723577236,0.4432234432234432,0.08131241084165478,1
31+
0.15526315789473677,0.24703557312252966,0.4919786096256683,0.3814432989690722,0.30434782608695654,0.703448275862069,0.40506329113924044,0.07547169811320756,0.2965299684542587,0.16808873720136516,0.5528455284552846,0.6190476190476191,0.04778887303851641,1
32+
0.8710526315789473,0.1857707509881423,0.716577540106952,0.7422680412371134,0.30434782608695654,0.6275862068965516,0.20464135021097046,0.7547169811320755,0.7223974763406941,1.0,0.07317073170731705,0.25274725274725274,0.2724679029957204,2
33+
0.13947368421052658,0.25889328063241107,1.0,0.922680412371134,0.532608695652174,0.7586206896551725,1.0,0.641509433962264,0.46056782334384866,0.4027303754266211,0.3658536585365854,0.8864468864468864,0.13338088445078458,1
34+
0.21315789473684219,0.029644268774703563,0.6524064171122995,0.3814432989690722,0.2608695652173913,0.42068965517241386,0.3945147679324894,0.16981132075471697,0.6119873817034701,0.1510238907849829,0.2520325203252033,0.663003663003663,0.17261055634807418,1
35+
0.755263157894737,0.1857707509881423,0.40641711229946526,0.2783505154639176,0.33695652173913043,0.7310344827586207,0.6434599156118144,0.15094339622641506,0.5457413249211357,0.4112627986348122,0.3495934959349594,0.7545787545787546,0.5042796005706134,0
36+
0.6473684210526317,0.18181818181818182,0.47058823529411775,0.6907216494845362,0.18478260869565216,0.31034482758620685,0.3164556962025316,0.2641509433962264,0.19558359621451107,0.2098976109215017,0.4065040650406504,0.553113553113553,0.1383737517831669,1
37+
0.6026315789473685,0.4940711462450593,0.5454545454545454,0.5618556701030929,0.2391304347826087,0.3275862068965517,0.08860759493670885,0.6037735849056604,0.26498422712933756,0.6092150170648464,0.05691056910569111,0.12820512820512825,0.2653352353780314,2
38+
0.4789473684210526,0.5000000000000001,0.6524064171122995,0.5876288659793815,0.391304347826087,0.23103448275862068,0.054852320675105475,0.8867924528301886,0.17350157728706628,0.3668941979522184,0.3170731707317073,0.30769230769230765,0.20827389443651925,2
39+
0.27631578947368435,0.1284584980237154,0.6096256684491979,0.6134020618556701,0.15217391304347827,0.5448275862068966,0.4113924050632911,0.5660377358490566,0.1987381703470032,0.13822525597269622,0.3658536585365854,0.7032967032967032,0.07631954350927246,1
40+
0.7052631578947371,0.2213438735177866,0.53475935828877,0.30927835051546404,0.33695652173913043,0.5620689655172414,0.5358649789029536,0.2641509433962264,0.4037854889589906,0.21501706484641633,0.5121951219512196,1.0,0.5399429386590585,0
41+
0.7973684210526317,0.27865612648221344,0.6684491978609625,0.36082474226804134,0.5543478260869565,0.5586206896551724,0.45780590717299574,0.33962264150943394,0.26498422712933756,0.3216723549488054,0.47154471544715454,0.8461538461538461,0.7253922967189729,0
42+
0.46315789473684194,0.3814229249011858,0.5989304812834224,0.5876288659793815,0.45652173913043476,0.1724137931034483,0.2151898734177215,0.2075471698113207,0.2681388012618297,0.8122866894197953,0.0,0.07326007326007325,0.14407988587731813,2
43+
0.6842105263157897,0.2114624505928854,0.716577540106952,0.3402061855670103,0.45652173913043476,0.6448275862068966,0.5421940928270043,0.320754716981132,0.3312302839116719,0.5136518771331058,0.6504065040650407,0.5897435897435896,0.7360912981455064,0
44+
0.7131578947368422,0.18379446640316205,0.4759358288770053,0.29896907216494845,0.5217391304347826,0.5586206896551724,0.540084388185654,0.15094339622641506,0.3817034700315458,0.3899317406143344,0.3577235772357724,0.706959706959707,0.557774607703281,0
45+
0.4868421052631582,0.4446640316205534,0.5561497326203207,0.48453608247422686,0.3695652173913043,0.11034482758620692,0.18565400843881855,0.2075471698113207,0.13249211356466878,0.3515358361774744,0.21138211382113822,0.05494505494505491,0.1797432239657632,2
46+
0.7973684210526317,0.1758893280632411,0.4919786096256683,0.2783505154639176,0.6086956521739131,0.6965517241379311,0.5970464135021097,0.2075471698113207,0.5331230283911672,0.3728668941979522,0.4959349593495936,0.8937728937728937,0.35805991440798857,0

0 commit comments

Comments
 (0)