noshot 10.0.0__py3-none-any.whl → 12.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. noshot/data/DLE FSD BDA/DLE/1. DNN (Image Classification).ipynb +389 -0
  2. noshot/data/DLE FSD BDA/DLE/2. DNN vs CNN.ipynb +516 -0
  3. noshot/data/DLE FSD BDA/DLE/3. CNN (Object Detecrion).ipynb +259 -0
  4. noshot/data/DLE FSD BDA/DLE/4. FCN (Image Segmentaion).ipynb +274 -0
  5. noshot/main.py +3 -3
  6. {noshot-10.0.0.dist-info → noshot-12.0.0.dist-info}/METADATA +1 -1
  7. noshot-12.0.0.dist-info/RECORD +13 -0
  8. {noshot-10.0.0.dist-info → noshot-12.0.0.dist-info}/WHEEL +1 -1
  9. noshot/data/ML TS XAI/ML/CNN(Image_for_Folders_5).ipynb +0 -201
  10. noshot/data/ML TS XAI/ML/CNN(Image_form_Folder_2).ipynb +0 -201
  11. noshot/data/ML TS XAI/ML/Json Codes/ML LAB CIA 2.ipynb +0 -409
  12. noshot/data/ML TS XAI/ML/ML 1/1. EDA-PCA (Balance Scale Dataset).ipynb +0 -147
  13. noshot/data/ML TS XAI/ML/ML 1/1. EDA-PCA (Rice Dataset).ipynb +0 -181
  14. noshot/data/ML TS XAI/ML/ML 1/10. HMM Veterbi.ipynb +0 -152
  15. noshot/data/ML TS XAI/ML/ML 1/2. KNN (Balance Scale Dataset).ipynb +0 -117
  16. noshot/data/ML TS XAI/ML/ML 1/2. KNN (Iris Dataset).ipynb +0 -156
  17. noshot/data/ML TS XAI/ML/ML 1/2. KNN (Sobar-72 Dataset).ipynb +0 -215
  18. noshot/data/ML TS XAI/ML/ML 1/3. LDA (Balance Scale Dataset).ipynb +0 -78
  19. noshot/data/ML TS XAI/ML/ML 1/3. LDA (NPHA Doctor Visits Dataset).ipynb +0 -114
  20. noshot/data/ML TS XAI/ML/ML 1/4. Linear Regression (Machine Dataset).ipynb +0 -115
  21. noshot/data/ML TS XAI/ML/ML 1/4. Linear Regression (Real Estate Dataset).ipynb +0 -146
  22. noshot/data/ML TS XAI/ML/ML 1/5. Logistic Regression (Magic04 Dataset).ipynb +0 -130
  23. noshot/data/ML TS XAI/ML/ML 1/5. Logistic Regression (Wine Dataset).ipynb +0 -112
  24. noshot/data/ML TS XAI/ML/ML 1/6. Naive Bayes Classifier (Agaricus Lepiota Dataset).ipynb +0 -118
  25. noshot/data/ML TS XAI/ML/ML 1/6. Naive Bayes Classifier (Wine Dataset).ipynb +0 -89
  26. noshot/data/ML TS XAI/ML/ML 1/7. SVM (Rice Dataset).ipynb +0 -120
  27. noshot/data/ML TS XAI/ML/ML 1/8. FeedForward NN (Sobar72 Dataset).ipynb +0 -262
  28. noshot/data/ML TS XAI/ML/ML 1/9. CNN (Cifar10 Dataset).ipynb +0 -156
  29. noshot/data/ML TS XAI/ML/ML 2/1. PCA.ipynb +0 -162
  30. noshot/data/ML TS XAI/ML/ML 2/10. CNN.ipynb +0 -100
  31. noshot/data/ML TS XAI/ML/ML 2/11. HMM.ipynb +0 -336
  32. noshot/data/ML TS XAI/ML/ML 2/2. KNN.ipynb +0 -149
  33. noshot/data/ML TS XAI/ML/ML 2/3. LDA.ipynb +0 -132
  34. noshot/data/ML TS XAI/ML/ML 2/4. Linear Regression.ipynb +0 -86
  35. noshot/data/ML TS XAI/ML/ML 2/5. Logistic Regression.ipynb +0 -115
  36. noshot/data/ML TS XAI/ML/ML 2/6. Naive Bayes (Titanic).ipynb +0 -196
  37. noshot/data/ML TS XAI/ML/ML 2/6. Naive Bayes (Wine).ipynb +0 -98
  38. noshot/data/ML TS XAI/ML/ML 2/7. SVM Linear.ipynb +0 -109
  39. noshot/data/ML TS XAI/ML/ML 2/8. SVM Non-Linear.ipynb +0 -195
  40. noshot/data/ML TS XAI/ML/ML 2/9. FNN With Regularization.ipynb +0 -189
  41. noshot/data/ML TS XAI/ML/ML 2/9. FNN Without Regularization.ipynb +0 -197
  42. noshot/data/ML TS XAI/ML/ML 2/All in One Lab CIA 1 Q.ipynb +0 -1087
  43. noshot/data/ML TS XAI/ML/ML 3 (Latest)/1. PCA EDA.ipynb +0 -274
  44. noshot/data/ML TS XAI/ML/ML 3 (Latest)/10. CNN.ipynb +0 -170
  45. noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM 2.ipynb +0 -1087
  46. noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM 3.ipynb +0 -178
  47. noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM 4.ipynb +0 -185
  48. noshot/data/ML TS XAI/ML/ML 3 (Latest)/11. HMM.ipynb +0 -106
  49. noshot/data/ML TS XAI/ML/ML 3 (Latest)/2. KNN.ipynb +0 -177
  50. noshot/data/ML TS XAI/ML/ML 3 (Latest)/3. LDA.ipynb +0 -195
  51. noshot/data/ML TS XAI/ML/ML 3 (Latest)/4. Linear Regression.ipynb +0 -267
  52. noshot/data/ML TS XAI/ML/ML 3 (Latest)/5. Logistic Regression.ipynb +0 -104
  53. noshot/data/ML TS XAI/ML/ML 3 (Latest)/6. Bayesian Classifier.ipynb +0 -109
  54. noshot/data/ML TS XAI/ML/ML 3 (Latest)/7. SVM.ipynb +0 -220
  55. noshot/data/ML TS XAI/ML/ML 3 (Latest)/8. MLP.ipynb +0 -99
  56. noshot/data/ML TS XAI/ML/ML 3 (Latest)/9. Ridge - Lasso.ipynb +0 -211
  57. noshot/data/ML TS XAI/ML/ML 3 (Latest)/9. Ridge Lasso 2.ipynb +0 -99
  58. noshot/data/ML TS XAI/ML/ML 3 (Latest)/Image Load Example.ipynb +0 -118
  59. noshot/data/ML TS XAI/ML/ML 3 (Latest)/Updated_Untitled.ipynb +0 -603
  60. noshot/data/ML TS XAI/ML/ML Lab AllinOne.ipynb +0 -961
  61. noshot/data/ML TS XAI/ML/ML Lab H Sec/1. Iris Dataset (Softmax vs Sigmoid).ipynb +0 -231
  62. noshot/data/ML TS XAI/ML/ML Lab H Sec/2. Student Dataset (Overfit vs Regularized).ipynb +0 -269
  63. noshot/data/ML TS XAI/ML/ML Lab H Sec/3. Insurance Target Categorical (Overfit vs Regularized).ipynb +0 -274
  64. noshot/data/ML TS XAI/ML/ML Lab H Sec/3. Insurance Target Numerical (Overfit vs Regularized).ipynb +0 -263
  65. noshot/data/ML TS XAI/ML/ML Lab H Sec/4. Smart House System HMM.ipynb +0 -198
  66. noshot/data/ML TS XAI/ML/ML Lab H Sec/5. Fraud Detection System HMM.ipynb +0 -201
  67. noshot/data/ML TS XAI/ML/ML Lab H Sec/insurance.csv +0 -1339
  68. noshot/data/ML TS XAI/ML/ML Lab H Sec/iris1.data +0 -151
  69. noshot/data/ML TS XAI/ML/ML Lab H Sec/student-mat.csv +0 -396
  70. noshot/data/ML TS XAI/ML/ML Lab H Sec/student-por.csv +0 -650
  71. noshot/data/ML TS XAI/ML/Rolls Royce AllinOne.ipynb +0 -691
  72. noshot-10.0.0.dist-info/RECORD +0 -72
  73. {noshot-10.0.0.dist-info → noshot-12.0.0.dist-info}/licenses/LICENSE.txt +0 -0
  74. {noshot-10.0.0.dist-info → noshot-12.0.0.dist-info}/top_level.txt +0 -0
@@ -1,215 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "838f3d63-f48d-4003-8a20-767d87d5d63b",
7
- "metadata": {
8
- "id": "10424106"
9
- },
10
- "outputs": [],
11
- "source": [
12
- "import numpy as np\n",
13
- "import pandas as pd\n",
14
- "import seaborn as sns\n",
15
- "import matplotlib.pyplot as plt\n",
16
- "from sklearn.model_selection import train_test_split\n",
17
- "from sklearn.preprocessing import StandardScaler\n",
18
- "from sklearn.decomposition import PCA\n",
19
- "from sklearn.neighbors import KNeighborsClassifier\n",
20
- "from sklearn import metrics\n",
21
- "from mlxtend.plotting import plot_decision_regions\n",
22
- "from scipy.cluster.hierarchy import dendrogram, linkage\n",
23
- "from scipy.spatial import Voronoi, voronoi_plot_2d"
24
- ]
25
- },
26
- {
27
- "cell_type": "code",
28
- "execution_count": null,
29
- "id": "5a30696e-2e04-4ead-90c7-21dbd6b1d75d",
30
- "metadata": {
31
- "id": "10424106"
32
- },
33
- "outputs": [],
34
- "source": [
35
- "df = pd.read_csv(\"data/sobar-72.csv\")\n",
36
- "display(df.head())\n",
37
- "display(df.info())"
38
- ]
39
- },
40
- {
41
- "cell_type": "code",
42
- "execution_count": null,
43
- "id": "35e3b9f1-f5ed-4dd1-8a4d-aeb7fe77bea2",
44
- "metadata": {
45
- "id": "10424106"
46
- },
47
- "outputs": [],
48
- "source": [
49
- "cols = [\n",
50
- " 'behavior_sexualRisk', 'intention_aggregation', 'attitude_consistency',\n",
51
- " 'norm_significantPerson', 'perception_vulnerability', 'motivation_strength',\n",
52
- " 'socialSupport_emotionality', 'empowerment_knowledge', 'ca_cervix'\n",
53
- "]\n",
54
- "sns.pairplot(df[cols], hue='ca_cervix')\n",
55
- "plt.show()"
56
- ]
57
- },
58
- {
59
- "cell_type": "code",
60
- "execution_count": null,
61
- "id": "09bb4a6d-3807-44cb-b15e-2e6b3ff20d02",
62
- "metadata": {
63
- "id": "10424106"
64
- },
65
- "outputs": [],
66
- "source": [
67
- "X = df.drop(columns=['ca_cervix'])\n",
68
- "y = df['ca_cervix']"
69
- ]
70
- },
71
- {
72
- "cell_type": "code",
73
- "execution_count": null,
74
- "id": "5a235b36-2136-4924-a6a3-834fde3e541c",
75
- "metadata": {
76
- "id": "10424106"
77
- },
78
- "outputs": [],
79
- "source": [
80
- "X_scaled = StandardScaler().fit_transform(X)\n",
81
- "X_pca = PCA(n_components=2).fit_transform(X_scaled)\n",
82
- "X_train, X_test, y_train, y_test = train_test_split(X_pca, y, test_size=0.4, random_state=4)"
83
- ]
84
- },
85
- {
86
- "cell_type": "code",
87
- "execution_count": null,
88
- "id": "7db3c778-fb6f-4509-8598-5df6928058e2",
89
- "metadata": {
90
- "id": "10424106"
91
- },
92
- "outputs": [],
93
- "source": [
94
- "similarities = ['euclidean', 'manhattan', 'minkowski']\n",
95
- "for sim in similarities:\n",
96
- " knn = KNeighborsClassifier(n_neighbors=5, metric=sim)\n",
97
- " knn.fit(X_train, y_train)\n",
98
- " y_pred = knn.predict(X_test)\n",
99
- "\n",
100
- " plot_decision_regions(X_train, np.array(y_train), clf=knn, legend=2)\n",
101
- " plt.xlabel('X')\n",
102
- " plt.ylabel('Y')\n",
103
- " plt.title(f'KNN with K=5 using {sim.capitalize()} Distance')\n",
104
- " plt.show()"
105
- ]
106
- },
107
- {
108
- "cell_type": "code",
109
- "execution_count": null,
110
- "id": "f4fee956-56f9-487d-b1fd-a2c32536fa0f",
111
- "metadata": {
112
- "id": "10424106"
113
- },
114
- "outputs": [],
115
- "source": [
116
- "k_values, accuracies = [], []\n",
117
- "for k in range(1, 10):\n",
118
- " knn = KNeighborsClassifier(n_neighbors=k)\n",
119
- " knn.fit(X_train, y_train)\n",
120
- " y_pred = knn.predict(X_test)\n",
121
- " k_values.append(k)\n",
122
- " accuracies.append(metrics.accuracy_score(y_test, y_pred))\n",
123
- "\n",
124
- "plt.figure(figsize=(4, 2))\n",
125
- "plt.plot(k_values, accuracies, marker='o')\n",
126
- "plt.title('K Value vs Accuracy')\n",
127
- "plt.xlabel('K')\n",
128
- "plt.ylabel('Accuracy')\n",
129
- "plt.grid()\n",
130
- "plt.show()"
131
- ]
132
- },
133
- {
134
- "cell_type": "code",
135
- "execution_count": null,
136
- "id": "6ecc3e38-c791-48eb-ad01-a8149a2380ae",
137
- "metadata": {
138
- "id": "10424106"
139
- },
140
- "outputs": [],
141
- "source": [
142
- "plt.scatter(X_test[:, 0], X_test[:, 1], c=y_pred, cmap='coolwarm', edgecolors='k')\n",
143
- "plt.title('Test Data Predictions')\n",
144
- "plt.grid()\n",
145
- "plt.show()"
146
- ]
147
- },
148
- {
149
- "cell_type": "code",
150
- "execution_count": null,
151
- "id": "9f40e9af-601f-4b4e-aadc-c3b27d4e4f11",
152
- "metadata": {
153
- "id": "10424106"
154
- },
155
- "outputs": [],
156
- "source": [
157
- "unique_labels = np.unique(y)\n",
158
- "label_mapping = {label: i for i, label in enumerate(unique_labels)}\n",
159
- "y_mapped = np.array([label_mapping[label] for label in y])\n",
160
- "\n",
161
- "linked = linkage(X_pca, method='single')\n",
162
- "\n",
163
- "plt.figure(figsize=(10, 7))\n",
164
- "dendrogram(linked, orientation='top', distance_sort='descending', labels=y_mapped, show_leaf_counts=True)\n",
165
- "plt.title('Dendrogram for KNN')\n",
166
- "plt.xlabel('Data Points')\n",
167
- "plt.ylabel('Distance')\n",
168
- "plt.show()"
169
- ]
170
- },
171
- {
172
- "cell_type": "code",
173
- "execution_count": null,
174
- "id": "5164b3a8-26f4-4855-a551-d5f9790b9975",
175
- "metadata": {
176
- "id": "10424106"
177
- },
178
- "outputs": [],
179
- "source": [
180
- "vor = Voronoi(X_pca)\n",
181
- "fig = voronoi_plot_2d(vor, show_vertices=False, line_colors='black', line_width=2, line_alpha=0.6, point_size=10)\n",
182
- "\n",
183
- "plt.scatter(X_pca[:, 0], X_pca[:, 1], c=y, cmap='viridis', s=50, edgecolors='k')\n",
184
- "plt.title('Voronoi Diagram with Target Variable')\n",
185
- "plt.xlabel('X')\n",
186
- "plt.ylabel('Y')\n",
187
- "plt.show()"
188
- ]
189
- }
190
- ],
191
- "metadata": {
192
- "colab": {
193
- "provenance": []
194
- },
195
- "kernelspec": {
196
- "display_name": "Python 3 (ipykernel)",
197
- "language": "python",
198
- "name": "python3"
199
- },
200
- "language_info": {
201
- "codemirror_mode": {
202
- "name": "ipython",
203
- "version": 3
204
- },
205
- "file_extension": ".py",
206
- "mimetype": "text/x-python",
207
- "name": "python",
208
- "nbconvert_exporter": "python",
209
- "pygments_lexer": "ipython3",
210
- "version": "3.12.4"
211
- }
212
- },
213
- "nbformat": 4,
214
- "nbformat_minor": 5
215
- }
@@ -1,78 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "96ac04a5-6577-4da4-8454-3b10535351f8",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import pandas as pd\n",
11
- "import matplotlib.pyplot as plt\n",
12
- "from sklearn.preprocessing import StandardScaler\n",
13
- "from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA"
14
- ]
15
- },
16
- {
17
- "cell_type": "code",
18
- "execution_count": null,
19
- "id": "b1ffa4dc-488f-4238-877b-5cbd6fb48e4e",
20
- "metadata": {},
21
- "outputs": [],
22
- "source": [
23
- "cols = ['class name','left-weight','left-distance','right-weight','right-distance']\n",
24
- "df = pd.read_table('data/balance-scale.txt', delimiter = \",\", names=cols)\n",
25
- "print(\"Shape:\", df.shape)\n",
26
- "df.head()"
27
- ]
28
- },
29
- {
30
- "cell_type": "code",
31
- "execution_count": null,
32
- "id": "069bba36-4187-48e4-bc5b-d1443c1ee87c",
33
- "metadata": {},
34
- "outputs": [],
35
- "source": [
36
- "features = ['left-weight','left-distance','right-weight','right-distance']\n",
37
- "x = df.loc[:,features]\n",
38
- "y = df.loc[:,'class name']\n",
39
- "lda = LDA(n_components=2)\n",
40
- "lda_X = lda.fit(x,y).transform(x)"
41
- ]
42
- },
43
- {
44
- "cell_type": "code",
45
- "execution_count": null,
46
- "id": "66c2b6ac-6163-4f36-ae6b-3a9e32e578ce",
47
- "metadata": {},
48
- "outputs": [],
49
- "source": [
50
- "plt.scatter(lda_X[y == 'L', 0], lda_X[y == 'L', 1], s=50, c='orange', label='L')\n",
51
- "plt.scatter(lda_X[y == 'B', 0], lda_X[y == 'B', 1], s=50, c='blue', label='B')\n",
52
- "plt.scatter(lda_X[y == 'R', 0], lda_X[y == 'R', 1], s=50, c='green', label='R')\n",
53
- "plt.title('LDA plot for cmc DataSet')"
54
- ]
55
- }
56
- ],
57
- "metadata": {
58
- "kernelspec": {
59
- "display_name": "Python 3 (ipykernel)",
60
- "language": "python",
61
- "name": "python3"
62
- },
63
- "language_info": {
64
- "codemirror_mode": {
65
- "name": "ipython",
66
- "version": 3
67
- },
68
- "file_extension": ".py",
69
- "mimetype": "text/x-python",
70
- "name": "python",
71
- "nbconvert_exporter": "python",
72
- "pygments_lexer": "ipython3",
73
- "version": "3.12.4"
74
- }
75
- },
76
- "nbformat": 4,
77
- "nbformat_minor": 5
78
- }
@@ -1,114 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "68f40eda",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import pandas as pd\n",
11
- "import numpy as np\n",
12
- "import matplotlib.pyplot as plt"
13
- ]
14
- },
15
- {
16
- "cell_type": "code",
17
- "execution_count": null,
18
- "id": "066999b2",
19
- "metadata": {},
20
- "outputs": [],
21
- "source": [
22
- "df = pd.read_csv(r\"data\\doctor-visits.csv\")\n",
23
- "print(\"Shape:\", df.shape)\n",
24
- "df.head()"
25
- ]
26
- },
27
- {
28
- "cell_type": "code",
29
- "execution_count": null,
30
- "id": "839d6a31",
31
- "metadata": {},
32
- "outputs": [],
33
- "source": [
34
- "df.columns"
35
- ]
36
- },
37
- {
38
- "cell_type": "code",
39
- "execution_count": null,
40
- "id": "7d105e4c",
41
- "metadata": {},
42
- "outputs": [],
43
- "source": [
44
- "X = df.drop(columns=['Number of Doctors Visited'])\n",
45
- "Y = df['Number of Doctors Visited']"
46
- ]
47
- },
48
- {
49
- "cell_type": "code",
50
- "execution_count": null,
51
- "id": "05dc3f49-79f4-4862-91e8-89aab4ae2b2f",
52
- "metadata": {},
53
- "outputs": [],
54
- "source": [
55
- "from sklearn import metrics\n",
56
- "from sklearn.discriminant_analysis import LinearDiscriminantAnalysis\n",
57
- "from sklearn.model_selection import train_test_split\n",
58
- "\n",
59
- "X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.4, random_state=4)\n",
60
- "\n",
61
- "lda = LinearDiscriminantAnalysis(n_components=2)\n",
62
- "X_train = lda.fit_transform(X_train, y_train)\n",
63
- "X_test = lda.fit_transform(X_test,y_test)"
64
- ]
65
- },
66
- {
67
- "cell_type": "code",
68
- "execution_count": null,
69
- "id": "9e25c024-8dd8-40da-b755-1ed36dfc197c",
70
- "metadata": {},
71
- "outputs": [],
72
- "source": [
73
- "lda.fit(X_train,y_train)\n",
74
- "y_pred=lda.predict(X_test)\n",
75
- "print (\"Accuracy:\",metrics.accuracy_score(y_test, y_pred))"
76
- ]
77
- },
78
- {
79
- "cell_type": "code",
80
- "execution_count": null,
81
- "id": "7f0537a8-6820-4859-a3f5-f24096dfa66b",
82
- "metadata": {},
83
- "outputs": [],
84
- "source": [
85
- "plt.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap='viridis')\n",
86
- "plt.title('LDA Dimensionality Reduction')\n",
87
- "plt.xlabel('LDA Component 1')\n",
88
- "plt.ylabel('LDA Component 2')\n",
89
- "plt.show()"
90
- ]
91
- }
92
- ],
93
- "metadata": {
94
- "kernelspec": {
95
- "display_name": "Python 3 (ipykernel)",
96
- "language": "python",
97
- "name": "python3"
98
- },
99
- "language_info": {
100
- "codemirror_mode": {
101
- "name": "ipython",
102
- "version": 3
103
- },
104
- "file_extension": ".py",
105
- "mimetype": "text/x-python",
106
- "name": "python",
107
- "nbconvert_exporter": "python",
108
- "pygments_lexer": "ipython3",
109
- "version": "3.12.4"
110
- }
111
- },
112
- "nbformat": 4,
113
- "nbformat_minor": 5
114
- }
@@ -1,115 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "2d42ca1a-531d-4d5b-aee4-a489d5033d1b",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import pandas as pd\n",
11
- "import matplotlib.pyplot as plt\n",
12
- "from sklearn.model_selection import train_test_split\n",
13
- "from sklearn.linear_model import LinearRegression\n",
14
- "from sklearn.metrics import r2_score"
15
- ]
16
- },
17
- {
18
- "cell_type": "code",
19
- "execution_count": null,
20
- "id": "f81220bc-5415-4b02-b2fd-fd5a8ff8c97a",
21
- "metadata": {},
22
- "outputs": [],
23
- "source": [
24
- "df = pd.read_csv('data/machine-data.csv')\n",
25
- "print(\"Shape:\", df.shape)\n",
26
- "df.head()"
27
- ]
28
- },
29
- {
30
- "cell_type": "code",
31
- "execution_count": null,
32
- "id": "958f3a04-3ae7-442b-a6e7-9134b9c5aeb3",
33
- "metadata": {},
34
- "outputs": [],
35
- "source": [
36
- "x = df.iloc[:,3:4].values\n",
37
- "y = df.iloc[:,8].values\n",
38
- "\n",
39
- "X_train, X_test, y_train, y_test = train_test_split(x, y, test_size = 0.2, random_state = 0)\n",
40
- "regressor = LinearRegression()\n",
41
- "regressor.fit(X_train, y_train)"
42
- ]
43
- },
44
- {
45
- "cell_type": "code",
46
- "execution_count": null,
47
- "id": "5b15fa5c-5c78-436b-8f33-4f431c797788",
48
- "metadata": {},
49
- "outputs": [],
50
- "source": [
51
- "y_pred = regressor.predict(X_test)\n",
52
- "y_pred_train = regressor.predict(X_train)\n",
53
- "print(\"Model Score: \", regressor.score(X_test, y_test))\n",
54
- "print(\"R2 Score: \", r2_score(y_test, y_pred))"
55
- ]
56
- },
57
- {
58
- "cell_type": "code",
59
- "execution_count": null,
60
- "id": "b044ea95-014e-466b-b036-8ba9f96e3910",
61
- "metadata": {},
62
- "outputs": [],
63
- "source": [
64
- "plt.scatter(X_train, y_train, color = 'red')\n",
65
- "plt.plot(X_train, regressor.predict(X_train), color = 'blue')\n",
66
- "plt.title('Y vs X (Training set)')\n",
67
- "plt.xlabel('X')\n",
68
- "plt.ylabel('Y')\n",
69
- "plt.show()\n",
70
- "plt.scatter(X_test, y_test, color = 'red')\n",
71
- "plt.plot(X_train, regressor.predict(X_train), color = 'blue')\n",
72
- "plt.title('Y vs X (Test set)')\n",
73
- "plt.xlabel('X')"
74
- ]
75
- },
76
- {
77
- "cell_type": "code",
78
- "execution_count": null,
79
- "id": "33c64414-d432-439e-a976-d28a9b4c3f2a",
80
- "metadata": {},
81
- "outputs": [],
82
- "source": [
83
- "X_future_expereince = [[2],[4]]\n",
84
- "print(\"Prediction :\", regressor.predict(X_future_expereince))\n",
85
- "plt.scatter(X_future_expereince, regressor.predict(X_future_expereince), color = 'red')\n",
86
- "plt.plot(X_train, regressor.predict(X_train), color = 'blue')\n",
87
- "plt.title('Y vs X (Test set)')\n",
88
- "plt.xlabel('X')\n",
89
- "plt.ylabel('Y')\n",
90
- "plt.show()"
91
- ]
92
- }
93
- ],
94
- "metadata": {
95
- "kernelspec": {
96
- "display_name": "Python 3 (ipykernel)",
97
- "language": "python",
98
- "name": "python3"
99
- },
100
- "language_info": {
101
- "codemirror_mode": {
102
- "name": "ipython",
103
- "version": 3
104
- },
105
- "file_extension": ".py",
106
- "mimetype": "text/x-python",
107
- "name": "python",
108
- "nbconvert_exporter": "python",
109
- "pygments_lexer": "ipython3",
110
- "version": "3.12.4"
111
- }
112
- },
113
- "nbformat": 4,
114
- "nbformat_minor": 5
115
- }
@@ -1,146 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "c885166e-e06f-46c2-bfe0-bc9b64e7e1e5",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import numpy as np\n",
11
- "import pandas as pd\n",
12
- "import seaborn as sns\n",
13
- "import matplotlib.pyplot as plt\n",
14
- "from sklearn.model_selection import train_test_split"
15
- ]
16
- },
17
- {
18
- "cell_type": "code",
19
- "execution_count": null,
20
- "id": "b00fd97c-b199-41f0-825a-4b9574967f5f",
21
- "metadata": {},
22
- "outputs": [],
23
- "source": [
24
- "df = pd.read_excel(\"data/real-estate.xlsx\")\n",
25
- "df.head()"
26
- ]
27
- },
28
- {
29
- "cell_type": "code",
30
- "execution_count": null,
31
- "id": "90bb7a26-1e9b-4cc1-b104-ee76588ae090",
32
- "metadata": {},
33
- "outputs": [],
34
- "source": [
35
- "df.isnull().sum()"
36
- ]
37
- },
38
- {
39
- "cell_type": "code",
40
- "execution_count": null,
41
- "id": "9be23824-cb35-4c3c-9173-8dd99a3a2ec4",
42
- "metadata": {},
43
- "outputs": [],
44
- "source": [
45
- "sns.pairplot(df)\n",
46
- "plt.show()"
47
- ]
48
- },
49
- {
50
- "cell_type": "code",
51
- "execution_count": null,
52
- "id": "517a7b77-ba3b-42d4-9941-c386c1d5b8f6",
53
- "metadata": {},
54
- "outputs": [],
55
- "source": [
56
- "sns.heatmap(df.corr(), annot=True, fmt='.2f', cmap='coolwarm')\n",
57
- "plt.title('Correlation Heatmap')\n",
58
- "plt.show()"
59
- ]
60
- },
61
- {
62
- "cell_type": "code",
63
- "execution_count": null,
64
- "id": "7b3b0dc7-366e-4d69-a537-27856bc39643",
65
- "metadata": {},
66
- "outputs": [],
67
- "source": [
68
- "def lin_reg(colX):\n",
69
- " X = df[colX].values\n",
70
- " y = df['Y house price of unit area'].values\n",
71
- "\n",
72
- " X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
73
- "\n",
74
- " N = len(X_train)\n",
75
- " beta1 = (N * np.sum(X_train * y_train) - np.sum(X_train) * np.sum(y_train)) / (N * np.sum(X_train ** 2) - (np.sum(X_train)) ** 2)\n",
76
- " beta0 = (np.sum(y_train) - beta1 * np.sum(X_train)) / N\n",
77
- "\n",
78
- " y_pred_train = beta1 * X_train + beta0\n",
79
- " y_pred_test = beta1 * X_test + beta0\n",
80
- "\n",
81
- " plt.figure(figsize=(8, 5))\n",
82
- " plt.scatter(X_train, y_train, color='blue', label='Train Data')\n",
83
- " plt.scatter(X_test, y_test, color='green', label='Test Data')\n",
84
- " x_line = np.linspace(min(X.min(), X_test.min()), max(X.max(), X_test.max()), 100)\n",
85
- " y_line = beta1 * x_line + beta0\n",
86
- " plt.plot(x_line, y_line, color='red', linewidth=2, label='Fitted Line')\n",
87
- " plt.xlabel(colX)\n",
88
- " plt.ylabel('Y house price of unit area')\n",
89
- " plt.title(f'Linear Regression: {colX} vs Y')\n",
90
- " plt.legend()\n",
91
- " plt.grid(True)\n",
92
- " plt.show()\n",
93
- "\n",
94
- " mse_train = np.mean((y_train - beta1 * X_train - beta0) ** 2)\n",
95
- " mse_test = np.mean((y_test - beta1 * X_test - beta0) ** 2)\n",
96
- "\n",
97
- " return mse_train, mse_test"
98
- ]
99
- },
100
- {
101
- "cell_type": "code",
102
- "execution_count": null,
103
- "id": "341f4931-35d0-4a8b-a971-81e2376ad1a1",
104
- "metadata": {},
105
- "outputs": [],
106
- "source": [
107
- "mse1 = lin_reg('X3 distance to the nearest MRT station')\n",
108
- "mse2 = lin_reg('X5 latitude')\n",
109
- "mse3 = lin_reg('X6 longitude')"
110
- ]
111
- },
112
- {
113
- "cell_type": "code",
114
- "execution_count": null,
115
- "id": "6e5e18a2-00bf-4443-900d-b470ff4bd150",
116
- "metadata": {},
117
- "outputs": [],
118
- "source": [
119
- "print(mse1)\n",
120
- "print(mse2)\n",
121
- "print(mse3)"
122
- ]
123
- }
124
- ],
125
- "metadata": {
126
- "kernelspec": {
127
- "display_name": "Python 3 (ipykernel)",
128
- "language": "python",
129
- "name": "python3"
130
- },
131
- "language_info": {
132
- "codemirror_mode": {
133
- "name": "ipython",
134
- "version": 3
135
- },
136
- "file_extension": ".py",
137
- "mimetype": "text/x-python",
138
- "name": "python",
139
- "nbconvert_exporter": "python",
140
- "pygments_lexer": "ipython3",
141
- "version": "3.12.4"
142
- }
143
- },
144
- "nbformat": 4,
145
- "nbformat_minor": 5
146
- }