This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn.model_selection import train_test_split | |
| train_X, val_X, train_y, val_y = train_test_split(X,y,random_state=1) | |
| iowa_model = DecisionTreeRegressor(random_state=1) | |
| iowa_model.fit(train_X,train_y) | |
| val_predictions = iowa_model.predict(val_X) | |
| print(iowa_model.predict(val_X.head())) | |
| print(val_y.head()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| from sklearn.tree import DecisionTreeRegressor | |
| iowa_file_path = 'shash/input/home-data-for-ml-course/train.csv' | |
| home_data = pd.read_csv(iowa_file_path) | |
| y = home_data.SalePrice | |
| feature_columns = ['LotArea', 'YearBuilt', '1stFlrSF', '2ndFlrSF', 'FullBath', 'BedroomAbvGr', 'TotRmsAbvGrd'] | |
| X = home_data[feature_columns] | |
| iowa_model = DecisionTreeRegressor(random_state=1) | |
| iowa_model.fit(X, y) | |
| print("First in-sample predictions:", iowa_model.predict(X.head())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn.tree import DecisionTreeRegressor | |
| iowa_model = DecisionTreeRegressor(random_state=1) | |
| iowa_model.fit(X,Y) | |
| predictions = iowa_model.predict(X) | |
| print(predictions) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Y = home_data.SalePrice | |
| feature_names = ["LotArea","YearBuilt","1stFlrSF","2ndFlrSF","FullBath","BedroomAbvGr","TotRmsAbvGrd"] | |
| X = home_data[feature_names] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| iowa_file_path = 'shash/input/home-data-for-ml-course/train.csv' | |
| home_data = pd.read_csv(iowa_file_path) | |
| home_data.describe() |