input_data np loadtxt(inputdelimiter=','xy input_data[::- ]input_data[:- step organizing data into training testing sets as we need to test our model on unseen data hencewe will divide our dataset into two partsa training set and test set the following command will perform ittraining_samples int( len( )testing_samples len(xnum_training x_trainy_train [:training_samples] [:training_samplesx_testy_test [training_samples:] [training_samples:step model evaluation prediction after dividing the data into training and testing we need to build the model we will be using linearegression(function of scikit-learn for this purpose following command will create linear regressor object reg_linearlinear_model linearregression(nexttrain this model with the training samples as followsreg_linear fit(x_trainy_trainnowat last we need to do the prediction with the testing data y_test_pred reg_linear predict(x_teststep plot visualization after predictionwe can plot and visualize it with the help of following scriptplt scatter(x_testy_testcolor='red'plt plot(x_testy_test_predcolor='black'linewidth= plt xticks(()plt yticks(()plt show(