<jupyter_start><jupyter_text>decision tree regression> A tutorial on How to use decision tree regression.- toc: true - badges: true- comments: true- categories: [jupyter, Regression]  0. Data Preprocessing  0.1 Importing the libraries<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd<jupyter_output><empty_output><jupyter_text>0.2 Importing the dataset<jupyter_code>dataset = pd.read_csv('Position_Salaries.csv')
dataset<jupyter_output><empty_output><jupyter_text>0.3 Split into X & y<jupyter_code>X = dataset.iloc[:, 1:-1].values
y = dataset.iloc[:, -1].values<jupyter_output><empty_output><jupyter_text>1. Training the decision tree regression model on the whole dataset<jupyter_code>from sklearn.tree import DecisionTreeRegressor
regressor = DecisionTreeRegressor()
regressor.fit(X, y)<jupyter_output><empty_output><jupyter_text>2. Predicting a new result with Linear Regression<jupyter_code>regressor.predict([[6.5]])<jupyter_output><empty_output><jupyter_text>3. Visualising the Decision Tree Regression results (higher resolution)<jupyter_code>X_grid = np.arange(min(X), max(X), 0.01)
X_grid = X_grid.reshape((len(X_grid), 1))
plt.scatter(X, y, color = 'red')
plt.plot(X_grid, regressor.predict(X_grid), color = 'blue')
plt.title('Truth or Bluff (Decision Tree Regression)')
plt.xlabel('Position level')
plt.ylabel('Salary')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12304409672830725, 'fraction_numerical': 0.013513513513513514, 'mean_word_length': 8.01923076923077, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '167663', 'license': 'Apache-2.0', 'n_tokens_mistral': 524, 'n_tokens_neox': 496, 'n_words': 109, 'path': '_notebooks/2020-10-26-Decision_tree_regression.ipynb', 'repo_name': 'Vivek2509/World_of_ML', 'size': '1406'}