generate functionThu, 06 Apr 2023

Implement Regularized Regression for house price prediction and evaluate there accuracy using sckitlearn. • Ridge Regression • Lasso Regression

def get_regressor(name): if name == 'ridge': return Ridge() elif name == 'lasso': return Lasso() else: return None regressors = ['ridge', 'lasso'] for reg_name in regressors: regressor = get_regressor(reg_name), y_train) y_pred = regressor.predict(X_test) print('Regressor: {}'.format(reg_name)) print('R^2: {}'.format(r2_score(y_test, y_pred))) print('RMSE: {}'.format(np.sqrt(mean_squared_error(y_test, y_pred)))) print()

Questions about programming?Chat with your personal AI assistant