Skip to content

Instantly share code, notes, and snippets.

Created Feb 15, 2021
What would you like to do?
import pandas as pd
from sklearn.model_selection import train_test_split
data = pd.read_csv("melb.csv")
columns = ["Rooms", "Distance", "Landsize", "BuildingArea", "YearBuilt"]
x = data[columns]
y = data.Price
x_train, x_test, y_train, y_test = train_test_split(x, y)
from sklearn.ensemble import RandomForestRegressor
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import Imputer
pipe = make_pipeline(Imputer(), RandomForestRegressor()), y_train)
predictions = pipe.predict(x_test)
imputer = Imputer()
model = RandomForestRegressor()
imputed_x_train = imputer.fit_transform(x_train)
imputed_x_test = imputer.transform(x_test), y_train)
predictions = model.predict(imputed_x_test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment