<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 ML Begins
Step1:  If slope is large, then that feature is more important. If slope is zero then the feature does is not important and prediction does not depend on it
Step2:  Boston dataset
<ASSISTANT_TASK:>
Python Code:
xs = np.array([1, 2, 3, 4, 5, 6])
ys = np.array([5, 4, 6, 5, 6, 7])
plt.scatter(xs, ys)
plt.show()
from sklearn.linear_model import LinearRegression
#we always assume that x is a 2d array of datapoints and features and y is a 1D array of outputs
xs = xs.reshape((6, 1))    # 6 datapoints and 1 feature
clf = LinearRegression()   # classifier
clf.fit(xs, ys)            # fit the input and output
xp = np.array([[0], [3.5], [10]])
print(xp.shape)
yp = clf.predict(xp)         # predict the output for the input data
plt.plot(xp, yp , "b", marker = "o")
plt.plot(xs, ys, 'g^')
clf.coef_, clf.intercept_    # coefficient is m (array bcoz multiple m1x1 + m2x2 + m3x3) and intercept is b
Explanation: ML Begins
End of explanation
xs2 = np.array([1, 2, 3, 4, 5, 6, 3, 5, 6, 6, 1, 8])
xs2 = xs2.reshape((6, 2))
print(xs2.shape)
ys2 = np.array([5, 4, 6, 5, 6, 7])
clf.fit(xs2, ys2)
xp2 = np.array([0, 2])
xp2 = xp2.reshape((1, 2))
print(xp2)
yp2 = clf.predict(xp2)
yp2
Explanation: If slope is large, then that feature is more important. If slope is zero then the feature does is not important and prediction does not depend on it
End of explanation
from sklearn import datasets
import pandas as pd
boston = datasets.load_boston()
print(boston.data.shape, boston.target.shape)
boston.feature_names
df = pd.DataFrame(boston.data)
df.columns = boston.feature_names
df.head()
boston.DESCR
df.describe()
clf2 = LinearRegression(normalize=True)
clf2.fit(boston.data, boston.target)
clf2.coef_, clf2.intercept_
df.describe()
clf2.score(boston.data, boston.target)
from sklearn.model_selection import train_test_split    #Now we're splitting the data using probabilitiy( we can also shuffle the data and then split simply)
x_train, x_test, y_train, y_test = train_test_split(boston.data, boston. target, test_size = 0.20, random_state = 2)  # random numbers will reamain same
x_train.shape, x_test.shape
clf2.fit(x_train, y_train)
clf2.score(x_test, y_test), clf2.score(x_train, y_train)
Explanation: Boston dataset
End of explanation
<END_TASK>