hholb commited on
Commit
6eced57
1 Parent(s): 9e4dfc2

Train new model using sklearn version 1.4.1.pos1 on Iris dataset

Browse files
Files changed (3) hide show
  1. .gitignore +2 -0
  2. Train_Model.ipynb +114 -0
  3. model.joblib +3 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .ipynb_checkpoints
2
+ __pycache__
Train_Model.ipynb ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 4,
6
+ "id": "68086de2-9e6a-4821-b0c8-d1c4125a236d",
7
+ "metadata": {},
8
+ "outputs": [
9
+ {
10
+ "name": "stdout",
11
+ "output_type": "stream",
12
+ "text": [
13
+ "Defaulting to user installation because normal site-packages is not writeable\n",
14
+ "Requirement already satisfied: scikit-learn==1.4.1.post1 in /home/hayden/.local/lib/python3.10/site-packages (1.4.1.post1)\n",
15
+ "Requirement already satisfied: numpy<2.0,>=1.19.5 in /home/hayden/.local/lib/python3.10/site-packages (from scikit-learn==1.4.1.post1) (1.26.4)\n",
16
+ "Requirement already satisfied: joblib>=1.2.0 in /home/hayden/.local/lib/python3.10/site-packages (from scikit-learn==1.4.1.post1) (1.4.0)\n",
17
+ "Requirement already satisfied: threadpoolctl>=2.0.0 in /home/hayden/.local/lib/python3.10/site-packages (from scikit-learn==1.4.1.post1) (3.4.0)\n",
18
+ "Requirement already satisfied: scipy>=1.6.0 in /home/hayden/.local/lib/python3.10/site-packages (from scikit-learn==1.4.1.post1) (1.13.0)\n",
19
+ "Note: you may need to restart the kernel to use updated packages.\n",
20
+ "sklearn.__version__='1.4.1.post1'\n"
21
+ ]
22
+ }
23
+ ],
24
+ "source": [
25
+ "%pip install scikit-learn==1.4.1.post1\n",
26
+ "import sklearn\n",
27
+ "print(f\"{sklearn.__version__=}\")"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "code",
32
+ "execution_count": 5,
33
+ "id": "4dead9f4-4098-415c-b67b-bf78a463786e",
34
+ "metadata": {},
35
+ "outputs": [],
36
+ "source": [
37
+ "from sklearn.datasets import load_iris\n",
38
+ "from sklearn.model_selection import train_test_split\n",
39
+ "from sklearn.ensemble import RandomForestClassifier\n",
40
+ "from sklearn.metrics import accuracy_score\n",
41
+ "\n",
42
+ "# Load the Iris dataset\n",
43
+ "iris = load_iris()\n",
44
+ "X, y = iris.data, iris.target\n",
45
+ "\n",
46
+ "# Split the data into training and test sets\n",
47
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)\n",
48
+ "\n",
49
+ "# Initialize the classifier\n",
50
+ "classifier = RandomForestClassifier(n_estimators=100, random_state=42)\n",
51
+ "\n",
52
+ "# Train the classifier\n",
53
+ "classifier.fit(X_train, y_train)\n",
54
+ "\n",
55
+ "# Make predictions on the test set\n",
56
+ "predictions = classifier.predict(X_test)\n",
57
+ "\n",
58
+ "# Calculate the accuracy\n",
59
+ "accuracy = accuracy_score(y_test, predictions)"
60
+ ]
61
+ },
62
+ {
63
+ "cell_type": "code",
64
+ "execution_count": 6,
65
+ "id": "4518f8c6-fc2f-449e-b796-cb7f383692e3",
66
+ "metadata": {},
67
+ "outputs": [
68
+ {
69
+ "data": {
70
+ "text/plain": [
71
+ "['model.joblib']"
72
+ ]
73
+ },
74
+ "execution_count": 6,
75
+ "metadata": {},
76
+ "output_type": "execute_result"
77
+ }
78
+ ],
79
+ "source": [
80
+ "from joblib import dump\n",
81
+ "dump(classifier, 'model.joblib')"
82
+ ]
83
+ },
84
+ {
85
+ "cell_type": "code",
86
+ "execution_count": null,
87
+ "id": "7ab76470-7686-4ade-a1d7-75f21a307263",
88
+ "metadata": {},
89
+ "outputs": [],
90
+ "source": []
91
+ }
92
+ ],
93
+ "metadata": {
94
+ "kernelspec": {
95
+ "display_name": "Python 3 (ipykernel)",
96
+ "language": "python",
97
+ "name": "python3"
98
+ },
99
+ "language_info": {
100
+ "codemirror_mode": {
101
+ "name": "ipython",
102
+ "version": 3
103
+ },
104
+ "file_extension": ".py",
105
+ "mimetype": "text/x-python",
106
+ "name": "python",
107
+ "nbconvert_exporter": "python",
108
+ "pygments_lexer": "ipython3",
109
+ "version": "3.10.12"
110
+ }
111
+ },
112
+ "nbformat": 4,
113
+ "nbformat_minor": 5
114
+ }
model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:216e0dfbc4e28b9a25bde02124d7be6016aea94ec3aade53dbc4463d394de14a
3
+ size 183761