71 lines
1.6 KiB
Plaintext
71 lines
1.6 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"id": "f7e1ae0d",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import pandas as pd\n",
|
||
|
"import csv\n",
|
||
|
"from sklearn.feature_extraction.text import TfidfVectorizer\n",
|
||
|
"from sklearn.cluster import KMeans"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"id": "7582a8dd",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"#dev0\n",
|
||
|
"dev0_data = pd.read_csv('dev-0/in.tsv', header=None, quoting=csv.QUOTE_NONE, sep='\\t')\n",
|
||
|
"\n",
|
||
|
"dev0_y = KMeans(n_clusters=50).fit_predict(TfidfVectorizer().fit_transform(dev0_data[0].values))\n",
|
||
|
"\n",
|
||
|
"#zapis wyników\n",
|
||
|
"dev0_y.tofile('dev-0/out.tsv', sep='\\n')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"id": "d3c75abc",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"#TestA\n",
|
||
|
"testA_data = pd.read_csv('test-A/in.tsv', header=None, quoting=csv.QUOTE_NONE, sep='\\t')\n",
|
||
|
"\n",
|
||
|
"testA_y = KMeans(n_clusters=50).fit_predict(TfidfVectorizer().fit_transform(testA_data[0].values))\n",
|
||
|
"\n",
|
||
|
"#zapis wyników\n",
|
||
|
"testA_y.tofile('test-A/out.tsv', sep='\\n')"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.8.8"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 5
|
||
|
}
|