Can you improve this model import matplotlib.pyplot as plt from sklearn.datasets import…
Jump to turn (8)
- 1Can you improve this model import matplotlib.pyplot as plt from sklearn.datasets
- 2improve my writing and make it narrative styled essay. When I was younger, I use
- 3clarify this sentence and improve it. So I thought anyone could receive “good ne
- 4this sentence too. However, as I read bible daily and getting answers from my ea
- 5It’s my second gap year. I rejected by all the universities and colleges. So I t
- 6I’ am also taking a data science, machine learning courses to planning to make m
- 7I was preparing for the Chemistry Olympiad before the quarantine. And my vision
- 8make it 250 words. Prior to the commencement of the quarantine, I had been thoro
- User
Can you improve this model import matplotlib.pyplot as plt from sklearn.datasets import fetch_openml from sklearn.metrics import r2_score from sklearn.metrics import mean_squared_error from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split import warnings warnings.filterwarnings("ignore") df_boston = fetch_openml(name= "boston", as_frame=True)['frame'] input_cols = df_boston.columns.tolist() target = 'MEDV' input_cols.remove(target) train_df, test_df = train_test_split(df_boston, test_size=0.4, random_state=42, shuffle=True) for col in input_cols: train_df[col] = train_df[col].astype('float32') test_df[col] = test_df[col].astype('float32') reg = LinearRegression().fit(train_df[input_cols], train_df[target]) pred = reg.predict(test_df[input_cols]) print('MSE:', mean_squared_error(test_df[target], pred)) print('R2 score ', r2_score(test_df[target],pred)) #plt.hist(df_boston[target]) #plt.show() plt.scatter(x=pred, y=test_df[target].values) plt.show()
- Assistant