{ "cells": [ { "cell_type": "markdown", "id": "9b2c0348", "metadata": {}, "source": [ "Lab08\n", "\n", "Consider the following data corresponding to \n", "\n", "url=\"https://github.com/masterfloss/data/raw/main/dataBitCoins1.xlsx\"\n", "\n", "It has the following data:\n", "* date - date\n", "* ElectPrice - price of electicity\n", "* BitcoinsPrice - bitcoins prince\n", "* TresBondsPrice - US tresury bonds price\n", "* BitcoinGoogleSerch - search index in Google (obtained from google trends)\n", "\n", "Create a model for price BitcoinsPrice prediction.\n", "\n", "1. Create a Regression model (OLS) using statsmodels library\n", "\n", "2. Create a Regression model (OLS) using sklearn library \n", "\n", "3. Create several Regression models and compare accuracy\n", "\n", "\n", "# split train and test\n", "X_train, X_test, y_train, y_test = train_test_split(X, Y, random_state=1)\n", "# Create model\n", "model = linear_model.LinearRegression()\n", "# fit the model\n", "model.fit(X_train, y_train) \n", "# predict y using the X test\n", "y_test_pred=model.predict(X_test)\n", "# model acuracy\n", "metrics.r2_score(y_test, y_test_pred)\n", "" ] }, { "cell_type": "code", "execution_count": 2, "id": "a4c63a2d", "metadata": {}, "outputs": [], "source": [ "#\n", "import pandas as pd\n", "import sklearn.metrics as metrics\n", "from sklearn import linear_model\n", "from sklearn.model_selection import train_test_split" ] }, { "cell_type": "code", "execution_count": null, "id": "946fe7cf", "metadata": {}, "outputs": [], "source": [ "url=\"https://github.com/masterfloss/data/raw/main/dataBitCoins1.xlsx\"\n", "YX=pd.read_excel(url)" ] }, { "cell_type": "code", "execution_count": 6, "id": "12754402", "metadata": {}, "outputs": [], "source": [ "X=YX[['ElectPrice','TresBondsPrice','BitcoinGoogleSerch']]\n", "Y=YX['BitcoinsPrice']" ] }, { "cell_type": "code", "execution_count": 7, "id": "5a5774e9", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 16, "id": "62cb53d6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.7763197465285913" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n" ] } ], "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.9.7" } }, "nbformat": 4, "nbformat_minor": 5 }