From 15de57dfe74aefd3ab1ee3292168798a71b930fa Mon Sep 17 00:00:00 2001 From: Md Afsar Uddin Chowdhury <125358856+nokibchowdhury1@users.noreply.github.com> Date: Sat, 24 May 2025 02:29:41 -0300 Subject: [PATCH] Created using Colab --- make_git_cli.ipynb | 1058 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1058 insertions(+) create mode 100644 make_git_cli.ipynb diff --git a/make_git_cli.ipynb b/make_git_cli.ipynb new file mode 100644 index 00000000..2aa289cf --- /dev/null +++ b/make_git_cli.ipynb @@ -0,0 +1,1058 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "That's an interesting new direction! Building a command-line interface (CLI) can be a very rewarding project. When you say \"make git cli,\" that's a broad goal, as Git itself is a very powerful and complex CLI.\n", + "\n", + "To help you best, could you clarify what you have in mind? For example:\n", + "\n", + "1. **Are you looking to create a new CLI tool that interacts with your existing Git repositories?** This could be a wrapper that simplifies common Git commands or adds custom functionality on top of Git.\n", + "2. **Are you interested in building a simplified version of some Git commands from scratch?** This could be for learning purposes, to understand how version control concepts might be implemented.\n", + "3. **What specific commands or features are you thinking of?** For example, are you interested in commands like `init`, `add`, `commit`, `status`, `log`, or something else?\n", + "4. **Do you have a preferred programming language for building this CLI?** Python, Node.js, Go, and Rust are popular choices for CLI tools, each with its own strengths.\n", + "\n", + "Building a CLI typically involves a few key coding aspects:\n", + "\n", + "* **Parsing Command-Line Arguments:** Your program needs to understand the commands and options the user types (e.g., `mygit commit -m \"Initial commit\"`). Libraries exist in most languages to help with this (like `argparse` in Python, `yargs` or `commander` in Node.js).\n", + "* **Implementing Command Logic:** For each command (like `init`, `add`, `commit`), you'll write functions or modules that perform the desired actions.\n", + " * If you're wrapping Git, this logic would involve constructing and running actual Git commands (e.g., using Python's `subprocess` module or Node.js's `child_process`).\n", + " * If you're simulating Git, this logic would involve manipulating some internal data structures that represent your repository's state.\n", + "* **Providing Output:** Your CLI needs to give feedback to the user, whether it's success messages, error messages, or the output of a command (like `git status`).\n", + "\n", + "Once I have a better idea of your specific goals, I can help you with:\n", + "* Choosing the right tools and libraries.\n", + "* Structuring your project.\n", + "* Writing the code for specific commands.\n", + "* Explaining the concepts involved.\n", + "\n", + "For example, if you wanted to start with a simple Python CLI that can accept a command, here's a very basic skeleton:" + ], + "metadata": { + "id": "Lqj8XQ0WuvDu" + } + }, + { + "cell_type": "code", + "source": [ + "# basic_cli.py\n", + "import argparse\n", + "\n", + "def handle_init(args):\n", + " print(\"Initializing a new (pretend) repository...\")\n", + " # In a real scenario, you might create a directory or some files.\n", + "\n", + "def handle_add(args):\n", + " print(f\"Adding files: {args.files}\")\n", + " # In a real scenario, you'd process the file list.\n", + "\n", + "def main():\n", + " parser = argparse.ArgumentParser(description=\"A simple Git-like CLI tool.\")\n", + " subparsers = parser.add_subparsers(dest=\"command\", help=\"Available commands\")\n", + " subparsers.required = True # Make sure a subcommand is given\n", + "\n", + " # 'init' command\n", + " parser_init = subparsers.add_parser(\"init\", help=\"Initialize a new repository.\")\n", + " parser_init.set_defaults(func=handle_init)\n", + "\n", + " # 'add' command\n", + " parser_add = subparsers.add_parser(\"add\", help=\"Add file contents to the index.\")\n", + " parser_add.add_argument(\"files\", nargs=\"+\", help=\"Files to add.\") # Allows one or more files\n", + " parser_add.set_defaults(func=handle_add)\n", + "\n", + " args = parser.parse_args()\n", + " args.func(args) # Call the function associated with the chosen subcommand\n", + "\n", + "if __name__ == \"__main__\":\n", + " main()" + ], + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "usage: colab_kernel_launcher.py [-h] {init,add} ...\n", + "colab_kernel_launcher.py: error: argument command: invalid choice: '/root/.local/share/jupyter/runtime/kernel-22e29993-c721-4945-8497-936ce3f4bbe7.json' (choose from 'init', 'add')\n", + "ERROR:root:Internal Python error in the inspect module.\n", + "Below is the traceback from this internal error.\n", + "\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Traceback (most recent call last):\n", + " File \"/usr/lib/python3.11/argparse.py\", line 1919, in parse_known_args\n", + " namespace, args = self._parse_known_args(args, namespace)\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/usr/lib/python3.11/argparse.py\", line 2143, in _parse_known_args\n", + " stop_index = consume_positionals(start_index)\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/usr/lib/python3.11/argparse.py\", line 2099, in consume_positionals\n", + " take_action(action, args)\n", + " File \"/usr/lib/python3.11/argparse.py\", line 1979, in take_action\n", + " argument_values = self._get_values(action, argument_strings)\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/usr/lib/python3.11/argparse.py\", line 2528, in _get_values\n", + " self._check_value(action, value[0])\n", + " File \"/usr/lib/python3.11/argparse.py\", line 2575, in _check_value\n", + " raise ArgumentError(action, msg % args)\n", + "argparse.ArgumentError: argument command: invalid choice: '/root/.local/share/jupyter/runtime/kernel-22e29993-c721-4945-8497-936ce3f4bbe7.json' (choose from 'init', 'add')\n", + "\n", + "During handling of the above exception, another exception occurred:\n", + "\n", + "Traceback (most recent call last):\n", + " File \"/usr/local/lib/python3.11/dist-packages/IPython/core/interactiveshell.py\", line 3553, in run_code\n", + " exec(code_obj, self.user_global_ns, self.user_ns)\n", + " File \"\", line 30, in \n", + " main()\n", + " File \"\", line 26, in main\n", + " args = parser.parse_args()\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"/usr/lib/python3.11/argparse.py\", line 1886, in parse_args\n", + " args, argv = self.parse_known_args(args, namespace)\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/usr/lib/python3.11/argparse.py\", line 1921, in parse_known_args\n", + " self.error(str(err))\n", + " File \"/usr/lib/python3.11/argparse.py\", line 2652, in error\n", + " self.exit(2, _('%(prog)s: error: %(message)s\\n') % args)\n", + " File \"/usr/lib/python3.11/argparse.py\", line 2639, in exit\n", + " _sys.exit(status)\n", + "SystemExit: 2\n", + "\n", + "During handling of the above exception, another exception occurred:\n", + "\n", + "Traceback (most recent call last):\n", + " File \"/usr/local/lib/python3.11/dist-packages/IPython/core/ultratb.py\", line 1101, in get_records\n", + " return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/usr/local/lib/python3.11/dist-packages/IPython/core/ultratb.py\", line 248, in wrapped\n", + " return f(*args, **kwargs)\n", + " ^^^^^^^^^^^^^^^^^^\n", + " File \"/usr/local/lib/python3.11/dist-packages/IPython/core/ultratb.py\", line 281, in _fixed_getinnerframes\n", + " records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/usr/lib/python3.11/inspect.py\", line 1739, in getinnerframes\n", + " traceback_info = getframeinfo(tb, context)\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/usr/lib/python3.11/inspect.py\", line 1671, in getframeinfo\n", + " lineno = frame.f_lineno\n", + " ^^^^^^^^^^^^^^\n", + "AttributeError: 'tuple' object has no attribute 'f_lineno'\n" + ] + }, + { + "output_type": "error", + "ename": "TypeError", + "evalue": "object of type 'NoneType' has no len()", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mArgumentError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/usr/lib/python3.11/argparse.py\u001b[0m in \u001b[0;36mparse_known_args\u001b[0;34m(self, args, namespace)\u001b[0m\n\u001b[1;32m 1918\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1919\u001b[0;31m \u001b[0mnamespace\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parse_known_args\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnamespace\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1920\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mArgumentError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/lib/python3.11/argparse.py\u001b[0m in \u001b[0;36m_parse_known_args\u001b[0;34m(self, arg_strings, namespace)\u001b[0m\n\u001b[1;32m 2142\u001b[0m \u001b[0;31m# consume any positionals following the last Optional\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2143\u001b[0;31m \u001b[0mstop_index\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mconsume_positionals\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstart_index\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2144\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/lib/python3.11/argparse.py\u001b[0m in \u001b[0;36mconsume_positionals\u001b[0;34m(start_index)\u001b[0m\n\u001b[1;32m 2098\u001b[0m \u001b[0mstart_index\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0marg_count\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2099\u001b[0;31m \u001b[0mtake_action\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0maction\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2100\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/lib/python3.11/argparse.py\u001b[0m in \u001b[0;36mtake_action\u001b[0;34m(action, argument_strings, option_string)\u001b[0m\n\u001b[1;32m 1978\u001b[0m \u001b[0mseen_actions\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0maction\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1979\u001b[0;31m \u001b[0margument_values\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_values\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0maction\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margument_strings\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1980\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/lib/python3.11/argparse.py\u001b[0m in \u001b[0;36m_get_values\u001b[0;34m(self, action, arg_strings)\u001b[0m\n\u001b[1;32m 2527\u001b[0m \u001b[0mvalue\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_value\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0maction\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0marg_strings\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2528\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_check_value\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0maction\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2529\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/lib/python3.11/argparse.py\u001b[0m in \u001b[0;36m_check_value\u001b[0;34m(self, action, value)\u001b[0m\n\u001b[1;32m 2574\u001b[0m \u001b[0mmsg\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'invalid choice: %(value)r (choose from %(choices)s)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2575\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mArgumentError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0maction\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmsg\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2576\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mArgumentError\u001b[0m: argument command: invalid choice: '/root/.local/share/jupyter/runtime/kernel-22e29993-c721-4945-8497-936ce3f4bbe7.json' (choose from 'init', 'add')", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[0;31mSystemExit\u001b[0m Traceback (most recent call last)", + " \u001b[0;31m[... skipping hidden 1 frame]\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0m__name__\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"__main__\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 30\u001b[0;31m \u001b[0mmain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m\u001b[0m in \u001b[0;36mmain\u001b[0;34m()\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m \u001b[0margs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparser\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mparse_args\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 27\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Call the function associated with the chosen subcommand\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/lib/python3.11/argparse.py\u001b[0m in \u001b[0;36mparse_args\u001b[0;34m(self, args, namespace)\u001b[0m\n\u001b[1;32m 1885\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mparse_args\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnamespace\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1886\u001b[0;31m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margv\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mparse_known_args\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnamespace\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1887\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0margv\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/lib/python3.11/argparse.py\u001b[0m in \u001b[0;36mparse_known_args\u001b[0;34m(self, args, namespace)\u001b[0m\n\u001b[1;32m 1920\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mArgumentError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1921\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0merror\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0merr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1922\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/lib/python3.11/argparse.py\u001b[0m in \u001b[0;36merror\u001b[0;34m(self, message)\u001b[0m\n\u001b[1;32m 2651\u001b[0m \u001b[0margs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m'prog'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprog\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'message'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mmessage\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2652\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0m_\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'%(prog)s: error: %(message)s\\n'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m/usr/lib/python3.11/argparse.py\u001b[0m in \u001b[0;36mexit\u001b[0;34m(self, status, message)\u001b[0m\n\u001b[1;32m 2638\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_print_message\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmessage\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0m_sys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstderr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2639\u001b[0;31m \u001b[0m_sys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstatus\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2640\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mSystemExit\u001b[0m: 2", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + " \u001b[0;31m[... skipping hidden 1 frame]\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.11/dist-packages/IPython/core/interactiveshell.py\u001b[0m in \u001b[0;36mshowtraceback\u001b[0;34m(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)\u001b[0m\n\u001b[1;32m 2090\u001b[0m stb = ['An exception has occurred, use %tb to see '\n\u001b[1;32m 2091\u001b[0m 'the full traceback.\\n']\n\u001b[0;32m-> 2092\u001b[0;31m stb.extend(self.InteractiveTB.get_exception_only(etype,\n\u001b[0m\u001b[1;32m 2093\u001b[0m value))\n\u001b[1;32m 2094\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.11/dist-packages/IPython/core/ultratb.py\u001b[0m in \u001b[0;36mget_exception_only\u001b[0;34m(self, etype, value)\u001b[0m\n\u001b[1;32m 752\u001b[0m \u001b[0mvalue\u001b[0m \u001b[0;34m:\u001b[0m \u001b[0mexception\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 753\u001b[0m \"\"\"\n\u001b[0;32m--> 754\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mListTB\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstructured_traceback\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0metype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 755\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 756\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mshow_exception_only\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0metype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mevalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.11/dist-packages/IPython/core/ultratb.py\u001b[0m in \u001b[0;36mstructured_traceback\u001b[0;34m(self, etype, evalue, etb, tb_offset, context)\u001b[0m\n\u001b[1;32m 627\u001b[0m \u001b[0mchained_exceptions_tb_offset\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 628\u001b[0m out_list = (\n\u001b[0;32m--> 629\u001b[0;31m self.structured_traceback(\n\u001b[0m\u001b[1;32m 630\u001b[0m \u001b[0metype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mevalue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0metb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mchained_exc_ids\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 631\u001b[0m chained_exceptions_tb_offset, context)\n", + "\u001b[0;32m/usr/local/lib/python3.11/dist-packages/IPython/core/ultratb.py\u001b[0m in \u001b[0;36mstructured_traceback\u001b[0;34m(self, etype, value, tb, tb_offset, number_of_lines_of_context)\u001b[0m\n\u001b[1;32m 1365\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1366\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtb\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1367\u001b[0;31m return FormattedTB.structured_traceback(\n\u001b[0m\u001b[1;32m 1368\u001b[0m self, etype, value, tb, tb_offset, number_of_lines_of_context)\n\u001b[1;32m 1369\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.11/dist-packages/IPython/core/ultratb.py\u001b[0m in \u001b[0;36mstructured_traceback\u001b[0;34m(self, etype, value, tb, tb_offset, number_of_lines_of_context)\u001b[0m\n\u001b[1;32m 1265\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmode\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mverbose_modes\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1266\u001b[0m \u001b[0;31m# Verbose modes need a full traceback\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1267\u001b[0;31m return VerboseTB.structured_traceback(\n\u001b[0m\u001b[1;32m 1268\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0metype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtb_offset\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnumber_of_lines_of_context\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1269\u001b[0m )\n", + "\u001b[0;32m/usr/local/lib/python3.11/dist-packages/IPython/core/ultratb.py\u001b[0m in \u001b[0;36mstructured_traceback\u001b[0;34m(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)\u001b[0m\n\u001b[1;32m 1122\u001b[0m \u001b[0;34m\"\"\"Return a nice text document describing the traceback.\"\"\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1123\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1124\u001b[0;31m formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,\n\u001b[0m\u001b[1;32m 1125\u001b[0m tb_offset)\n\u001b[1;32m 1126\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.11/dist-packages/IPython/core/ultratb.py\u001b[0m in \u001b[0;36mformat_exception_as_a_whole\u001b[0;34m(self, etype, evalue, etb, number_of_lines_of_context, tb_offset)\u001b[0m\n\u001b[1;32m 1080\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1081\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1082\u001b[0;31m \u001b[0mlast_unique\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrecursion_repeat\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfind_recursion\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0morig_etype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mevalue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrecords\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1083\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1084\u001b[0m \u001b[0mframes\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat_records\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrecords\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlast_unique\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrecursion_repeat\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.11/dist-packages/IPython/core/ultratb.py\u001b[0m in \u001b[0;36mfind_recursion\u001b[0;34m(etype, value, records)\u001b[0m\n\u001b[1;32m 380\u001b[0m \u001b[0;31m# first frame (from in to out) that looks different.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 381\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mis_recursion_error\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0metype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrecords\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 382\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrecords\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 383\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 384\u001b[0m \u001b[0;31m# Select filename, lineno, func_name to track frames with\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: object of type 'NoneType' has no len()" + ] + } + ], + "execution_count": 1, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000 + }, + "id": "HspkbA0KuvDw", + "outputId": "8c86ab0e-4628-4383-9805-22f45a7bc2b9" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "sO-XKW27wRUx" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "FduF8dWrwRhD" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "KNAPFNyAwRwy" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "lRRch8L0wSUh" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "zxSK7tAewU59" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "5DkgkZ5PwWnh" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "_-5nUwwDwW8D" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "1T1k7d7gwXAD" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "veDkIYSlwXCv" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "sxOv_51lwXFv" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "aRv09dO6wXLC" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "dXIt6qZMwXOD" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "3AUmVY0vwXRr" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "IanInTsnwXUa" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "zqoqb9vPwXXR" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "-42cEPOawXZ7" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "HS2-UDiMwXcr" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "Nh3NCVfhwXfY" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "2UQ94MhmwXiZ" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cuml.accel` before importing sklearn to speed up operations using GPU\n" + ], + "metadata": { + "id": "pwFfgScGwYEu" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cudf.pandas` before importing pandas to speed up operations using GPU" + ], + "metadata": { + "id": "RvBr9G24wt54" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cudf.pandas` before importing pandas to speed up operations using GPU" + ], + "metadata": { + "id": "qnmIZnqIwuS0" + } + }, + { + "cell_type": "markdown", + "source": [ + "Add `%load_ext cudf.pandas` before importing pandas to speed up operations using GPU" + ], + "metadata": { + "id": "_PDzisK7wwN6" + } + }, + { + "cell_type": "markdown", + "source": [ + "# New Section" + ], + "metadata": { + "id": "OWDA2evjxAOn" + } + }, + { + "cell_type": "code", + "source": [ + "%load_ext cudf.pandas\n", + "import pandas as pd\n", + "import numpy as np\n", + "\n", + "# Randomly generated dataset of parking violations-\n", + "# Define the number of rows\n", + "num_rows = 1000000\n", + "\n", + "states = [\"NY\", \"NJ\", \"CA\", \"TX\"]\n", + "violations = [\"Double Parking\", \"Expired Meter\", \"No Parking\",\n", + " \"Fire Hydrant\", \"Bus Stop\"]\n", + "vehicle_types = [\"SUBN\", \"SDN\"]\n", + "\n", + "# Create a date range\n", + "start_date = \"2022-01-01\"\n", + "end_date = \"2022-12-31\"\n", + "dates = pd.date_range(start=start_date, end=end_date, freq='D')\n", + "\n", + "# Generate random data\n", + "data = {\n", + " \"Registration State\": np.random.choice(states, size=num_rows),\n", + " \"Violation Description\": np.random.choice(violations, size=num_rows),\n", + " \"Vehicle Body Type\": np.random.choice(vehicle_types, size=num_rows),\n", + " \"Issue Date\": np.random.choice(dates, size=num_rows),\n", + " \"Ticket Number\": np.random.randint(1000000000, 9999999999, size=num_rows)\n", + "}\n", + "\n", + "# Create a DataFrame\n", + "df = pd.DataFrame(data)\n", + "\n", + "# Which parking violation is most commonly committed by vehicles from various U.S states?\n", + "\n", + "(df[[\"Registration State\", \"Violation Description\"]] # get only these two columns\n", + " .value_counts() # get the count of offences per state and per type of offence\n", + " .groupby(\"Registration State\") # group by state\n", + " .head(1) # get the first row in each group (the type of offence with the largest count)\n", + " .sort_index() # sort by state name\n", + " .reset_index()\n", + ")" + ], + "metadata": { + "id": "0syeEJSEwwN6" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cudf.pandas\n", + "import pandas as pd\n", + "import numpy as np\n", + "\n", + "# Randomly generated dataset of parking violations-\n", + "# Define the number of rows\n", + "num_rows = 1000000\n", + "\n", + "states = [\"NY\", \"NJ\", \"CA\", \"TX\"]\n", + "violations = [\"Double Parking\", \"Expired Meter\", \"No Parking\",\n", + " \"Fire Hydrant\", \"Bus Stop\"]\n", + "vehicle_types = [\"SUBN\", \"SDN\"]\n", + "\n", + "# Create a date range\n", + "start_date = \"2022-01-01\"\n", + "end_date = \"2022-12-31\"\n", + "dates = pd.date_range(start=start_date, end=end_date, freq='D')\n", + "\n", + "# Generate random data\n", + "data = {\n", + " \"Registration State\": np.random.choice(states, size=num_rows),\n", + " \"Violation Description\": np.random.choice(violations, size=num_rows),\n", + " \"Vehicle Body Type\": np.random.choice(vehicle_types, size=num_rows),\n", + " \"Issue Date\": np.random.choice(dates, size=num_rows),\n", + " \"Ticket Number\": np.random.randint(1000000000, 9999999999, size=num_rows)\n", + "}\n", + "\n", + "# Create a DataFrame\n", + "df = pd.DataFrame(data)\n", + "\n", + "# Which parking violation is most commonly committed by vehicles from various U.S states?\n", + "\n", + "(df[[\"Registration State\", \"Violation Description\"]] # get only these two columns\n", + " .value_counts() # get the count of offences per state and per type of offence\n", + " .groupby(\"Registration State\") # group by state\n", + " .head(1) # get the first row in each group (the type of offence with the largest count)\n", + " .sort_index() # sort by state name\n", + " .reset_index()\n", + ")" + ], + "metadata": { + "id": "UFnhQ8dXwuS0" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cudf.pandas\n", + "import pandas as pd\n", + "import numpy as np\n", + "\n", + "# Randomly generated dataset of parking violations-\n", + "# Define the number of rows\n", + "num_rows = 1000000\n", + "\n", + "states = [\"NY\", \"NJ\", \"CA\", \"TX\"]\n", + "violations = [\"Double Parking\", \"Expired Meter\", \"No Parking\",\n", + " \"Fire Hydrant\", \"Bus Stop\"]\n", + "vehicle_types = [\"SUBN\", \"SDN\"]\n", + "\n", + "# Create a date range\n", + "start_date = \"2022-01-01\"\n", + "end_date = \"2022-12-31\"\n", + "dates = pd.date_range(start=start_date, end=end_date, freq='D')\n", + "\n", + "# Generate random data\n", + "data = {\n", + " \"Registration State\": np.random.choice(states, size=num_rows),\n", + " \"Violation Description\": np.random.choice(violations, size=num_rows),\n", + " \"Vehicle Body Type\": np.random.choice(vehicle_types, size=num_rows),\n", + " \"Issue Date\": np.random.choice(dates, size=num_rows),\n", + " \"Ticket Number\": np.random.randint(1000000000, 9999999999, size=num_rows)\n", + "}\n", + "\n", + "# Create a DataFrame\n", + "df = pd.DataFrame(data)\n", + "\n", + "# Which parking violation is most commonly committed by vehicles from various U.S states?\n", + "\n", + "(df[[\"Registration State\", \"Violation Description\"]] # get only these two columns\n", + " .value_counts() # get the count of offences per state and per type of offence\n", + " .groupby(\"Registration State\") # group by state\n", + " .head(1) # get the first row in each group (the type of offence with the largest count)\n", + " .sort_index() # sort by state name\n", + " .reset_index()\n", + ")" + ], + "metadata": { + "id": "2iAE2ETpwt55" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "WxAJbO45wYEu" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "W2dKDXlxwXia" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "L6TjX94nwXfY" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "0DyYumGwwXcs" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "zKGTsXtJwXZ7" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "Gd0X_irQwXXR" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "ogit7YymwXUa" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "qrpBThKnwXRr" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "jPOsg51AwXOD" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "MjdraKYywXLD" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "zCg_6xENwXFw" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "oBS_ra95wXCw" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "BOHGiUjCwXAD" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "lelQdth-wW8D" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.metrics import classification_report\n", + "from sklearn.neighbors import KNeighborsClassifier\n", + "\n", + "X, y = make_classification(n_samples=100000, n_features=100, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "knn = KNeighborsClassifier(n_neighbors=5)\n", + "knn.fit(X_train, y_train)\n", + "\n", + "y_pred = knn.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "OupTQmmrwWnh" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "X, y = make_classification(n_samples=1000000, n_features=200, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "clf = LogisticRegression()\n", + "clf.fit(X_train, y_train)\n", + "y_pred = clf.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "qTaacG4nwU5-" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.metrics import classification_report\n", + "from sklearn.neighbors import KNeighborsClassifier\n", + "\n", + "X, y = make_classification(n_samples=100000, n_features=100, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "knn = KNeighborsClassifier(n_neighbors=5)\n", + "knn.fit(X_train, y_train)\n", + "\n", + "y_pred = knn.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "VyCIB8N3wSUi" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.metrics import classification_report\n", + "from sklearn.neighbors import KNeighborsClassifier\n", + "\n", + "X, y = make_classification(n_samples=100000, n_features=100, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "knn = KNeighborsClassifier(n_neighbors=5)\n", + "knn.fit(X_train, y_train)\n", + "\n", + "y_pred = knn.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "M4h38y2cwRwy" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.metrics import classification_report\n", + "from sklearn.neighbors import KNeighborsClassifier\n", + "\n", + "X, y = make_classification(n_samples=100000, n_features=100, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "knn = KNeighborsClassifier(n_neighbors=5)\n", + "knn.fit(X_train, y_train)\n", + "\n", + "y_pred = knn.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "5W9w7mDPwRhE" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%load_ext cuml.accel\n", + "from sklearn.datasets import make_classification\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.metrics import classification_report\n", + "from sklearn.neighbors import KNeighborsClassifier\n", + "\n", + "X, y = make_classification(n_samples=100000, n_features=100, random_state=0)\n", + "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", + "\n", + "knn = KNeighborsClassifier(n_neighbors=5)\n", + "knn.fit(X_train, y_train)\n", + "\n", + "y_pred = knn.predict(X_test)\n", + "print(classification_report(y_test, y_pred))" + ], + "metadata": { + "id": "h83uq2PTwRUy" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [], + "metadata": { + "id": "q3CQyAlfuwkj" + } + }, + { + "cell_type": "code", + "source": [ + "\n", + "\n", + "\n" + ], + "metadata": { + "id": "TY9O1kV6uxE6" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [], + "metadata": { + "id": "DBEa0bA4wGz6" + } + } + ], + "metadata": { + "colab": { + "provenance": [], + "toc_visible": true, + "include_colab_link": true + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file