Files
labs/Module-4/3.Linear_Regression_Spam_detection.ipynb
T

88 lines
1.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "kFEl9T0h7KS1"
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "3viYCvJl7U3I"
},
"outputs": [],
"source": [
"df = pd.read_csv('datasets-2/sms_spam_perceptron.csv')\n",
"x = df.iloc[:,[1,2]].values\n",
"y=df.iloc[:, 0].values\n",
"y= np.where(y=='spam',-1,1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "RKMJB7gJ7rpj",
"outputId": "3d701a48-151c-40d3-82cd-d8e216c40808"
},
"outputs": [],
"source": [
"from sklearn.linear_model import LinearRegression\n",
"linear_regression = LinearRegression()\n",
"linear_regression.fit(x,y)\n",
"print(linear_regression.score(x,y))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"colab": {
"name": "Linear Regression for spam detection.ipynb",
"provenance": []
},
"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.8.8"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}