Decision Tree Regression | Machine Learning Algorithm

In this ML Algorithms course tutorial, we are going to learn “Decision Tree Regression in detail. we covered it by practically and theoretical intuition.

  1. What is Decision Tree?
  2. What are decision trees used for?
  3. How do Decision trees work?
  4. What is Decision Tree Regression?
  5. What is Gini impurity, entropy, cost function for CART algorithm?
  6. What is decision tree diagram?
  7. What is the difference between decision tree and random forest?
  8. How to implement Decision Tree Regression in python using sklearn?

Decision Tree Regression Source Code

# -*- coding: utf-8 -*-
"""Decision Tree Regression.ipynb

Automatically generated by Colaboratory.

Original file is located at

## Business Problem - Predict the Price of Bangalore House

Using Decision Tree Regression - Supervised Machine Learning Algorithm

### Load Libraries

import pandas as pd

"""### Load Data"""

path = r"" 
df = pd.read_csv(path)


"""## Split Data"""

X = df.drop('price', axis=1)
y = df['price']

print('Shape of X = ', X.shape)
print('Shape of y = ', y.shape)

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=51)

print('Shape of X_train = ', X_train.shape)
print('Shape of y_train = ', y_train.shape)
print('Shape of X_test = ', X_test.shape)
print('Shape of y_test = ', y_test.shape)

"""##Decision Tree Regression - ML Model Training"""

from sklearn.tree import DecisionTreeRegressor

regressor = DecisionTreeRegressor(criterion='mse'), y_train)

regressor.score(X_test, y_test)

"""## Predict the value of Home"""

X_test.iloc[-1, :]

regressor.predict([X_test.iloc[-1, :]])


pred = regressor.predict(X_test)


"""Ab milenge next tutorial me,Tab tak ke liye SIKHATE SIKHATE kuch IMPLEMENT karte raho, Thank You.....-:)"""

Leave a Reply