ahmed salah

ahmed salah

  • 1k
  • 687
  • 43.3k

How to apply decision tree regression for this file please ?

Jan 31 2024 11:35 PM

I'm beginner working on python machine learning using google colab . i face issue i can't apply decision tree regression on excel file 

price is output or Y 

other fields on excel is input 

so

How to apply decision tree regression for code below ?

i need to know how to write part related to  decision tree regression after clean data ?

what i try 

import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error

df = pd.read_excel('Data_Train.xlsx')

# For example, if there are missing values, you can fill them with the mean or median.
# df.fillna(df.mean(), inplace=True)

X = df.drop('price', axis=1) # Input features
Y = df['price'] # Output variable

# Here I split the data into training and testing sets
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2, random_state=0)


file attached with post

/forums/uploadfile/e2e758/01302024213902PM/Data_Train.zip

/forums/uploadfile/e2e758/01302024213902PM/Data_Train.xlsx


Answers (2)