{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "b6bf609f", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.10/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] }, { "data": { "text/html": [ "
RandomForestRegressor()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
" ], "text/plain": [ "RandomForestRegressor()" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import shap\n", "import pandas as pd\n", "from sklearn.datasets import fetch_california_housing\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.ensemble import RandomForestRegressor# California Housing Prices\n", "dataset = fetch_california_housing(as_frame = True)\n", "X = dataset['data']\n", "y = dataset['target']\n", "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2)# Prepares a default instance of the random forest regressor\n", "model = RandomForestRegressor()# Fits the model on the data\n", "model.fit(X_train, y_train)" ] }, { "cell_type": "code", "execution_count": null, "id": "9b24b4df", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "1cc7f2dc", "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.8" } }, "nbformat": 4, "nbformat_minor": 5 }