Closed marco-c closed 1 year ago
Linear Regression for Training set
`from sklearn.model_selection import train_test_split'
'from sklearn.linear_model import LinearRegression'
'from sklearn.metrics import mean_squared_error'
'import matplotlib.pyplot as plt'
'import pandas as pd'
'import numpy as np`
'housing = pd.read_csv('housing.csv')'
'housing.shape'
'x_train, x_test, y_train, y_test = train_test_split(housing.median_income, housing.median_house_value, test_size = 0.2)'
'regr = LinearRegression()'
'regr.fit(np.array(x_train).reshape(-1,1), y_train)'
'preds = regr.predict(np.array(x_test).reshape(-1,1))'
'y_test.head()'
'pred'
'residuals = preds - y_test'
'plt.hist(residuals)'
'mean_squared_error(y_test, preds) ** 0.5'
reference: 'https://towardsdatascience.com/linear-regression-on-housing-csv-data-kaggle-10b0edc550ed'
Link to my google colab using linear regresssion for training dataset
https://colab.research.google.com/drive/1G9Ttnqo5qwKZhN4RY6N5Gvo3-D_9tO9g?usp=sharing
RegressionModel A regression model provides a function that describes the relationship between one or more independent variables and a response, dependent, or target variable. Predictive modelling techniques such as regression model may be used to determine the relationship between a dataset’s dependent (goal) and independent variables. It is widely used when the dependent and independent variables are linked in a linear or non-linear fashion, and the target variable has a set of continuous values. Thus, regression model approaches help establish causal relationships between variables, modelling time series, and forecasting. Differents RegressionModel to the training set