58769/__MACOSX/._experiments.py
58769/__MACOSX/._results.csv
58769/experiment.ipynb
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"with open('sample.txt', 'r') as f:\n",
" data = f.read()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"data = data.split('\\n')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"firm = [int(i) for i in data[0].split()[1:]]\n",
"wc = list(map(lambda x: float(x), data[2].split()[1:]))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"for i in data[4].split():\n",
" try:\n",
" firm.append(int(i))\n",
" except:\n",
" wc.append(float(i))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"category = [ 1 for i in range(34)] + [0 for i in range(34)]"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"df_data = [\n",
" {\n",
" 'firm': f,\n",
" 'wc': w,\n",
" 'category': c\n",
" } for f, w, c in zip(firm, wc,category)\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
"\n",
"\n",
" | \n",
"firm | \n",
"wc | \n",
"category | \n",
"
\n",
"\n",
"\n",
"\n",
"0 | \n",
"1 | \n",
"309.577 | \n",
"1 | \n",
"
\n",
"\n",
"1 | \n",
"2 | \n",
"363.790 | \n",
"1 | \n",
"
\n",
"\n",
"2 | \n",
"3 | \n",
"341.399 | \n",
"1 | \n",
"
\n",
"\n",
"3 | \n",
"4 | \n",
"363.616 | \n",
"1 | \n",
"
\n",
"\n",
"4 | \n",
"5 | \n",
"323.673 | \n",
"1 | \n",
"
\n",
"\n",
"
\n",
"
"
],
"text/plain": [
" firm wc category\n",
"0 1 309.577 1\n",
"1 2 363.790 1\n",
"2 3 341.399 1\n",
"3 4 363.616 1\n",
"4 5 323.673 1"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"df = pd.DataFrame().from_records(df_data)\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"with open('sample_test.txt', 'r') as f:\n",
" data = f.read()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"data = data.split('\\n')"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"firm = [int(i) for i in data[0].split()[1:]]\n",
"wc = list(map(lambda x: float(x), data[2].split()[1:]))"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"for i in data[4].split():\n",
" try:\n",
" firm.append(int(i))\n",
" except:\n",
" wc.append(float(i))"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"category = [ 1 for i in range(34)] + [0 for i in range(34)]"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"df_data = [\n",
" {\n",
" 'firm': f,\n",
" 'wc': w,\n",
" 'category': c\n",
" } for f, w, c in zip(firm,...