<jupyter_start><jupyter_text>Welcome to your notebook.<jupyter_code>print('hello notebook')<jupyter_output>hello notebook<jupyter_text>Add imports by typing the following code:<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets, linear_model, model_selection<jupyter_output><empty_output><jupyter_text>Add some print commands to show the shape of the data matrix and its first element:<jupyter_code>X, y = datasets.load_diabetes(return_X_y=True)
print(X.shape)
print(X[0])<jupyter_output>(442, 10)
[ 0.03807591  0.05068012  0.06169621  0.02187235 -0.0442235  -0.03482076
 -0.04340085 -0.00259226  0.01990842 -0.01764613]<jupyter_text>Select a portion of this dataset to plot by arranging it into a new array using numpy's newaxis function. We are going to use linear regression to generate a line between values in this data, according to a pattern it determines.<jupyter_code>X = X[:, np.newaxis, 2]
X[0:5]<jupyter_output><empty_output><jupyter_text>Now that you have data ready to be plotted, you can see if a machine can help determine a logical split between the numbers in this dataset. To do this, you need to split both the data (X) and the target (y) into test and training sets. Scikit-learn has a straightforward way to do this; you can split your test data at a given point.<jupyter_code>X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, test_size=0.33)<jupyter_output><empty_output><jupyter_text>Now you are ready to train your model! Load up the linear regression model and train it with your X and y training sets using model.fit():<jupyter_code>model = linear_model.LinearRegression()
model.fit(X_train, y_train)<jupyter_output><empty_output><jupyter_text>Then, create a prediction using test data, using the function predict(). This will be used to draw the line between data groups<jupyter_code>y_pred = model.predict(X_test)<jupyter_output><empty_output><jupyter_text>Now it's time to show the data in a plot. Matplotlib is a very useful tool for this task. Create a scatterplot of all the X and y test data, and use the prediction to draw a line in the most appropriate place, between the model's data groupings.<jupyter_code>plt.scatter(X_test, y_test,  color='black')
plt.plot(X_test, y_pred, color='blue', linewidth=3)
plt.xlabel('Scaled BMIs')
plt.ylabel('Disease Progression')
plt.title('A Graph Plot Showing Diabetes Progression Against BMI')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08289738430583501, 'fraction_numerical': 0.04104627766599597, 'mean_word_length': 6.082621082621083, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '466395', 'license': 'MIT', 'n_tokens_mistral': 869, 'n_tokens_neox': 804, 'n_words': 285, 'path': '2-Regression/1-Tools/notebook.ipynb', 'repo_name': 'turhancan97/ML-For-Beginners', 'size': '2485'}