MITS5509 Assignment 3 MITS5509 Intelligent Systems for Analytics Assignment 3 MITS5509 Assignment 3 Copyright © XXXXXXXXXXVIT, All Rights Reserved. 2 NOTE: This Document is used in conjunction with...

1 answer below »

View more »
Answered Same DayMay 24, 2021MITS5509

Answer To: MITS5509 Assignment 3 MITS5509 Intelligent Systems for Analytics Assignment 3 MITS5509 Assignment 3...

Neha answered on May 30 2021
153 Votes
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",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
firmwccategory
01309.5771
12363.7901
23341.3991
34363.6161
45323.6731
\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,...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here
April
January
February
March
April
May
June
July
August
September
October
November
December
2025
2025
2026
2027
SunMonTueWedThuFriSat
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30