mirror of
https://github.com/Andreaierardi/Master-DataScience-Notes.git
synced 2025-01-05 17:15:56 +01:00
up
This commit is contained in:
parent
044e2bb489
commit
d634470290
@ -623,10 +623,30 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"E:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\linear_model\\logistic.py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning.\n",
|
||||
" FutureWarning)\n",
|
||||
"E:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\linear_model\\logistic.py:469: FutureWarning: Default multi_class will be changed to 'auto' in 0.22. Specify the multi_class option to silence this warning.\n",
|
||||
" \"this warning.\", FutureWarning)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"SCORE: 0.009547645532072673 \n",
|
||||
"--------------\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from sklearn import linear_model\n",
|
||||
"from sklearn.linear_model import LogisticRegression\n",
|
||||
"logistic = linear_model.LogisticRegression(random_state=0) # create object for the class\n",
|
||||
"logistic.fit(X_train, y_train) # perform logistic regression\n",
|
||||
@ -636,13 +656,30 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1662 3370\n",
|
||||
"1882 3321\n",
|
||||
"776 698\n",
|
||||
"530 646\n",
|
||||
"1882 4839\n",
|
||||
"1076 1851\n",
|
||||
"984 1624\n",
|
||||
"802 665\n",
|
||||
"872 596\n",
|
||||
"394 1154\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"Y_pred = logistic.predict(X_test, y_test) # make predictions\n",
|
||||
"for X,y in list(zip(X_test, y_test))[:10]:\n",
|
||||
" print(Y_pred[x], y)"
|
||||
" print(logistic.predict([X])[0], y)\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -650,11 +687,7 @@
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for X,y in list(zip(X_test, y_test))[:10]:\n",
|
||||
" print(logistic.predict([X])[0], y)\n",
|
||||
" "
|
||||
]
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
@ -677,5 +710,5 @@
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
|
@ -656,25 +656,30 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "TypeError",
|
||||
"evalue": "predict() takes 2 positional arguments but 3 were given",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[1;32m<ipython-input-8-7941666c0bd3>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mY_pred\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlogistic\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpredict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX_test\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my_test\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m# make predictions\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mX\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0my\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mlist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mzip\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX_test\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my_test\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mY_pred\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;31mTypeError\u001b[0m: predict() takes 2 positional arguments but 3 were given"
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1662 3370\n",
|
||||
"1882 3321\n",
|
||||
"776 698\n",
|
||||
"530 646\n",
|
||||
"1882 4839\n",
|
||||
"1076 1851\n",
|
||||
"984 1624\n",
|
||||
"802 665\n",
|
||||
"872 596\n",
|
||||
"394 1154\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"Y_pred = logistic.predict(X_test, y_test) # make predictions\n",
|
||||
"for X,y in list(zip(X_test, y_test))[:10]:\n",
|
||||
" print(Y_pred[x], y)"
|
||||
" print(logistic.predict([X])[0], y)\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -682,11 +687,7 @@
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for X,y in list(zip(X_test, y_test))[:10]:\n",
|
||||
" print(logistic.predict([X])[0], y)\n",
|
||||
" "
|
||||
]
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
Loading…
Reference in New Issue
Block a user