# -*- coding: utf-8 -*-
"""
Created on Tue Apr 17 06:44:47 2018

@author: Eleam Emmanuel
"""

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.tree import DecisionTreeRegressor

# importing the dataset
dataset = pd.read_csv('Position_Salaries.csv')
# take all the columns but leave the last one(-1)
# always make sure our independent variable is a matrix not a vector and 
# dependent variable can be a vector
X = dataset.iloc[:, 1:-1].values
Y = dataset.iloc[:, 2].values
                
# splitting the dataset into a training set and a test set
# x_train, x_test, y_train, y_test = train_test_split(X, Y, test_size=0.2, random_state=0)

# feature scaling
"""sc_X = StandardScaler()
x_train = sc_X.fit_transform(x_train)
x_test = sc_X.transform(x_test)
sc_Y = StandardScaler()
x_train = sc_X.fit_transform(x_train)"""

# fitting the Decision Tree regression Model to the dataset
regressor = DecisionTreeRegressor(random_state=0)
regressor.fit(X, Y)

# predicting a new result
y_pred = regressor.predict(6.5)

# Visualizing the Decision tree regression result (for higher resolution and smoother curve)
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 (Regression Model)")
plt.xlabel("Position Level")
plt.ylabel("Salary")
plt.show()
[((247, 283), 'pandas.read_csv', 'pd.read_csv', (['"""Position_Salaries.csv"""'], {}), "('Position_Salaries.csv')\n", (258, 283), True, 'import pandas as pd\n'), ((929, 966), 'sklearn.tree.DecisionTreeRegressor', 'DecisionTreeRegressor', ([], {'random_state': '(0)'}), '(random_state=0)\n', (950, 966), False, 'from sklearn.tree import DecisionTreeRegressor\n'), ((1221, 1251), 'matplotlib.pyplot.scatter', 'plt.scatter', (['X', 'Y'], {'color': '"""red"""'}), "(X, Y, color='red')\n", (1232, 1251), True, 'import matplotlib.pyplot as plt\n'), ((1310, 1356), 'matplotlib.pyplot.title', 'plt.title', (['"""Truth or Bluff (Regression Model)"""'], {}), "('Truth or Bluff (Regression Model)')\n", (1319, 1356), True, 'import matplotlib.pyplot as plt\n'), ((1357, 1385), 'matplotlib.pyplot.xlabel', 'plt.xlabel', (['"""Position Level"""'], {}), "('Position Level')\n", (1367, 1385), True, 'import matplotlib.pyplot as plt\n'), ((1386, 1406), 'matplotlib.pyplot.ylabel', 'plt.ylabel', (['"""Salary"""'], {}), "('Salary')\n", (1396, 1406), True, 'import matplotlib.pyplot as plt\n'), ((1407, 1417), 'matplotlib.pyplot.show', 'plt.show', ([], {}), '()\n', (1415, 1417), True, 'import matplotlib.pyplot as plt\n')]