Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- # Path of the file to read
- iowa_file_path = '../input/home-data-for-ml-course/train.csv'
- home_data = pd.read_csv(iowa_file_path)
- print(home_data.describe())
- print(home_data.head())
- print(home_data.columns)
- y = home_data.SalePrice
- # Create the list of features below
- feature_names = ['LotArea', 'YearBuilt', '1stFlrSF', '2ndFlrSF', 'FullBath', 'BedroomAbvGr', 'TotRmsAbvGrd']
- # Select data corresponding to features in feature_names
- X = home_data[feature_names]
- print(X.describe())
- print(X.head())
- from sklearn.tree import DecisionTreeRegressor
- iowa_model = DecisionTreeRegressor(random_state=1)
- iowa_model.fit(X, y)
- predictions = iowa_model.predict(X)
- print(predictions)
- print(home_data.SalePrice.head())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement