|
@@ -1,120 +0,0 @@
|
|
-{
|
|
|
|
- "cells": [
|
|
|
|
- {
|
|
|
|
- "cell_type": "markdown",
|
|
|
|
- "id": "a0a95b0c",
|
|
|
|
- "metadata": {},
|
|
|
|
- "source": [
|
|
|
|
- "import numpy as np\n",
|
|
|
|
- "X=np.array([[1.2,1.5,1.8],\n",
|
|
|
|
- " [1.3,1.4,1.9],\n",
|
|
|
|
- " [1.1,1.6,1.7]])\n",
|
|
|
|
- "y=np.array([5,10,9]).T\n",
|
|
|
|
- "X.dot(y)"
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- "cell_type": "code",
|
|
|
|
- "execution_count": 3,
|
|
|
|
- "id": "1a728cfe",
|
|
|
|
- "metadata": {},
|
|
|
|
- "outputs": [
|
|
|
|
- {
|
|
|
|
- "data": {
|
|
|
|
- "text/plain": [
|
|
|
|
- "(3, 3)"
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- "execution_count": 3,
|
|
|
|
- "metadata": {},
|
|
|
|
- "output_type": "execute_result"
|
|
|
|
- }
|
|
|
|
- ],
|
|
|
|
- "source": [
|
|
|
|
- "X.shape"
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- "cell_type": "code",
|
|
|
|
- "execution_count": 7,
|
|
|
|
- "id": "e87d7c01",
|
|
|
|
- "metadata": {},
|
|
|
|
- "outputs": [
|
|
|
|
- {
|
|
|
|
- "name": "stdout",
|
|
|
|
- "output_type": "stream",
|
|
|
|
- "text": [
|
|
|
|
- "1.08 µs ± 11.4 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)\n"
|
|
|
|
- ]
|
|
|
|
- }
|
|
|
|
- ],
|
|
|
|
- "source": [
|
|
|
|
- "%timeit X.dot(y)"
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- "cell_type": "code",
|
|
|
|
- "execution_count": 11,
|
|
|
|
- "id": "e7d8db84",
|
|
|
|
- "metadata": {},
|
|
|
|
- "outputs": [
|
|
|
|
- {
|
|
|
|
- "name": "stdout",
|
|
|
|
- "output_type": "stream",
|
|
|
|
- "text": [
|
|
|
|
- "41.4 µs ± 971 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)\n"
|
|
|
|
- ]
|
|
|
|
- }
|
|
|
|
- ],
|
|
|
|
- "source": [
|
|
|
|
- "%%timeit\n",
|
|
|
|
- "total=[]\n",
|
|
|
|
- "for i in range(X.shape[0]):\n",
|
|
|
|
- " each_price = 0\n",
|
|
|
|
- " for j in range(X.shape[1]):\n",
|
|
|
|
- " each_price += X[i,j] * y[j]\n",
|
|
|
|
- " total.append(round(each_price,1))\n",
|
|
|
|
- " total"
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- "cell_type": "code",
|
|
|
|
- "execution_count": null,
|
|
|
|
- "id": "a43f3738",
|
|
|
|
- "metadata": {},
|
|
|
|
- "outputs": [],
|
|
|
|
- "source": [
|
|
|
|
- "\n"
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- "cell_type": "code",
|
|
|
|
- "execution_count": null,
|
|
|
|
- "id": "319800c6",
|
|
|
|
- "metadata": {},
|
|
|
|
- "outputs": [],
|
|
|
|
- "source": []
|
|
|
|
- }
|
|
|
|
- ],
|
|
|
|
- "metadata": {
|
|
|
|
- "kernelspec": {
|
|
|
|
- "display_name": "Python 3 (ipykernel)",
|
|
|
|
- "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.10.11"
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- "nbformat": 4,
|
|
|
|
- "nbformat_minor": 5
|
|
|
|
-}
|
|
|