Introduction to Regression - Machine learning



Relapse is another significant and extensively utilized measurable and AI device. The critical target of relapse based errands is to anticipate yield marks or reactions which are proceeds with numeric qualities, for the given info information. The result will be founded on what the model has realized in preparing stage. Essentially, relapse models utilize the info information highlights (autonomous factors) and their relating constant numeric result values (ward or result factors) to learn explicit relationship among inputs and comparing yields.

Types of Regression Models


Regression models are of following two types −

Simple regression model − This is the most basic regression model in which predictions are formed from a single, univariate feature of the data.

Multiple regression model − As name implies, in this regression model the predictions are formed from multiple features of the data.


import numpy as np
from sklearn import linear_model
import sklearn.metrics as sm
import matplotlib.pyplot as plt

input = r'C:\linear.txt'


input_data = np.loadtxt(input, delimiter=',')
X, y = input_data[:, :-1], input_data[:, -1]



training_samples = int(0.6 * len(X))
testing_samples = len(X) - num_training

X_train, y_train = X[:training_samples], y[:training_samples]

X_test, y_test = X[training_samples:], y[training_samples:]


reg_linear= linear_model.LinearRegression()


reg_linear.fit(X_train, y_train)


y_test_pred = reg_linear.predict(X_test)


plt.scatter(X_test, y_test, color='red')
plt.plot(X_test, y_test_pred, color='black', linewidth=2)
plt.xticks(())
plt.yticks(())
plt.show()



Building a Regressor in Python

Regressor model in Python can be developed very much like we built the classifier. Scikit-learn, a Python library for AI can likewise be utilized to fabricate a regressor in Python.


In the accompanying model, we will construct fundamental relapse model that will fit a line to the information for example direct regressor. The vital stages for building a regressor in Python are as per the following −

Introduction to Regression - Machine learning