Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLSS assign 1 #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
181 changes: 181 additions & 0 deletions mlss18-assignment1/Assignment_1_1/Assignment_1_1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pickle\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## Code to load the array\n",
"with open('array.pickle', 'rb') as p:\n",
" arr = pickle.load(p)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Check that the size of the array (arr) is 1000. Please report if any discrepancy."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Task 1: Resize the array to a (20x50) matrix"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## BEGIN CODE\n",
"arr.resize(20,50)\n",
"## END CODE"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Task 2: Find the transpose of this matrix"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## BEGIN CODE\n",
"brr=arr.T\n",
"## END CODE"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Task 3: Find the dot product of the matrices created in Tasks 1 & 2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## BEGIN CODE\n",
"crr=arr.dot(brr)\n",
"## END CODE"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Task 4: Find the row-wise sum of the resulting matrix"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## BEGIN CODE\n",
"n=np.sum(crr,axis=1)\n",
"## END CODE"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Task 5: Find the square root of all elements in the resulting matrix"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## BEGIN CODE\n",
"sn = np.sqrt(crr)\n",
"## END CODE"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Task 6: Find the sine value of all elements in the resulting matrix"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## BEGIN CODE\n",
"vp = np.sin(crr)\n",
"## END CODE"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create submission file"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## Assign the name of the variable containing the final matrix to VARIABLE_NAME variable.\n",
"\n",
"VARIABLE_NAME = vp\n",
"with open('submission.pickle', 'wb') as p:\n",
" pickle.dump(VARIABLE_NAME, p)"
]
}
],
"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.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Binary file added mlss18-assignment1/Assignment_1_1/array.pickle
Binary file not shown.
Loading