Skip to content

Instantly share code, notes, and snippets.

@infinite-Joy
Last active November 29, 2017 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infinite-Joy/307841d66a8fac974e14c7d2a6acb415 to your computer and use it in GitHub Desktop.
Save infinite-Joy/307841d66a8fac974e14c7d2a6acb415 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# split the data into training test sets\n",
"diabetes_X_train = diabetes_X[:-20]\n",
"diabetes_X_test = diabetes_X[-20:]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#split the targets into training test sets\n",
"diabetes_y_train = diabetes.target[:-20]\n",
"diabetes_y_test = diabetes.target[-20:]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# create linear regression object\n",
"regr = linear_model.LinearRegression()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# train the model using the training sets\n",
"regr.fit(diabetes_X_train, diabetes_y_train)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# make predictions using the testing set\n",
"diabetes_y_pred = regr.predict(diabetes_X_test)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment