OwenPriceSkelly commited on
Commit
c0575f2
1 Parent(s): 8089d6c

add training notebook and model weights

Browse files
Files changed (2) hide show
  1. Train_Model.ipynb +112 -0
  2. model.joblib +3 -0
Train_Model.ipynb ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stdout",
10
+ "output_type": "stream",
11
+ "text": [
12
+ "Requirement already satisfied: scikit-learn in /Users/owen/.pyenv/versions/3.10.11/lib/python3.10/site-packages (1.3.0)\n",
13
+ "Requirement already satisfied: threadpoolctl>=2.0.0 in /Users/owen/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from scikit-learn) (3.1.0)\n",
14
+ "Requirement already satisfied: joblib>=1.1.1 in /Users/owen/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from scikit-learn) (1.3.1)\n",
15
+ "Requirement already satisfied: scipy>=1.5.0 in /Users/owen/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from scikit-learn) (1.11.1)\n",
16
+ "Requirement already satisfied: numpy>=1.17.3 in /Users/owen/.pyenv/versions/3.10.11/lib/python3.10/site-packages (from scikit-learn) (1.23.5)\n",
17
+ "\n",
18
+ "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.0.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.3.1\u001b[0m\n",
19
+ "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49m/Users/owen/.pyenv/versions/3.10.11/bin/python3.10 -m pip install --upgrade pip\u001b[0m\n",
20
+ "Note: you may need to restart the kernel to use updated packages.\n",
21
+ "sklearn.__version__='1.3.0'\n"
22
+ ]
23
+ }
24
+ ],
25
+ "source": [
26
+ "%pip install scikit-learn\n",
27
+ "import sklearn\n",
28
+ "print(f\"{sklearn.__version__=}\")"
29
+ ]
30
+ },
31
+ {
32
+ "cell_type": "code",
33
+ "execution_count": 2,
34
+ "metadata": {
35
+ "id": "ljmtcrVxoxfO"
36
+ },
37
+ "outputs": [],
38
+ "source": [
39
+ "from sklearn.datasets import load_iris\n",
40
+ "from sklearn.model_selection import train_test_split\n",
41
+ "from sklearn.ensemble import RandomForestClassifier\n",
42
+ "from sklearn.metrics import accuracy_score\n",
43
+ "\n",
44
+ "# Load the Iris dataset\n",
45
+ "iris = load_iris()\n",
46
+ "X, y = iris.data, iris.target\n",
47
+ "\n",
48
+ "# Split the data into training and test sets\n",
49
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)\n",
50
+ "\n",
51
+ "# Initialize the classifier\n",
52
+ "classifier = RandomForestClassifier(n_estimators=100, random_state=42)\n",
53
+ "\n",
54
+ "# Train the classifier\n",
55
+ "classifier.fit(X_train, y_train)\n",
56
+ "\n",
57
+ "# Make predictions on the test set\n",
58
+ "predictions = classifier.predict(X_test)\n",
59
+ "\n",
60
+ "# Calculate the accuracy\n",
61
+ "accuracy = accuracy_score(y_test, predictions)"
62
+ ]
63
+ },
64
+ {
65
+ "cell_type": "code",
66
+ "execution_count": 3,
67
+ "metadata": {
68
+ "id": "NL58M19xo4PP"
69
+ },
70
+ "outputs": [
71
+ {
72
+ "data": {
73
+ "text/plain": [
74
+ "['model.joblib']"
75
+ ]
76
+ },
77
+ "execution_count": 3,
78
+ "metadata": {},
79
+ "output_type": "execute_result"
80
+ }
81
+ ],
82
+ "source": [
83
+ "from joblib import dump\n",
84
+ "dump(classifier, 'model.joblib')"
85
+ ]
86
+ }
87
+ ],
88
+ "metadata": {
89
+ "colab": {
90
+ "provenance": []
91
+ },
92
+ "kernelspec": {
93
+ "display_name": "Python 3 (ipykernel)",
94
+ "language": "python",
95
+ "name": "python3"
96
+ },
97
+ "language_info": {
98
+ "codemirror_mode": {
99
+ "name": "ipython",
100
+ "version": 3
101
+ },
102
+ "file_extension": ".py",
103
+ "mimetype": "text/x-python",
104
+ "name": "python",
105
+ "nbconvert_exporter": "python",
106
+ "pygments_lexer": "ipython3",
107
+ "version": "3.10.11"
108
+ }
109
+ },
110
+ "nbformat": 4,
111
+ "nbformat_minor": 4
112
+ }
model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d9eb39162deca05f3f3e5ef86ae542580c043cd58c86e5cbc5b1b13214838409
3
+ size 183713