{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "c52f9f8f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([37.2, 37.6, 36.8])" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import numpy as np\n", "\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", "\n", "\n", "\n", "\n", "\n", "X.dot(y)\n", "\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "512d980c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ 5, 10, 9])" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "y" ] }, { "cell_type": "code", "execution_count": 3, "id": "7d14c77f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(3, 3)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "X.shape" ] }, { "cell_type": "code", "execution_count": 4, "id": "2abdc2e6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([37.2, 37.6, 36.8])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "X.dot(y)\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "98bd6c39", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[37.2, 37.6, 36.8]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "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", "# each_price = each_price + X[i,j] * y[j]\n", " total.append(round(each_price, 1))\n", "total " ] }, { "cell_type": "code", "execution_count": null, "id": "509240d4", "metadata": {}, "outputs": [], "source": [] } ], "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.10.4" } }, "nbformat": 4, "nbformat_minor": 5 }