Skip to content

Instantly share code, notes, and snippets.

View shashwath44's full-sized avatar
🎯
Focusing

shashwath44

🎯
Focusing
View GitHub Profile
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())
@shashwath44
shashwath44 / DTR.py
Created March 27, 2020 16:34
Article2
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()))
@shashwath44
shashwath44 / fitModel.py
Created March 25, 2020 13:42
DecisionTreeRegressor
from sklearn.tree import DecisionTreeRegressor
iowa_model = DecisionTreeRegressor(random_state=1)
iowa_model.fit(X,Y)
predictions = iowa_model.predict(X)
print(predictions)
@shashwath44
shashwath44 / trainModel.py
Last active March 25, 2020 13:29
DecisionTreeRegressor
Y = home_data.SalePrice
feature_names = ["LotArea","YearBuilt","1stFlrSF","2ndFlrSF","FullBath","BedroomAbvGr","TotRmsAbvGrd"]
X = home_data[feature_names]
@shashwath44
shashwath44 / explore.py
Last active March 25, 2020 13:23
DecisionTreeRegressor
iowa_file_path = 'shash/input/home-data-for-ml-course/train.csv'
home_data = pd.read_csv(iowa_file_path)
home_data.describe()