1from sklearn.linear_model import LinearRegression
2X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])
3y = np.dot(X, np.array([1, 2])) + 3
4reg = LinearRegression().fit(X, y)
5reg.score(X, y)
6reg.coef_
7reg.intercept_
8reg.predict(np.array([[3, 5]]))
1# import the class
2from sklearn.linear_model import LogisticRegression
3
4# instantiate the model (using the default parameters)
5logreg = LogisticRegression()
6
7# fit the model with data
8logreg.fit(X_train,y_train)
9
10#
11y_pred=logreg.predict(X_test)
12
1from sklearn.linear_model import LinearRegression
2#x, y = np.array([0,1,2,3,4,5])
3
4model = LinearRegression().fit(x.reshape(-1,1), y.reshape(-1,1))
5r_sq = model.score(x.reshape(-1,1), y.reshape(-1,1))
6q = model.intercept_
7m = model.coef_
8
9y_fit = np.array([i*m[0] for i in x]+q[0])
1from sklearn.linear_model import LinearRegression
2lm = LinearRegression()
3lm.fit(X, y)
1>>> from scipy import stats
2>>> import numpy as np
3>>> x = np.random.random(10)
4>>> y = np.random.random(10)
5>>> slope, intercept, r_value, p_value, std_err = stats.linregress(x,y)
6
1
2import seaborn as sb
3from matplotlib import pyplot as plt
4df = sb.load_dataset('tips')
5sb.regplot(x = "total_bill", y = "tip", data = df)
6plt.show()