# Create linear regression objectreg = linear_model.LinearRegression()reg.fit(new_df,price)
LinearRegression()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
LinearRegression()
reg.predict([[3300]])
/home/ben/mambaforge/envs/cfast/lib/python3.11/site-packages/sklearn/base.py:464: UserWarning: X does not have valid feature names, but LinearRegression was fitted with feature names
warnings.warn(
array([628813.88621022])
reg.coef_
array([167.30954677])
reg.intercept_
76692.3818707813
Y = m * X + b (m is coefficient and b is intercept)
5000*reg.coef_ + reg.intercept_
array([913240.11571842])
reg.predict([[5000]])
/home/ben/mambaforge/envs/cfast/lib/python3.11/site-packages/sklearn/base.py:464: UserWarning: X does not have valid feature names, but LinearRegression was fitted with feature names
warnings.warn(
array([913240.11571842])
Generate CSV file with list of home price predictions
Create a list of numbers from 1000 to 5000 with 500 increments
numbers_list =list(range(2000, 4000, 500))
# Create a DataFrame using the pandas constructor and a dictionarydata = {'area': numbers_list}area_df = pd.DataFrame(data)area_df