From 6d4852e583db8fa2aeefa1370b0a5a5d1e14d4a0 Mon Sep 17 00:00:00 2001 From: Carmel Gafa Date: Fri, 11 Oct 2024 22:58:32 +0200 Subject: [PATCH] worked on venv --- ml_algorithms.egg-info/PKG-INFO | 11 ----- ml_algorithms.egg-info/SOURCES.txt | 41 ------------------ ml_algorithms.egg-info/dependency_links.txt | 1 - ml_algorithms.egg-info/top_level.txt | 2 - .../__pycache__/__init__.cpython-39.pyc | Bin 154 -> 0 bytes ml_algorithms/src/algorithms/cnn/cnn.py | 7 +++ .../batch_gradient_descent/uni_batch_gd_v.py | 13 +++--- .../normalization/normalization_analysis.py | 2 +- .../univariate_gd_analysis.py | 26 ++++++++--- .../univariate_lr.py | 1 + .../binaryclassification.cpython-311.pyc | Bin 0 -> 5518 bytes .../__pycache__/lr_utils.cpython-311.pyc | Bin 0 -> 1886 bytes .../binaryclassification.py | 4 +- 13 files changed, 36 insertions(+), 72 deletions(-) delete mode 100644 ml_algorithms.egg-info/PKG-INFO delete mode 100644 ml_algorithms.egg-info/SOURCES.txt delete mode 100644 ml_algorithms.egg-info/dependency_links.txt delete mode 100644 ml_algorithms.egg-info/top_level.txt delete mode 100644 ml_algorithms/__pycache__/__init__.cpython-39.pyc create mode 100644 ml_algorithms/src/algorithms/cnn/cnn.py create mode 100644 ml_algorithms/src/algorithms/logistic_regression/__pycache__/binaryclassification.cpython-311.pyc create mode 100644 ml_algorithms/src/algorithms/logistic_regression/__pycache__/lr_utils.cpython-311.pyc diff --git a/ml_algorithms.egg-info/PKG-INFO b/ml_algorithms.egg-info/PKG-INFO deleted file mode 100644 index 32f5169..0000000 --- a/ml_algorithms.egg-info/PKG-INFO +++ /dev/null @@ -1,11 +0,0 @@ -Metadata-Version: 2.1 -Name: ml-algorithms -Version: 1.0 -Summary: UNKNOWN -Home-page: UNKNOWN -License: UNKNOWN -Platform: UNKNOWN -License-File: LICENSE - -UNKNOWN - diff --git a/ml_algorithms.egg-info/SOURCES.txt b/ml_algorithms.egg-info/SOURCES.txt deleted file mode 100644 index d706743..0000000 --- a/ml_algorithms.egg-info/SOURCES.txt +++ /dev/null @@ -1,41 +0,0 @@ -LICENSE -README.md -setup.py -algorithms/__init__.py -algorithms/fuzzy_learning/__init__.py -algorithms/fuzzy_learning/fuzzy_learning_sample_set.py -algorithms/fuzzy_learning/fuzzy_learning_sbp.py -algorithms/fuzzy_learning/fuzzy_system_example.py -algorithms/fuzzy_learning/fuzzy_system_test.py -algorithms/fuzzy_learning/sensor_comparison.py -algorithms/fuzzy_learning/sensor_data_generate.py -algorithms/fuzzy_learning/sensor_fuzzy_learn.py -algorithms/fuzzy_learning/weather_analyse.py -algorithms/fuzzy_learning/weather_fuzzy_learning.py -algorithms/fuzzy_learning/weather_preprocessing.py -algorithms/fuzzy_learning/weather_preprocessing_humidity.py -algorithms/fuzzy_learning/wine_dataset_analysis.py -algorithms/fuzzy_learning/wine_fuzzy_learning.py -algorithms/fuzzy_learning/wine_scaling.py -algorithms/fuzzy_learning/fuzzy_system/__init__.py -algorithms/fuzzy_learning/fuzzy_system/fuzzy_associative_memory.py -algorithms/fuzzy_learning/fuzzy_system/fuzzy_clause.py -algorithms/fuzzy_learning/fuzzy_system/fuzzy_learning_helper.py -algorithms/fuzzy_learning/fuzzy_system/fuzzy_learning_system.py -algorithms/fuzzy_learning/fuzzy_system/fuzzy_rule.py -algorithms/fuzzy_learning/fuzzy_system/fuzzy_system.py -algorithms/fuzzy_learning/fuzzy_system/system_settings.py -algorithms/fuzzy_learning/fuzzy_system/type1_fuzzy_set.py -algorithms/fuzzy_learning/fuzzy_system/type1_fuzzy_variable.py -algorithms/fuzzy_learning/fuzzy_system_exec/__init__.py -algorithms/fuzzy_learning/fuzzy_system_exec/fuzzy_learning_system_DiskStation_Apr-16-1542-2020_Conflict.py -algorithms/fuzzy_learning/fuzzy_system_exec/system_test.py -algorithms/fuzzy_learning/fuzzy_system_exec/system_test2.py -algorithms/fuzzy_learning/fuzzy_system_exec/system_test2_DiskStation_Mar-27-1623-2020_Conflict.py -algorithms/linear_regression/__init__.py -algorithms/linear_regression/univariate_gd_analysis.py -ml_algorithms/__init__.py -ml_algorithms.egg-info/PKG-INFO -ml_algorithms.egg-info/SOURCES.txt -ml_algorithms.egg-info/dependency_links.txt -ml_algorithms.egg-info/top_level.txt \ No newline at end of file diff --git a/ml_algorithms.egg-info/dependency_links.txt b/ml_algorithms.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/ml_algorithms.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/ml_algorithms.egg-info/top_level.txt b/ml_algorithms.egg-info/top_level.txt deleted file mode 100644 index 860476d..0000000 --- a/ml_algorithms.egg-info/top_level.txt +++ /dev/null @@ -1,2 +0,0 @@ -algorithms -ml_algorithms diff --git a/ml_algorithms/__pycache__/__init__.cpython-39.pyc b/ml_algorithms/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index c3c5ef27c0b944650b9605a48ce9819b6136b7c2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 154 zcmYe~<>g`kf=`!^q=M+jAOaaM0yz#qT+9L_QW%06G#UL?G8BP?5yUV1RI8Zs{G#lb zf};Ga)Z~)l_{5^r#F*Ti__U(@-1y?;qQsKq3=lstCq2I?vm_(8I3_+mGcU6wK3=b& V@)n0pZhlH>PO2Tq;LkwJ006xzC(8f; diff --git a/ml_algorithms/src/algorithms/cnn/cnn.py b/ml_algorithms/src/algorithms/cnn/cnn.py new file mode 100644 index 0000000..5e13962 --- /dev/null +++ b/ml_algorithms/src/algorithms/cnn/cnn.py @@ -0,0 +1,7 @@ +def convolution2d(x, kernel, bias, stride=1, padding=0): + """ + Convolution 2D + """ + + + \ No newline at end of file diff --git a/ml_algorithms/src/algorithms/linear_regression/batch_gradient_descent/uni_batch_gd_v.py b/ml_algorithms/src/algorithms/linear_regression/batch_gradient_descent/uni_batch_gd_v.py index 7203851..49aa39e 100644 --- a/ml_algorithms/src/algorithms/linear_regression/batch_gradient_descent/uni_batch_gd_v.py +++ b/ml_algorithms/src/algorithms/linear_regression/batch_gradient_descent/uni_batch_gd_v.py @@ -13,7 +13,7 @@ def gradient_descent( a0 = 130 a1 = 19 - + a0_prev = a0 a1_prev = a1 @@ -21,10 +21,10 @@ def gradient_descent( m = len(data_set) epoch = 0 - + previous_cost = sys.float_info.max gd_data = [] - + while True: # calculate the hypothesis function for all training data @@ -75,7 +75,7 @@ def gradient_descent( a0_range=(125,175,0.5), a1_range=(18,22,0.5), gd_points = gd_data - ) + ) return a0, a1 if __name__ == '__main__': @@ -87,6 +87,7 @@ def gradient_descent( epochs_threshold = 100000 costdifference_threshold = 0.00001 plot = True - + a0, a1 = gradient_descent(filename, alpha, epochs_threshold, costdifference_threshold, plot) - print(f'a0: {a0:.3f}, a1: {a1:.3f}') \ No newline at end of file + print(f'a0: {a0:.3f}, a1: {a1:.3f}') + \ No newline at end of file diff --git a/ml_algorithms/src/algorithms/linear_regression/normalization/normalization_analysis.py b/ml_algorithms/src/algorithms/linear_regression/normalization/normalization_analysis.py index d459d12..5958c2d 100644 --- a/ml_algorithms/src/algorithms/linear_regression/normalization/normalization_analysis.py +++ b/ml_algorithms/src/algorithms/linear_regression/normalization/normalization_analysis.py @@ -1,6 +1,6 @@ import os import pandas as pd -from sklearn.preprocessing import StandardScaler + data_path=os.path.join(os.path.dirname(__file__),'..', 'data_generation', 'data_1f.csv') diff --git a/ml_algorithms/src/algorithms/linear_regression/univariate_gd_analysis.py b/ml_algorithms/src/algorithms/linear_regression/univariate_gd_analysis.py index cdf8bd8..4eeb2de 100644 --- a/ml_algorithms/src/algorithms/linear_regression/univariate_gd_analysis.py +++ b/ml_algorithms/src/algorithms/linear_regression/univariate_gd_analysis.py @@ -1,12 +1,17 @@ from operator import index -from typing_extensions import _AnnotatedAlias import numpy as np import matplotlib.pyplot as plt import pandas as pd from matplotlib import cm -def plot_univariate_gd_analysis(file:str, a0_range:tuple, a1_range:tuple, gd_points:list, plot_slices=False): +def plot_univariate_gd_analysis( + file:str, + a0_range:tuple, + a1_range:tuple, + gd_points:list, + plot_slices=False): ''' + plot the costs surface and the gradient descent points ''' # read the data set @@ -31,7 +36,6 @@ def plot_univariate_gd_analysis(file:str, a0_range:tuple, a1_range:tuple, gd_poi cost_row.append(cost) costs.append(cost_row) - if plot_slices: a0_mincost_idx = np.where(np.round(a0[0,:], 1)==150) @@ -43,7 +47,7 @@ def plot_univariate_gd_analysis(file:str, a0_range:tuple, a1_range:tuple, gd_poi plt.plot(a1_mincost, costs_mincosts) plt.xlabel(r'$a_1$') plt.ylabel(r'$J(150,a_1$)') - + plt.show() @@ -71,7 +75,15 @@ def plot_univariate_gd_analysis(file:str, a0_range:tuple, a1_range:tuple, gd_poi plt.rcParams['text.usetex'] = True fig = plt.figure() ax = plt.axes(projection='3d') - ax.plot_surface(a0, a1, np.array(costs), rstride=1, cstride=1, cmap='cividis', edgecolor='none', alpha=0.5) + ax.plot_surface( + a0, + a1, + np.array(costs), + rstride=1, + cstride=1, + cmap='cividis', + edgecolor='none', + alpha=0.5) ax.contour(a0, a1, np.array(costs), zdir='z', offset=-0.5, cmap=cm.coolwarm) ax.plot(xx, yy, zz, 'r.--', alpha=1) ax.set_xlabel(r'$a_0$') @@ -84,7 +96,7 @@ def plot_univariate_gd_analysis(file:str, a0_range:tuple, a1_range:tuple, gd_poi plot_univariate_gd_analysis( file=os.path.join(os.path.dirname(__file__), 'data_generation', 'data_1f.csv'), - a0_range=(125,175,0.2), - a1_range=(18,22,0.2), + a0_range=(125,175,0.2), + a1_range=(18,22,0.2), gd_points= [], plot_slices=True) diff --git a/ml_algorithms/src/algorithms/linear_regression/univariate_linear_regression/univariate_lr.py b/ml_algorithms/src/algorithms/linear_regression/univariate_linear_regression/univariate_lr.py index aa43f2c..111e4c1 100644 --- a/ml_algorithms/src/algorithms/linear_regression/univariate_linear_regression/univariate_lr.py +++ b/ml_algorithms/src/algorithms/linear_regression/univariate_linear_regression/univariate_lr.py @@ -26,4 +26,5 @@ a_1 = (n*sum_xy - sum_x*sum_y)/(n*sum_x_sq - sum_x**2) + print(f'a_0: {a_0}, a_1: {a_1}') \ No newline at end of file diff --git a/ml_algorithms/src/algorithms/logistic_regression/__pycache__/binaryclassification.cpython-311.pyc b/ml_algorithms/src/algorithms/logistic_regression/__pycache__/binaryclassification.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9e41037d7445e18546c0d8764b62b074b0567c78 GIT binary patch literal 5518 zcmd5=O>7&-72f4PwWRe=JCZGrEIT$6MX(yHNtDF3A}6RFr)c6JKaN^r$X!ya@XxbL z(_)tmQRF}y0zv}{%mNOe9-1a_3Zw;k=_#k4NrOOz1q=u%e8^3J5unJa@6D3SUCAnX z>|%FzXZF1}GjHB}@7w)TG&&%_@sCD0^Y=r7@Gq?N4o~;t@gh9j6=Xpcv%)oz-#t0+ zHJ>QRo==5qe%T9UK=wfyltXghQ}J3z4ni#~i&uqs_4hc`c5Ubr5=0tMI> zWl?v$U$dVLK@z@%+I_pF0vZ)b5UQeq);*QV0D)tCY1sH zc8O(5IVG=ai@aJP&ygjfrD&EiQeY%s$`#ki4JD-)n5FQJqL)~{E3Sd~KD*fI_c*G! z$MocjrdPRHgh#PrikgPLBjm??dU2&(U>~m(Sz!&VYYEB}x{}K#(yWk6XembZ)GF3# zHdA1#zM9ikG?rR%RI`PQs_AMf!ITVBG)*n!SCVR;vh`G!LN%?Xs1A*D#dR~-ojJo* zMIUR^P}GFoF(EuqfBW;1%~*4|>A5qpIdSXP?aqU=X!0M(wAM?8Axh(un)PvZcbr>E!)O!|$FG1?Qt*IT} zBgtdclHMc9?HZ!tNqZnBymSN>#tIAYx2|Y}c2}3AVY%NYYF^bfP>UF}ko7A}pyutffgB22_HD#C~~Dt!uiH zdqUKe!T2S|IQxddCK%FIX;C=?gP5I<^SLHL!8x&{O10T;lyd=w%gWHd@c_f{F#Q#U z6*SY&ZJ7hArsg%B=2MF4PiG5MH@#|Jk9$oobYqHTQ%q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JZa~wFXU-lq_?Pn2Sx_lfg1oQV7}l zAm06R^8bzE+yO3D`eCB$4`lZohixS9!d?bIlzR*$H2yc?0}H1xpK^4{Sc|&zvv|m& zhqy8<3WXVj?|x*Y7Gpe$?Z>cq7K(UqFZ7&5m56gl>=a5r4~2%LrHddIbOgKOVlSZ# ziu@G{K#n6$_V;LXeDlTT+b!~w*3swNqvtxK=W17WLgCNCx5JI;&C|{4&1agl9U`3& zsVzMU4gMFVh+s6o`9gDkbFm$r>O`k@1)m>q2?_ufK$5rX*Xvh-OkTbHYW>x1GF`s{ zf1l=?qwUDCR^-^uz6R-V%XgR~LR@?!K4AI*c8lv4vmOR?E@lgQR!zd6E_^Zr-MhD# z)h&v t=Waj}qq~A#Obm-dyMkRjJtH3873|`&__RoN1$XgFaY6)2y1(E9{14R9U1R_N literal 0 HcmV?d00001 diff --git a/ml_algorithms/src/algorithms/logistic_regression/__pycache__/lr_utils.cpython-311.pyc b/ml_algorithms/src/algorithms/logistic_regression/__pycache__/lr_utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..21c86db3589e3503b4c678ad505171a2bcb14243 GIT binary patch literal 1886 zcmcgsO>7%Q6rNr0#v40{lg9F;W!_1F9?~M_(vLz2w*xr55Zv!qlF=M~KdGC8a zquJj^MQ4{~i zu7?IxJfsbsy5jIajPR*3q=6XHsWFBfu|C|rsy;!ZC&l0mFryafA?EoLHz+#NKn&@W z7?LA6q7!x`XE-m?7ZY8*pG>9Fnrf>^w^7=Ls!>*Qs(rU?l_^UVE)forXvT_9o2fMvC$6G>6> zhN&wG5sH>kCPLv-rAma)sg3aE3K3NZ)hY=?9Tn7yPQ-xCL`VeXpi!|E3PdERn@WH? zs@_H|z?Rx-t~~=X-q)*QL1U}mQf*mAg04Cdv0jg@L42zA9H*=7fsulK}Mg}LZJU+)ZPA>V0t2lAh zU3=r1@G_NW}7XsZxb!s0POwVc+^-`o9DC9+Rgjc_l5CEN$D=KZfV2%ANtbPRUV- g