Skip to content
Open

. #354

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Best features : 3, 8\n"
]
}
],
"source": [
"import numpy as np\n",
"from matplotlib import pyplot as plt\n",
"from sklearn.decomposition import PCA\n",
"from sklearn.preprocessing import StandardScaler\n",
"\n",
"data = np.loadtxt('data.txt', delimiter='\\t', skiprows=1)\n",
"\n",
"max1a = 0\n",
"max1b = 0\n",
"max2a = 0\n",
"max2b = 0\n",
"\n",
"max1 = 0\n",
"max2 = 0\n",
"\n",
"for a in range(1, 11):\n",
" for b in range(a+1, 11):\n",
" \n",
" x1=[]\n",
" \n",
" x2=[]\n",
" \n",
" for k in range(0, data.shape[0]):\n",
" if data[k][0] == np.float64(1):\n",
" x1.append([data[k][a], data[k][b]])\n",
" \n",
" else:\n",
" x2.append([data[k][a], data[k][b]])\n",
" \n",
" x1 = StandardScaler().fit_transform(x1)\n",
" pca = PCA(n_components=1)\n",
" principalComponents1 = pca.fit_transform(x1)\n",
" #print(\"{}, {}\".format(a, b))\n",
" #print(pca.explained_variance_ratio_)\n",
" #print(x1)\n",
" #print(principalComponents1)\n",
" \n",
" if(pca.explained_variance_ratio_ > max1):\n",
" max1a = a\n",
" max1b = b\n",
" max1 = pca.explained_variance_ratio_\n",
" \n",
" x2 = StandardScaler().fit_transform(x2)\n",
" pca = PCA(n_components=1)\n",
" principalComponents1 = pca.fit_transform(x2)\n",
" #print(\"{}, {}\".format(a, b))\n",
" #print(pca.explained_variance_ratio_)\n",
" #print(x1)\n",
" #print(principalComponents1)\n",
" \n",
" if(pca.explained_variance_ratio_ > max2):\n",
" max2a = a\n",
" max2b = b\n",
" max2 = pca.explained_variance_ratio_\n",
" \n",
"print(\"Best features : {}, {}\".format(max1a, max1b))"
]
}
],
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 2. 3.201 5.77470148 ... -0.08273688 -0.31659793\n",
" 8.9705947 ]\n",
" [ 1. 1.066 0.51969346 ... -0.05726641 0.12953615\n",
" 6.40681803]\n",
" [ 2. 1.395 6.18460515 ... -0.21614335 0.6549017\n",
" 17.42562827]\n",
" ...\n",
" [ 1. 0.854 0.97744937 ... -0.14189873 0.35539943\n",
" 0.06023684]\n",
" [ 1. 0.03 0.09371179 ... -0.13902791 0.49674919\n",
" 0.07933982]\n",
" [ 2. 3.881 5.77286718 ... 0.84925859 -0.92115962\n",
" 17.13040574]]\n"
]
}
],
"source": [
"import numpy as np\n",
"\n",
"data = np.loadtxt('data.txt', delimiter='\\t', skiprows=1)\n",
"\n",
"print(data)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading