Skip to content

Commit

Permalink
Fix error and add vote
Browse files Browse the repository at this point in the history
  • Loading branch information
Bombenchris committed Nov 3, 2019
1 parent 028ec47 commit c56619c
Show file tree
Hide file tree
Showing 8 changed files with 25,113 additions and 68 deletions.
463 changes: 395 additions & 68 deletions Task2NN.ipynb

Large diffs are not rendered by default.

4,101 changes: 4,101 additions & 0 deletions best702.csv

Large diffs are not rendered by default.

4,101 changes: 4,101 additions & 0 deletions best707.csv

Large diffs are not rendered by default.

4,101 changes: 4,101 additions & 0 deletions best719.csv

Large diffs are not rendered by default.

4,101 changes: 4,101 additions & 0 deletions best724.csv

Large diffs are not rendered by default.

4,101 changes: 4,101 additions & 0 deletions best725.csv

Large diffs are not rendered by default.

112 changes: 112 additions & 0 deletions vote.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import random"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[1, 1, 1, 1, 1], [0, 0, 2, 0, 0], [1, 1, 1, 1, 1], [2, 0, 2, 1, 2], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 1, 1, 0, 1]]\n"
]
}
],
"source": [
"candidates = [\"best702.csv\", \"best707.csv\", \"best719.csv\", \"best724.csv\",\"best725.csv\"]\n",
"result = [list() for i in range(4100)]\n",
"\n",
"for f in candidates:\n",
" f = open(f)\n",
" lines = f.readlines()\n",
" for l in lines[1:]:\n",
" l = l.strip().split(',')\n",
" idx, val = int(l[0]), int(float(l[1]))\n",
" result[idx].append(val)\n",
" f.close()\n",
"print(result[:10])\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n"
]
}
],
"source": [
"def vote(x):\n",
" c = [0] * 3\n",
" for i in x:\n",
" c[i] += 1\n",
" c = [(0, c[0]), (1, c[1]), (2, c[2])]\n",
" c.sort(key = lambda x: x[1], reverse = True)\n",
" if c[0][1] > c[1][1]:\n",
" return c[0][0]\n",
" else:\n",
" if c[0][0] == 1 or c[1][0] == 1:\n",
" return 1\n",
" else:\n",
" return random.choice([c[0][0], c[1][0]])\n",
"print(vote([1,2,0,0,0]))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"with open(\"voted.csv\", \"w\") as f:\n",
" f.write(\"id,y\\n\")\n",
" for i in range(4100):\n",
" f.write(\"{},{}\\n\".format(i, vote(result[i])))\n",
" f.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:root] *",
"language": "python",
"name": "conda-root-py"
},
"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.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit c56619c

Please sign in to comment.