#define independent and dependent features X = salary_data.drop(columns = 'salary_in_usd') y = salary_data['salary_in_usd'] #split between training and testing sets X_train, X_test, y_train, y_test = train_test_split( X, y, random_state = 104, test_size = 0.2, shuffle = True) #fit linear regression model regr = linear_model.LinearRegression() regr.fit(X_train, y_train) #make predictions y_pred = regr.predict(X_test) #print the coefficients print("Coefficients: n", regr.coef_) #print the MSE print("Mean squared error: %.2f" % mean_squared_error(y_test, y_pred)) #print the adjusted R2 value print("R2: %.2f" % r2_score(y_test, y_pred))