\n",
+ "
pandas.plotting._core.hist_series
def hist_series(by=None, ax=None, grid: bool=True, xlabelsize: int | None=None, xrot: float | None=None, ylabelsize: int | None=None, yrot: float | None=None, figsize: tuple[int, int] | None=None, bins: int | Sequence[int]=10, backend: str | None=None, legend: bool=False, **kwargs)
/usr/local/lib/python3.12/dist-packages/pandas/plotting/_core.pyDraw histogram of the input series using matplotlib.\n",
+ "\n",
+ "Parameters\n",
+ "----------\n",
+ "by : object, optional\n",
+ " If passed, then used to form histograms for separate groups.\n",
+ "ax : matplotlib axis object\n",
+ " If not passed, uses gca().\n",
+ "grid : bool, default True\n",
+ " Whether to show axis grid lines.\n",
+ "xlabelsize : int, default None\n",
+ " If specified changes the x-axis label size.\n",
+ "xrot : float, default None\n",
+ " Rotation of x axis labels.\n",
+ "ylabelsize : int, default None\n",
+ " If specified changes the y-axis label size.\n",
+ "yrot : float, default None\n",
+ " Rotation of y axis labels.\n",
+ "figsize : tuple, default None\n",
+ " Figure size in inches by default.\n",
+ "bins : int or sequence, default 10\n",
+ " Number of histogram bins to be used. If an integer is given, bins + 1\n",
+ " bin edges are calculated and returned. If bins is a sequence, gives\n",
+ " bin edges, including left edge of first bin and right edge of last\n",
+ " bin. In this case, bins is returned unmodified.\n",
+ "backend : str, default None\n",
+ " Backend to use instead of the backend specified in the option\n",
+ " ``plotting.backend``. For instance, 'matplotlib'. Alternatively, to\n",
+ " specify the ``plotting.backend`` for the whole session, set\n",
+ " ``pd.options.plotting.backend``.\n",
+ "legend : bool, default False\n",
+ " Whether to show the legend.\n",
+ "\n",
+ "**kwargs\n",
+ " To be passed to the actual plotting function.\n",
+ "\n",
+ "Returns\n",
+ "-------\n",
+ "matplotlib.AxesSubplot\n",
+ " A histogram plot.\n",
+ "\n",
+ "See Also\n",
+ "--------\n",
+ "matplotlib.axes.Axes.hist : Plot a histogram using matplotlib.\n",
+ "\n",
+ "Examples\n",
+ "--------\n",
+ "For Series:\n",
+ "\n",
+ ".. plot::\n",
+ " :context: close-figs\n",
+ "\n",
+ " >>> lst = ['a', 'a', 'a', 'b', 'b', 'b']\n",
+ " >>> ser = pd.Series([1, 2, 2, 4, 6, 6], index=lst)\n",
+ " >>> hist = ser.hist()\n",
+ "\n",
+ "For Groupby:\n",
+ "\n",
+ ".. plot::\n",
+ " :context: close-figs\n",
+ "\n",
+ " >>> lst = ['a', 'a', 'a', 'b', 'b', 'b']\n",
+ " >>> ser = pd.Series([1, 2, 2, 4, 6, 6], index=lst)\n",
+ " >>> hist = ser.groupby(level=0).hist()
\n",
+ " \n",
+ "
"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 22
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "2e41caaf"
+ },
+ "source": [
+ "# Convert labels to numerical format\n",
+ "df['labels'] = df['labels'].map({'ham': 0, 'spam': 1})"
+ ],
+ "execution_count": 23,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "c841b673"
+ },
+ "source": [
+ "# Split the data into training and testing sets\n",
+ "X_train, X_test, y_train, y_test = train_test_split(df['data'], df['labels'], test_size=0.33, random_state=42)"
+ ],
+ "execution_count": 9,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "412cf5a6"
+ },
+ "source": [
+ "# Vectorize the text data using TF-IDF\n",
+ "vectorizer = TfidfVectorizer(decode_error='ignore')\n",
+ "X_train_vectorized = vectorizer.fit_transform(X_train)\n",
+ "X_test_vectorized = vectorizer.transform(X_test)"
+ ],
+ "execution_count": 10,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "X_train"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 458
+ },
+ "id": "RPOkw_7TPuiD",
+ "outputId": "a879716e-2b7d-4bcd-d001-ceac04e028af"
+ },
+ "execution_count": 25,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "3235 Aight text me when you're back at mu and I'll ...\n",
+ "945 I cant wait to see you! How were the photos we...\n",
+ "5319 Kothi print out marandratha.\n",
+ "5528 Its just the effect of irritation. Just ignore it\n",
+ "247 Kallis wont bat in 2nd innings.\n",
+ " ... \n",
+ "3772 I came hostel. I m going to sleep. Plz call me...\n",
+ "5191 Sorry, I'll call later\n",
+ "5226 Prabha..i'm soryda..realy..frm heart i'm sory\n",
+ "5390 Nt joking seriously i told\n",
+ "860 In work now. Going have in few min.\n",
+ "Name: data, Length: 3733, dtype: object"
+ ],
+ "text/html": [
+ "