Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Major Project machine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
jonathan.poalses
Major Project machine
Commits
5cd7726d
Commit
5cd7726d
authored
May 18, 2023
by
Jonathan Poalses
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added GNB, KNeighbour, and SVC ML implementations
parent
d3ae4489
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
87 deletions
+87
-87
nlp_gnb.ipynb
nlp_gnb.ipynb
+30
-30
nlp_kn.ipynb
nlp_kn.ipynb
+28
-28
nlp_svc.ipynb
nlp_svc.ipynb
+29
-29
No files found.
nlp_gnb.ipynb
View file @
5cd7726d
...
...
@@ -2,12 +2,12 @@
"cells": [
{
"cell_type": "code",
"execution_count":
26
5,
"execution_count":
10
5,
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:55.264368
Z",
"start_time": "2023-05-18T01:
49:55.25900
4Z"
"end_time": "2023-05-18T01:
58:43.027132
Z",
"start_time": "2023-05-18T01:
58:43.01934
4Z"
}
},
"outputs": [],
...
...
@@ -21,7 +21,7 @@
},
{
"cell_type": "code",
"execution_count":
26
6,
"execution_count":
10
6,
"outputs": [],
"source": [
"data = vectorizer.fit_transform(edn.loads(open(\"sample_data.txt\").read()))\n",
...
...
@@ -30,29 +30,29 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:55.286323
Z",
"start_time": "2023-05-18T01:
49:55.267563
Z"
"end_time": "2023-05-18T01:
58:43.043055
Z",
"start_time": "2023-05-18T01:
58:43.026725
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
26
7,
"execution_count":
10
7,
"outputs": [],
"source": [
"X_train, X_test, y_train, y_test = train_test_split(data, target, test_size=0.2, random_state=
1999
)"
"X_train, X_test, y_train, y_test = train_test_split(data, target, test_size=0.2, random_state=
42
)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:55.292277
Z",
"start_time": "2023-05-18T01:
49:55.288051
Z"
"end_time": "2023-05-18T01:
58:43.066023
Z",
"start_time": "2023-05-18T01:
58:43.054110
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
26
8,
"execution_count":
10
8,
"outputs": [],
"source": [
"from sklearn.naive_bayes import GaussianNB"
...
...
@@ -60,21 +60,21 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:55.298594
Z",
"start_time": "2023-05-18T01:
49:55.295927
Z"
"end_time": "2023-05-18T01:
58:43.066927
Z",
"start_time": "2023-05-18T01:
58:43.060309
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
26
9,
"execution_count":
10
9,
"outputs": [
{
"data": {
"text/plain": "
KNeighborsClassifier
()",
"text/html": "<style>#sk-container-id-
25 {color: black;background-color: white;}#sk-container-id-25 pre{padding: 0;}#sk-container-id-25 div.sk-toggleable {background-color: white;}#sk-container-id-25 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-25 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-25 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-25 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-25 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-25 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-25 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-25 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-25 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-25 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-25 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-25 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-25 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-25 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-25 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-25 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-25 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-25 div.sk-item {position: relative;z-index: 1;}#sk-container-id-25 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-25 div.sk-item::before, #sk-container-id-25 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-25 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-25 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-25 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-25 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-25 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-25 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-25 div.sk-label-container {text-align: center;}#sk-container-id-25 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-25 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-25\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>KNeighborsClassifier()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-25\" type=\"checkbox\" checked><label for=\"sk-estimator-id-25\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">KNeighborsClassifier</label><div class=\"sk-toggleable__content\"><pre>KNeighborsClassifier
()</pre></div></div></div></div></div>"
"text/plain": "
GaussianNB
()",
"text/html": "<style>#sk-container-id-
14 {color: black;background-color: white;}#sk-container-id-14 pre{padding: 0;}#sk-container-id-14 div.sk-toggleable {background-color: white;}#sk-container-id-14 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-14 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-14 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-14 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-14 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-14 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-14 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-14 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-14 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-14 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-14 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-14 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-14 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-14 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-14 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-14 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-14 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-14 div.sk-item {position: relative;z-index: 1;}#sk-container-id-14 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-14 div.sk-item::before, #sk-container-id-14 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-14 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-14 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-14 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-14 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-14 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-14 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-14 div.sk-label-container {text-align: center;}#sk-container-id-14 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-14 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-14\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>GaussianNB()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-14\" type=\"checkbox\" checked><label for=\"sk-estimator-id-14\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">GaussianNB</label><div class=\"sk-toggleable__content\"><pre>GaussianNB
()</pre></div></div></div></div></div>"
},
"execution_count":
26
9,
"execution_count":
10
9,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -86,14 +86,14 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:55.315007
Z",
"start_time": "2023-05-18T01:
49:55.303883
Z"
"end_time": "2023-05-18T01:
58:43.077601
Z",
"start_time": "2023-05-18T01:
58:43.067375
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
27
0,
"execution_count":
11
0,
"outputs": [],
"source": [
"predicted=gnb.predict((X_test).toarray())\n",
...
...
@@ -102,20 +102,20 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:55.33029
7Z",
"start_time": "2023-05-18T01:
49:55.311459
Z"
"end_time": "2023-05-18T01:
58:43.08248
7Z",
"start_time": "2023-05-18T01:
58:43.078846
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
27
1,
"execution_count":
11
1,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"
20
.00%\n"
"
75
.00%\n"
]
}
],
...
...
@@ -126,20 +126,20 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:55.35731
3Z",
"start_time": "2023-05-18T01:
49:55.3267
80Z"
"end_time": "2023-05-18T01:
58:43.09374
3Z",
"start_time": "2023-05-18T01:
58:43.0842
80Z"
}
}
},
{
"cell_type": "code",
"execution_count":
27
2,
"execution_count":
11
2,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"
20
.00%\n"
"
75
.00%\n"
]
}
],
...
...
@@ -149,8 +149,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:55.362376
Z",
"start_time": "2023-05-18T01:
49:55.341241
Z"
"end_time": "2023-05-18T01:
58:43.109002
Z",
"start_time": "2023-05-18T01:
58:43.087892
Z"
}
}
}
...
...
nlp_kn.ipynb
View file @
5cd7726d
...
...
@@ -2,12 +2,12 @@
"cells": [
{
"cell_type": "code",
"execution_count":
2
57,
"execution_count": 57,
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:38.014295
Z",
"start_time": "2023-05-18T01:
49:38.00738
7Z"
"end_time": "2023-05-18T01:
58:46.040817
Z",
"start_time": "2023-05-18T01:
58:46.03609
7Z"
}
},
"outputs": [],
...
...
@@ -21,7 +21,7 @@
},
{
"cell_type": "code",
"execution_count":
2
58,
"execution_count": 58,
"outputs": [],
"source": [
"data = vectorizer.fit_transform(edn.loads(open(\"sample_data.txt\").read()))\n",
...
...
@@ -30,29 +30,29 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:38.035222
Z",
"start_time": "2023-05-18T01:
49:38.012819
Z"
"end_time": "2023-05-18T01:
58:46.083314
Z",
"start_time": "2023-05-18T01:
58:46.042782
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
2
59,
"execution_count": 59,
"outputs": [],
"source": [
"X_train, X_test, y_train, y_test = train_test_split(data, target, test_size=0.2, random_state=
1999
)"
"X_train, X_test, y_train, y_test = train_test_split(data, target, test_size=0.2, random_state=
42
)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:38.048317
Z",
"start_time": "2023-05-18T01:
49:38.038940
Z"
"end_time": "2023-05-18T01:
58:46.099054
Z",
"start_time": "2023-05-18T01:
58:46.093034
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
2
60,
"execution_count": 60,
"outputs": [],
"source": [
"from sklearn.neighbors import KNeighborsClassifier"
...
...
@@ -60,21 +60,21 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:38.053101
Z",
"start_time": "2023-05-18T01:
49:38.046545
Z"
"end_time": "2023-05-18T01:
58:46.103466
Z",
"start_time": "2023-05-18T01:
58:46.099846
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
2
61,
"execution_count": 61,
"outputs": [
{
"data": {
"text/plain": "
GaussianNB
()",
"text/html": "<style>#sk-container-id-
24 {color: black;background-color: white;}#sk-container-id-24 pre{padding: 0;}#sk-container-id-24 div.sk-toggleable {background-color: white;}#sk-container-id-24 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-24 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-24 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-24 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-24 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-24 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-24 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-24 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-24 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-24 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-24 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-24 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-24 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-24 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-24 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-24 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-24 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-24 div.sk-item {position: relative;z-index: 1;}#sk-container-id-24 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-24 div.sk-item::before, #sk-container-id-24 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-24 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-24 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-24 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-24 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-24 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-24 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-24 div.sk-label-container {text-align: center;}#sk-container-id-24 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-24 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-24\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>GaussianNB()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-24\" type=\"checkbox\" checked><label for=\"sk-estimator-id-24\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">GaussianNB</label><div class=\"sk-toggleable__content\"><pre>GaussianNB
()</pre></div></div></div></div></div>"
"text/plain": "
KNeighborsClassifier
()",
"text/html": "<style>#sk-container-id-
8 {color: black;background-color: white;}#sk-container-id-8 pre{padding: 0;}#sk-container-id-8 div.sk-toggleable {background-color: white;}#sk-container-id-8 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-8 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-8 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-8 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-8 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-8 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-8 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-8 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-8 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-8 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-8 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-8 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-8 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-8 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-8 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-8 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-8 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-8 div.sk-item {position: relative;z-index: 1;}#sk-container-id-8 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-8 div.sk-item::before, #sk-container-id-8 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-8 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-8 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-8 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-8 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-8 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-8 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-8 div.sk-label-container {text-align: center;}#sk-container-id-8 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-8 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-8\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>KNeighborsClassifier()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-8\" type=\"checkbox\" checked><label for=\"sk-estimator-id-8\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">KNeighborsClassifier</label><div class=\"sk-toggleable__content\"><pre>KNeighborsClassifier
()</pre></div></div></div></div></div>"
},
"execution_count":
2
61,
"execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -86,14 +86,14 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:38.074733
Z",
"start_time": "2023-05-18T01:
49:38.058388
Z"
"end_time": "2023-05-18T01:
58:46.117344
Z",
"start_time": "2023-05-18T01:
58:46.110609
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
2
62,
"execution_count": 62,
"outputs": [],
"source": [
"predicted=knc.predict(X_test)\n",
...
...
@@ -102,14 +102,14 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:38.086974
Z",
"start_time": "2023-05-18T01:
49:38.072132
Z"
"end_time": "2023-05-18T01:
58:46.122772
Z",
"start_time": "2023-05-18T01:
58:46.118837
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
2
63,
"execution_count": 63,
"outputs": [
{
"name": "stdout",
...
...
@@ -126,14 +126,14 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:38.087358
Z",
"start_time": "2023-05-18T01:
49:38.077370
Z"
"end_time": "2023-05-18T01:
58:46.126935
Z",
"start_time": "2023-05-18T01:
58:46.124164
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
2
64,
"execution_count": 64,
"outputs": [
{
"name": "stdout",
...
...
@@ -149,8 +149,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:
49:38.090517
Z",
"start_time": "2023-05-18T01:
49:38.085248
Z"
"end_time": "2023-05-18T01:
58:46.132578
Z",
"start_time": "2023-05-18T01:
58:46.128149
Z"
}
}
}
...
...
nlp_svc.ipynb
View file @
5cd7726d
...
...
@@ -2,12 +2,12 @@
"cells": [
{
"cell_type": "code",
"execution_count":
366
,
"execution_count":
438
,
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2023-05-18T01:5
3:55.66645
2Z",
"start_time": "2023-05-18T01:5
3:55.643356
Z"
"end_time": "2023-05-18T01:5
8:39.30849
2Z",
"start_time": "2023-05-18T01:5
8:39.302389
Z"
}
},
"outputs": [],
...
...
@@ -21,7 +21,7 @@
},
{
"cell_type": "code",
"execution_count":
367
,
"execution_count":
439
,
"outputs": [],
"source": [
"data = vectorizer.fit_transform(edn.loads(open(\"sample_data.txt\").read()))\n",
...
...
@@ -30,29 +30,29 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:5
3:55.696031
Z",
"start_time": "2023-05-18T01:5
3:55.66031
8Z"
"end_time": "2023-05-18T01:5
8:39.340125
Z",
"start_time": "2023-05-18T01:5
8:39.31210
8Z"
}
}
},
{
"cell_type": "code",
"execution_count":
368
,
"execution_count":
440
,
"outputs": [],
"source": [
"X_train, X_test, y_train, y_test = train_test_split(data, target, test_size=0.2, random_state=
1999
)"
"X_train, X_test, y_train, y_test = train_test_split(data, target, test_size=0.2, random_state=
42
)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:5
3:55.703863
Z",
"start_time": "2023-05-18T01:5
3:55.699895
Z"
"end_time": "2023-05-18T01:5
8:39.351322
Z",
"start_time": "2023-05-18T01:5
8:39.341456
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
369
,
"execution_count":
441
,
"outputs": [],
"source": [
"from sklearn.svm import SVC"
...
...
@@ -60,21 +60,21 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:5
3:55.709149
Z",
"start_time": "2023-05-18T01:5
3:55.705840
Z"
"end_time": "2023-05-18T01:5
8:39.368348
Z",
"start_time": "2023-05-18T01:5
8:39.355705
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
370
,
"execution_count":
442
,
"outputs": [
{
"data": {
"text/plain": "SVC()",
"text/html": "<style>#sk-container-id-
37 {color: black;background-color: white;}#sk-container-id-37 pre{padding: 0;}#sk-container-id-37 div.sk-toggleable {background-color: white;}#sk-container-id-37 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-37 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-37 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-37 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-37 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-37 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-37 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-37 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-37 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-37 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-37 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-37 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-37 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-37 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-37 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-37 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-37 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-37 div.sk-item {position: relative;z-index: 1;}#sk-container-id-37 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-37 div.sk-item::before, #sk-container-id-37 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-37 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-37 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-37 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-37 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-37 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-37 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-37 div.sk-label-container {text-align: center;}#sk-container-id-37 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-37 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-37\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>SVC()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-37\" type=\"checkbox\" checked><label for=\"sk-estimator-id-37
\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">SVC</label><div class=\"sk-toggleable__content\"><pre>SVC()</pre></div></div></div></div></div>"
"text/html": "<style>#sk-container-id-
46 {color: black;background-color: white;}#sk-container-id-46 pre{padding: 0;}#sk-container-id-46 div.sk-toggleable {background-color: white;}#sk-container-id-46 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-46 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-46 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-46 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-46 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-46 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-46 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-46 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-46 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-46 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-46 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-46 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-46 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-46 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-46 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-46 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-46 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-46 div.sk-item {position: relative;z-index: 1;}#sk-container-id-46 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-46 div.sk-item::before, #sk-container-id-46 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-46 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-46 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-46 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-46 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-46 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-46 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-46 div.sk-label-container {text-align: center;}#sk-container-id-46 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-46 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-46\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>SVC()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-46\" type=\"checkbox\" checked><label for=\"sk-estimator-id-46
\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">SVC</label><div class=\"sk-toggleable__content\"><pre>SVC()</pre></div></div></div></div></div>"
},
"execution_count":
370
,
"execution_count":
442
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -86,14 +86,14 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:5
3:55.729099
Z",
"start_time": "2023-05-18T01:5
3:55.719679
Z"
"end_time": "2023-05-18T01:5
8:39.384555
Z",
"start_time": "2023-05-18T01:5
8:39.371641
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
371
,
"execution_count":
443
,
"outputs": [],
"source": [
"predicted=svc.predict(X_test)\n",
...
...
@@ -102,20 +102,20 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:5
3:55.733844
Z",
"start_time": "2023-05-18T01:5
3:55.730968
Z"
"end_time": "2023-05-18T01:5
8:39.393847
Z",
"start_time": "2023-05-18T01:5
8:39.386304
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
372
,
"execution_count":
444
,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"
3
5.00%\n"
"
5
5.00%\n"
]
}
],
...
...
@@ -126,20 +126,20 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:5
3:55.738217
Z",
"start_time": "2023-05-18T01:5
3:55.735115
Z"
"end_time": "2023-05-18T01:5
8:39.405299
Z",
"start_time": "2023-05-18T01:5
8:39.395221
Z"
}
}
},
{
"cell_type": "code",
"execution_count":
373
,
"execution_count":
445
,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"
3
5.00%\n"
"
5
5.00%\n"
]
}
],
...
...
@@ -149,8 +149,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-05-18T01:5
3:55.744380
Z",
"start_time": "2023-05-18T01:5
3:55.740566
Z"
"end_time": "2023-05-18T01:5
8:39.413605
Z",
"start_time": "2023-05-18T01:5
8:39.407510
Z"
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment