noshot 6.0.0__py3-none-any.whl → 7.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.
- noshot/data/ML TS XAI/ML/Rolls Royce AllinOne.ipynb +691 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/1. EDA-PCA (Balance Scale Dataset).ipynb +147 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/1. EDA-PCA (Rice Dataset).ipynb +181 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/10. HMM Veterbi.ipynb +152 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/2. KNN (Balance Scale Dataset).ipynb +117 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/2. KNN (Iris Dataset).ipynb +156 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/2. KNN (Sobar-72 Dataset).ipynb +215 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/3. LDA (Balance Scale Dataset).ipynb +78 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/3. LDA (NPHA Doctor Visits Dataset).ipynb +114 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/4. Linear Regression (Machine Dataset).ipynb +115 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/4. Linear Regression (Real Estate Dataset).ipynb +146 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/5. Logistic Regression (Magic04 Dataset).ipynb +130 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/5. Logistic Regression (Wine Dataset).ipynb +112 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/6. Naive Bayes Classifier (Agaricus Lepiota Dataset).ipynb +118 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/6. Naive Bayes Classifier (Wine Dataset).ipynb +89 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/7. SVM (Rice Dataset).ipynb +120 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/8. FeedForward NN (Sobar72 Dataset).ipynb +262 -0
- noshot/data/ML TS XAI/ML/Tamilan Code/9. CNN (Cifar10 Dataset).ipynb +156 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/1. PCA.ipynb +162 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/10. CNN.ipynb +100 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/11. HMM.ipynb +336 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/2. KNN.ipynb +149 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/3. LDA.ipynb +132 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/4. Linear Regression.ipynb +86 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/5. Logistic Regression.ipynb +115 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/6. Naive Bayes (Titanic).ipynb +196 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/6. Naive Bayes (Wine).ipynb +98 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/7. SVM Linear.ipynb +109 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/8. SVM Non-Linear.ipynb +195 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/9. FNN With Regularization.ipynb +189 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/9. FNN Without Regularization.ipynb +197 -0
- noshot/data/ML TS XAI/ML/Whitefang Code/All in One Lab CIA 1 Q.ipynb +1087 -0
- {noshot-6.0.0.dist-info → noshot-7.0.0.dist-info}/METADATA +1 -1
- noshot-7.0.0.dist-info/RECORD +41 -0
- {noshot-6.0.0.dist-info → noshot-7.0.0.dist-info}/WHEEL +1 -1
- noshot/data/ML TS XAI/XAI/Q1.ipynb +0 -377
- noshot/data/ML TS XAI/XAI/Q2.ipynb +0 -362
- noshot/data/ML TS XAI/XAI/Q3.ipynb +0 -637
- noshot/data/ML TS XAI/XAI/Q4.ipynb +0 -206
- noshot/data/ML TS XAI/XAI/Q5.ipynb +0 -1018
- noshot-6.0.0.dist-info/RECORD +0 -14
- {noshot-6.0.0.dist-info → noshot-7.0.0.dist-info}/licenses/LICENSE.txt +0 -0
- {noshot-6.0.0.dist-info → noshot-7.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,132 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "markdown",
|
5
|
+
"id": "0e55f86f-412e-466f-bba9-25f0f0e6a4cf",
|
6
|
+
"metadata": {},
|
7
|
+
"source": [
|
8
|
+
"LDA- Linear Discriminant Analysis."
|
9
|
+
]
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"cell_type": "code",
|
13
|
+
"execution_count": null,
|
14
|
+
"id": "530aa877-bc4c-4705-9558-c3699fddcb48",
|
15
|
+
"metadata": {},
|
16
|
+
"outputs": [],
|
17
|
+
"source": [
|
18
|
+
"#required packages.\n",
|
19
|
+
"\n",
|
20
|
+
"import pandas as pd\n",
|
21
|
+
"import matplotlib.pyplot as plt\n",
|
22
|
+
"import seaborn as sns\n",
|
23
|
+
"import numpy as np\n",
|
24
|
+
"from sklearn.preprocessing import StandardScaler\n",
|
25
|
+
"from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA"
|
26
|
+
]
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"cell_type": "code",
|
30
|
+
"execution_count": null,
|
31
|
+
"id": "dc60a6db-5b8e-4915-9d54-41fd24137b78",
|
32
|
+
"metadata": {},
|
33
|
+
"outputs": [],
|
34
|
+
"source": [
|
35
|
+
"#load dataset.\n",
|
36
|
+
"\n",
|
37
|
+
"df=pd.read_csv(\"E:/126156055/dataset.csv\",names=['class name',\"left-weight\",\"left-distance\",'right-weight','right-distance'])\n",
|
38
|
+
"print(\"First Five rows : \\n\",df.head())\n",
|
39
|
+
"print(\"\\nInfo : \\n\",df.info)\n",
|
40
|
+
"print(\"\\nDescribe : \\n\",df.describe())"
|
41
|
+
]
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"cell_type": "code",
|
45
|
+
"execution_count": null,
|
46
|
+
"id": "65db7f61-68a6-44e1-8cc7-59d4598ea56a",
|
47
|
+
"metadata": {},
|
48
|
+
"outputs": [],
|
49
|
+
"source": [
|
50
|
+
"features=[\"left-weight\",\"left-distance\",'right-weight','right-distance']\n",
|
51
|
+
"x=df.loc[:,features]\n",
|
52
|
+
"x"
|
53
|
+
]
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"cell_type": "code",
|
57
|
+
"execution_count": null,
|
58
|
+
"id": "07a4edf8-e592-4ccb-b433-17f2054b5a60",
|
59
|
+
"metadata": {},
|
60
|
+
"outputs": [],
|
61
|
+
"source": [
|
62
|
+
"y=df.loc[:,'class name']\n",
|
63
|
+
"y"
|
64
|
+
]
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"cell_type": "code",
|
68
|
+
"execution_count": null,
|
69
|
+
"id": "4888333a-ac2c-4310-ad2f-6cf3786cbcf6",
|
70
|
+
"metadata": {},
|
71
|
+
"outputs": [],
|
72
|
+
"source": [
|
73
|
+
"lda=LDA(n_components=2)\n",
|
74
|
+
"lda"
|
75
|
+
]
|
76
|
+
},
|
77
|
+
{
|
78
|
+
"cell_type": "code",
|
79
|
+
"execution_count": null,
|
80
|
+
"id": "c6904766-9fea-4f83-8fe8-9b225f118afe",
|
81
|
+
"metadata": {},
|
82
|
+
"outputs": [],
|
83
|
+
"source": [
|
84
|
+
"lda_x=lda.fit(x,y).transform(x)\n",
|
85
|
+
"lda_x"
|
86
|
+
]
|
87
|
+
},
|
88
|
+
{
|
89
|
+
"cell_type": "code",
|
90
|
+
"execution_count": null,
|
91
|
+
"id": "94165d9a-5825-4b5b-804b-4a41b9353f9e",
|
92
|
+
"metadata": {},
|
93
|
+
"outputs": [],
|
94
|
+
"source": [
|
95
|
+
"plt.scatter(lda_x[y == 'L', 0], lda_x[y == 'L', 1], s =50, c = 'orange',label = 'L')\n",
|
96
|
+
"plt.scatter(lda_x[y == 'B', 0], lda_x[y == 'B', 1], s =50, c = 'blue',label = 'B')\n",
|
97
|
+
"plt.scatter(lda_x[y == 'R', 0], lda_x[y == 'R', 1], s =50, c = 'green',label = 'R')\n",
|
98
|
+
"plt.title('LDA plot for cmc DataSet')\n",
|
99
|
+
"plt.show()"
|
100
|
+
]
|
101
|
+
},
|
102
|
+
{
|
103
|
+
"cell_type": "code",
|
104
|
+
"execution_count": null,
|
105
|
+
"id": "7c0f9c23-7a44-4194-b5dd-5c6524b44bb9",
|
106
|
+
"metadata": {},
|
107
|
+
"outputs": [],
|
108
|
+
"source": []
|
109
|
+
}
|
110
|
+
],
|
111
|
+
"metadata": {
|
112
|
+
"kernelspec": {
|
113
|
+
"display_name": "Python 3 (ipykernel)",
|
114
|
+
"language": "python",
|
115
|
+
"name": "python3"
|
116
|
+
},
|
117
|
+
"language_info": {
|
118
|
+
"codemirror_mode": {
|
119
|
+
"name": "ipython",
|
120
|
+
"version": 3
|
121
|
+
},
|
122
|
+
"file_extension": ".py",
|
123
|
+
"mimetype": "text/x-python",
|
124
|
+
"name": "python",
|
125
|
+
"nbconvert_exporter": "python",
|
126
|
+
"pygments_lexer": "ipython3",
|
127
|
+
"version": "3.12.4"
|
128
|
+
}
|
129
|
+
},
|
130
|
+
"nbformat": 4,
|
131
|
+
"nbformat_minor": 5
|
132
|
+
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "code",
|
5
|
+
"execution_count": null,
|
6
|
+
"id": "cb7109b3-2133-4346-99cd-af7ed09252be",
|
7
|
+
"metadata": {},
|
8
|
+
"outputs": [],
|
9
|
+
"source": [
|
10
|
+
"import sys\n",
|
11
|
+
"import pandas as pd\n",
|
12
|
+
"df2 = pd.read_csv (\"E:/126156055/dataset4.csv\")\n",
|
13
|
+
"df2.to_csv ('machine.csv', index=None)\n",
|
14
|
+
"x=df2.iloc[:,3:4].values\n",
|
15
|
+
"y=df2.iloc[:,8].values\n",
|
16
|
+
"\n",
|
17
|
+
"\n",
|
18
|
+
"from sklearn.model_selection import train_test_split\n",
|
19
|
+
"X_train, X_test, y_train, y_test = train_test_split(x, y, test_size = 0.2,\n",
|
20
|
+
"random_state = 0)\n",
|
21
|
+
"from sklearn.linear_model import LinearRegression\n",
|
22
|
+
"regressor = LinearRegression()\n",
|
23
|
+
"regressor.fit(X_train, y_train)\n",
|
24
|
+
"#LinearRegression(copy_X=True, fit_intercept=True, n_jobs=None,normalize=False)\n",
|
25
|
+
"y_pred = regressor.predict(X_test)\n",
|
26
|
+
"y_pred_train = regressor.predict(X_train)\n",
|
27
|
+
"print(\"Model Score: \", regressor.score(X_test, y_test))\n",
|
28
|
+
"from sklearn.metrics import r2_score\n",
|
29
|
+
"print(\"R_square score: \", r2_score(y_test,y_pred))\n",
|
30
|
+
"import matplotlib.pyplot as plt\n",
|
31
|
+
"plt.scatter(X_train, y_train, color = 'red')\n",
|
32
|
+
"plt.plot(X_train, regressor.predict(X_train), color = 'blue')\n",
|
33
|
+
"plt.title('Y vs X (Training set)')\n",
|
34
|
+
"plt.xlabel('X')\n",
|
35
|
+
"plt.ylabel('Y')\n",
|
36
|
+
"plt.show()\n",
|
37
|
+
"plt.scatter(X_test, y_test, color = 'red')\n",
|
38
|
+
"plt.plot(X_train, regressor.predict(X_train), color = 'blue')\n",
|
39
|
+
"plt.title('Y vs X (Test set)')\n",
|
40
|
+
"plt.xlabel('X')\n",
|
41
|
+
"\n",
|
42
|
+
"\n",
|
43
|
+
"plt.ylabel('Y')\n",
|
44
|
+
"plt.show()\n",
|
45
|
+
"X_future_expereince = [[2],[4]]\n",
|
46
|
+
"print (\"Prediction :\", regressor.predict(X_future_expereince))\n",
|
47
|
+
"plt.scatter(X_future_expereince, regressor.predict(X_future_expereince),\n",
|
48
|
+
"color = 'red')\n",
|
49
|
+
"plt.plot(X_train, regressor.predict(X_train), color = 'blue')\n",
|
50
|
+
"plt.title('Y vs X (Test set)')\n",
|
51
|
+
"plt.xlabel('X')\n",
|
52
|
+
"plt.ylabel('Y')\n",
|
53
|
+
"plt.show()"
|
54
|
+
]
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"cell_type": "code",
|
58
|
+
"execution_count": null,
|
59
|
+
"id": "a39458d3-d8b7-44c9-8dfd-931a004a898a",
|
60
|
+
"metadata": {},
|
61
|
+
"outputs": [],
|
62
|
+
"source": []
|
63
|
+
}
|
64
|
+
],
|
65
|
+
"metadata": {
|
66
|
+
"kernelspec": {
|
67
|
+
"display_name": "Python 3 (ipykernel)",
|
68
|
+
"language": "python",
|
69
|
+
"name": "python3"
|
70
|
+
},
|
71
|
+
"language_info": {
|
72
|
+
"codemirror_mode": {
|
73
|
+
"name": "ipython",
|
74
|
+
"version": 3
|
75
|
+
},
|
76
|
+
"file_extension": ".py",
|
77
|
+
"mimetype": "text/x-python",
|
78
|
+
"name": "python",
|
79
|
+
"nbconvert_exporter": "python",
|
80
|
+
"pygments_lexer": "ipython3",
|
81
|
+
"version": "3.12.4"
|
82
|
+
}
|
83
|
+
},
|
84
|
+
"nbformat": 4,
|
85
|
+
"nbformat_minor": 5
|
86
|
+
}
|
@@ -0,0 +1,115 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "code",
|
5
|
+
"execution_count": null,
|
6
|
+
"id": "a305f157-3894-4887-a6e7-8f62d4269f69",
|
7
|
+
"metadata": {},
|
8
|
+
"outputs": [],
|
9
|
+
"source": [
|
10
|
+
"from sklearn import linear_model,datasets\n",
|
11
|
+
"from sklearn.model_selection import train_test_split\n",
|
12
|
+
"from sklearn.metrics import confusion_matrix\n",
|
13
|
+
"import numpy as np\n",
|
14
|
+
"import matplotlib.pyplot as plt\n",
|
15
|
+
"import itertools"
|
16
|
+
]
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"cell_type": "code",
|
20
|
+
"execution_count": null,
|
21
|
+
"id": "edf3ad16-3eab-47e8-9424-155e2702f607",
|
22
|
+
"metadata": {},
|
23
|
+
"outputs": [],
|
24
|
+
"source": [
|
25
|
+
"win = datasets.load_wine()\n",
|
26
|
+
"type(win)\n",
|
27
|
+
"win.data[:5,:]"
|
28
|
+
]
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"cell_type": "code",
|
32
|
+
"execution_count": null,
|
33
|
+
"id": "1070132c-d4c7-474d-b569-481b63209e84",
|
34
|
+
"metadata": {},
|
35
|
+
"outputs": [],
|
36
|
+
"source": [
|
37
|
+
"print(type(win.feature_names))\n",
|
38
|
+
"win.feature_names\n",
|
39
|
+
"X_train,X_test,y_train,y_test =train_test_split(win.data,win.target,test_size=0.30,random_state=7)"
|
40
|
+
]
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"cell_type": "code",
|
44
|
+
"execution_count": null,
|
45
|
+
"id": "9b53bde4-67e3-45ff-a733-5d4856cc8a6a",
|
46
|
+
"metadata": {},
|
47
|
+
"outputs": [],
|
48
|
+
"source": [
|
49
|
+
"log_reg_model = linear_model.LogisticRegression()\n",
|
50
|
+
"log_reg_model.fit(X_train,y_train)\n",
|
51
|
+
"log_reg_base_score = log_reg_model.score(X_test,y_test)\n",
|
52
|
+
"print(\"The score for the Logistic Regression Model is : \",log_reg_base_score)"
|
53
|
+
]
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"cell_type": "code",
|
57
|
+
"execution_count": null,
|
58
|
+
"id": "f9f0c932-0ea8-4c0d-9c09-fdf14b6b10d2",
|
59
|
+
"metadata": {},
|
60
|
+
"outputs": [],
|
61
|
+
"source": [
|
62
|
+
"cm = confusion_matrix(y_test,log_reg_model.predict(X_test))\n",
|
63
|
+
"print(cm)\n",
|
64
|
+
"X = win.data[:,:2]\n",
|
65
|
+
"Y = win.target\n",
|
66
|
+
"log_reg_model.fit(X,Y)\n",
|
67
|
+
"x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5\n",
|
68
|
+
"y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5\n",
|
69
|
+
"xx, yy = np.meshgrid(np.arange(x_min, x_max, .01), np.arange(y_min, y_max,\n",
|
70
|
+
".01))\n",
|
71
|
+
"Z = log_reg_model.predict(np.c_[xx.ravel(), yy.ravel()])\n",
|
72
|
+
"Z = Z.reshape(xx.shape)\n",
|
73
|
+
"plt.figure(1, figsize=(4, 3))\n",
|
74
|
+
"plt.pcolormesh(xx, yy, Z, cmap=plt.cm.Paired)\n",
|
75
|
+
"plt.scatter(X[:, 0], X[:, 1], c=Y, edgecolors='k', cmap=plt.cm.Paired)\n",
|
76
|
+
"plt.xlabel('X')\n",
|
77
|
+
"plt.ylabel('Y')\n",
|
78
|
+
"plt.xlim(xx.min(), xx.max())\n",
|
79
|
+
"plt.ylim(yy.min(), yy.max())\n",
|
80
|
+
"plt.xticks(())\n",
|
81
|
+
"plt.yticks(())\n",
|
82
|
+
"plt.show()"
|
83
|
+
]
|
84
|
+
},
|
85
|
+
{
|
86
|
+
"cell_type": "code",
|
87
|
+
"execution_count": null,
|
88
|
+
"id": "4739ed30-654d-4b0f-82eb-fafa8cf857d7",
|
89
|
+
"metadata": {},
|
90
|
+
"outputs": [],
|
91
|
+
"source": []
|
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
|
+
}
|
@@ -0,0 +1,196 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "markdown",
|
5
|
+
"metadata": {
|
6
|
+
"id": "ZiSQi85mwJak"
|
7
|
+
},
|
8
|
+
"source": [
|
9
|
+
"## ***Reqiuired Packages***"
|
10
|
+
]
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"cell_type": "code",
|
14
|
+
"execution_count": null,
|
15
|
+
"metadata": {
|
16
|
+
"executionInfo": {
|
17
|
+
"elapsed": 6,
|
18
|
+
"status": "ok",
|
19
|
+
"timestamp": 1740466961205,
|
20
|
+
"user": {
|
21
|
+
"displayName": "Jaison A",
|
22
|
+
"userId": "07006398627763032071"
|
23
|
+
},
|
24
|
+
"user_tz": -330
|
25
|
+
},
|
26
|
+
"id": "s0sHSKMhwF4e"
|
27
|
+
},
|
28
|
+
"outputs": [],
|
29
|
+
"source": [
|
30
|
+
"import pandas as pd\n",
|
31
|
+
"import numpy as np\n",
|
32
|
+
"from sklearn.model_selection import train_test_split\n",
|
33
|
+
"from sklearn.metrics import confusion_matrix\n",
|
34
|
+
"from sklearn.preprocessing import LabelEncoder\n"
|
35
|
+
]
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"cell_type": "markdown",
|
39
|
+
"metadata": {
|
40
|
+
"id": "xNrDbVDgwSc0"
|
41
|
+
},
|
42
|
+
"source": [
|
43
|
+
"## ***Load Dataset***"
|
44
|
+
]
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"cell_type": "code",
|
48
|
+
"execution_count": null,
|
49
|
+
"metadata": {
|
50
|
+
"colab": {
|
51
|
+
"base_uri": "https://localhost:8080/"
|
52
|
+
},
|
53
|
+
"executionInfo": {
|
54
|
+
"elapsed": 1905,
|
55
|
+
"status": "ok",
|
56
|
+
"timestamp": 1740466963116,
|
57
|
+
"user": {
|
58
|
+
"displayName": "Jaison A",
|
59
|
+
"userId": "07006398627763032071"
|
60
|
+
},
|
61
|
+
"user_tz": -330
|
62
|
+
},
|
63
|
+
"id": "MtmRoNj4wYOr",
|
64
|
+
"outputId": "0dc7b706-181e-4bb2-f37e-9fd1f7220c51"
|
65
|
+
},
|
66
|
+
"outputs": [],
|
67
|
+
"source": [
|
68
|
+
"from google.colab import drive\n",
|
69
|
+
"drive.mount('/content/drive')"
|
70
|
+
]
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"cell_type": "markdown",
|
74
|
+
"metadata": {
|
75
|
+
"id": "_lLnxu9a4vsX"
|
76
|
+
},
|
77
|
+
"source": [
|
78
|
+
"## ***Create Input Data and Output Data***"
|
79
|
+
]
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"cell_type": "code",
|
83
|
+
"execution_count": null,
|
84
|
+
"metadata": {
|
85
|
+
"colab": {
|
86
|
+
"base_uri": "https://localhost:8080/",
|
87
|
+
"height": 1000
|
88
|
+
},
|
89
|
+
"executionInfo": {
|
90
|
+
"elapsed": 123,
|
91
|
+
"status": "ok",
|
92
|
+
"timestamp": 1740466963241,
|
93
|
+
"user": {
|
94
|
+
"displayName": "Jaison A",
|
95
|
+
"userId": "07006398627763032071"
|
96
|
+
},
|
97
|
+
"user_tz": -330
|
98
|
+
},
|
99
|
+
"id": "g99uRIRSxLer",
|
100
|
+
"outputId": "250bfcff-a08d-420a-b72d-c297f9108cb2"
|
101
|
+
},
|
102
|
+
"outputs": [],
|
103
|
+
"source": [
|
104
|
+
"data=pd.read_csv('/content/drive/MyDrive/sem 6/Lab/ML Lab/Lab 6/titanic.csv')\n",
|
105
|
+
"display(data.head())\n",
|
106
|
+
"\n",
|
107
|
+
"\n",
|
108
|
+
"inputs=data.get(['Pclass','Sex','Age','SibSp','Fare','Cabin','Parch'])\n",
|
109
|
+
"\n",
|
110
|
+
"\n",
|
111
|
+
"inputs['Sex'].replace(['male','female'],[1,2],inplace=True)\n",
|
112
|
+
"\n",
|
113
|
+
"le=LabelEncoder()\n",
|
114
|
+
"inputs['Cabin']=le.fit_transform(inputs['Cabin'].astype(str))\n",
|
115
|
+
"#inputs['Embarked']=le.fit_transform(inputs['Embarked'].astype(str))\n",
|
116
|
+
"inputs['Age'].fillna(inputs['Age'].mean(),inplace=True)\n",
|
117
|
+
"inputs['Cabin'].fillna(inputs['Cabin'].mean(),inplace=True)\n",
|
118
|
+
"#inputs['Embarked'].fillna(inputs['Embarked'].mean(),inplace=True)\n",
|
119
|
+
"display(inputs.head())\n",
|
120
|
+
"\n",
|
121
|
+
"\n",
|
122
|
+
"targets=data.get(['Survived'])\n",
|
123
|
+
"display(targets)"
|
124
|
+
]
|
125
|
+
},
|
126
|
+
{
|
127
|
+
"cell_type": "markdown",
|
128
|
+
"metadata": {
|
129
|
+
"id": "xRVUOPSQ41xw"
|
130
|
+
},
|
131
|
+
"source": [
|
132
|
+
"## ***Perform Naive Bayes***"
|
133
|
+
]
|
134
|
+
},
|
135
|
+
{
|
136
|
+
"cell_type": "code",
|
137
|
+
"execution_count": null,
|
138
|
+
"metadata": {
|
139
|
+
"colab": {
|
140
|
+
"base_uri": "https://localhost:8080/"
|
141
|
+
},
|
142
|
+
"executionInfo": {
|
143
|
+
"elapsed": 9,
|
144
|
+
"status": "ok",
|
145
|
+
"timestamp": 1740466963249,
|
146
|
+
"user": {
|
147
|
+
"displayName": "Jaison A",
|
148
|
+
"userId": "07006398627763032071"
|
149
|
+
},
|
150
|
+
"user_tz": -330
|
151
|
+
},
|
152
|
+
"id": "fjoKWEbI4e_H",
|
153
|
+
"outputId": "a5bb1d20-21ea-4f32-9c46-5a2f91abee91"
|
154
|
+
},
|
155
|
+
"outputs": [],
|
156
|
+
"source": [
|
157
|
+
"X=inputs\n",
|
158
|
+
"y=targets\n",
|
159
|
+
"\n",
|
160
|
+
"X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=0.3, random_state =42)\n",
|
161
|
+
"from sklearn.naive_bayes import GaussianNB\n",
|
162
|
+
"gnb = GaussianNB().fit(X_train, y_train)\n",
|
163
|
+
"gnb_predictions = gnb.predict(X_test)\n",
|
164
|
+
"accuracy = gnb.score(X_test, y_test)\n",
|
165
|
+
"print(f'Accuracy : {accuracy}')\n",
|
166
|
+
"cm = confusion_matrix(y_test, gnb_predictions)\n",
|
167
|
+
"print(f'\\n\\nConfusion Matrix : \\n{cm}')"
|
168
|
+
]
|
169
|
+
}
|
170
|
+
],
|
171
|
+
"metadata": {
|
172
|
+
"colab": {
|
173
|
+
"authorship_tag": "ABX9TyP8FfIQ/MJ/dOh6Q/ByMUQd",
|
174
|
+
"provenance": []
|
175
|
+
},
|
176
|
+
"kernelspec": {
|
177
|
+
"display_name": "Python 3 (ipykernel)",
|
178
|
+
"language": "python",
|
179
|
+
"name": "python3"
|
180
|
+
},
|
181
|
+
"language_info": {
|
182
|
+
"codemirror_mode": {
|
183
|
+
"name": "ipython",
|
184
|
+
"version": 3
|
185
|
+
},
|
186
|
+
"file_extension": ".py",
|
187
|
+
"mimetype": "text/x-python",
|
188
|
+
"name": "python",
|
189
|
+
"nbconvert_exporter": "python",
|
190
|
+
"pygments_lexer": "ipython3",
|
191
|
+
"version": "3.12.4"
|
192
|
+
}
|
193
|
+
},
|
194
|
+
"nbformat": 4,
|
195
|
+
"nbformat_minor": 4
|
196
|
+
}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "code",
|
5
|
+
"execution_count": null,
|
6
|
+
"metadata": {
|
7
|
+
"colab": {
|
8
|
+
"base_uri": "https://localhost:8080/",
|
9
|
+
"height": 468
|
10
|
+
},
|
11
|
+
"executionInfo": {
|
12
|
+
"elapsed": 35,
|
13
|
+
"status": "ok",
|
14
|
+
"timestamp": 1740464645333,
|
15
|
+
"user": {
|
16
|
+
"displayName": "Jaison A",
|
17
|
+
"userId": "07006398627763032071"
|
18
|
+
},
|
19
|
+
"user_tz": -330
|
20
|
+
},
|
21
|
+
"id": "v_4SXAGau-F-",
|
22
|
+
"outputId": "a4d3c4c5-4e90-4d7c-d82e-743600472c63"
|
23
|
+
},
|
24
|
+
"outputs": [],
|
25
|
+
"source": [
|
26
|
+
"from sklearn import datasets\n",
|
27
|
+
"from sklearn.metrics import confusion_matrix\n",
|
28
|
+
"from sklearn.model_selection import train_test_split\n",
|
29
|
+
"win = datasets.load_wine()\n",
|
30
|
+
"X = win.data\n",
|
31
|
+
"display(X)\n",
|
32
|
+
"y = win.target\n",
|
33
|
+
"display(y)\n",
|
34
|
+
"\n",
|
35
|
+
"X_train, X_test, y_train, y_test = train_test_split(X, y, random_state =0)\n",
|
36
|
+
"from sklearn.naive_bayes import GaussianNB\n",
|
37
|
+
"gnb = GaussianNB().fit(X_train, y_train)\n",
|
38
|
+
"gnb_predictions = gnb.predict(X_test)\n",
|
39
|
+
"accuracy = gnb.score(X_test, y_test)\n",
|
40
|
+
"display(accuracy)\n",
|
41
|
+
"cm = confusion_matrix(y_test, gnb_predictions)\n",
|
42
|
+
"print(cm)"
|
43
|
+
]
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"cell_type": "code",
|
47
|
+
"execution_count": null,
|
48
|
+
"metadata": {
|
49
|
+
"colab": {
|
50
|
+
"base_uri": "https://localhost:8080/",
|
51
|
+
"height": 989
|
52
|
+
},
|
53
|
+
"executionInfo": {
|
54
|
+
"elapsed": 50,
|
55
|
+
"status": "ok",
|
56
|
+
"timestamp": 1740464655299,
|
57
|
+
"user": {
|
58
|
+
"displayName": "Jaison A",
|
59
|
+
"userId": "07006398627763032071"
|
60
|
+
},
|
61
|
+
"user_tz": -330
|
62
|
+
},
|
63
|
+
"id": "EhHE3W9Rxlrr",
|
64
|
+
"outputId": "cdb28b95-d0b8-496a-97c8-59190599363f"
|
65
|
+
},
|
66
|
+
"outputs": [],
|
67
|
+
"source": [
|
68
|
+
"win=datasets.load_wine()\n",
|
69
|
+
"display(win)"
|
70
|
+
]
|
71
|
+
}
|
72
|
+
],
|
73
|
+
"metadata": {
|
74
|
+
"colab": {
|
75
|
+
"authorship_tag": "ABX9TyMW6RGa7T9gSVJv4lb9rc4X",
|
76
|
+
"provenance": []
|
77
|
+
},
|
78
|
+
"kernelspec": {
|
79
|
+
"display_name": "Python 3 (ipykernel)",
|
80
|
+
"language": "python",
|
81
|
+
"name": "python3"
|
82
|
+
},
|
83
|
+
"language_info": {
|
84
|
+
"codemirror_mode": {
|
85
|
+
"name": "ipython",
|
86
|
+
"version": 3
|
87
|
+
},
|
88
|
+
"file_extension": ".py",
|
89
|
+
"mimetype": "text/x-python",
|
90
|
+
"name": "python",
|
91
|
+
"nbconvert_exporter": "python",
|
92
|
+
"pygments_lexer": "ipython3",
|
93
|
+
"version": "3.12.4"
|
94
|
+
}
|
95
|
+
},
|
96
|
+
"nbformat": 4,
|
97
|
+
"nbformat_minor": 4
|
98
|
+
}
|