Delete Untitled1.ipynb
Browse files- Untitled1.ipynb +0 -97
Untitled1.ipynb
DELETED
@@ -1,97 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": 4,
|
6 |
-
"id": "2e314513",
|
7 |
-
"metadata": {},
|
8 |
-
"outputs": [
|
9 |
-
{
|
10 |
-
"name": "stdout",
|
11 |
-
"output_type": "stream",
|
12 |
-
"text": [
|
13 |
-
"Accuracy: 0.8417508417508418\n"
|
14 |
-
]
|
15 |
-
}
|
16 |
-
],
|
17 |
-
"source": [
|
18 |
-
"\n",
|
19 |
-
"import pandas as pd\n",
|
20 |
-
"from sklearn.model_selection import train_test_split\n",
|
21 |
-
"from sklearn.ensemble import RandomForestClassifier\n",
|
22 |
-
"from sklearn.metrics import accuracy_score, classification_report\n",
|
23 |
-
"\n",
|
24 |
-
"# Load the dataset\n",
|
25 |
-
"df = pd.read_csv('dataset.csv')\n",
|
26 |
-
"\n",
|
27 |
-
"# Split the dataset into features and target variable\n",
|
28 |
-
"X = df.drop('PlacedOrNot', axis=1) # Features\n",
|
29 |
-
"y = df['PlacedOrNot'] # Target variable\n",
|
30 |
-
"\n",
|
31 |
-
"# Convert categorical features to numerical using one-hot encoding\n",
|
32 |
-
"X = pd.get_dummies(X)\n",
|
33 |
-
"\n",
|
34 |
-
"# Split the dataset into training and testing sets\n",
|
35 |
-
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
|
36 |
-
"\n",
|
37 |
-
"# Create a Random Forest Classifier\n",
|
38 |
-
"clf = RandomForestClassifier(n_estimators=100, random_state=42)\n",
|
39 |
-
"\n",
|
40 |
-
"# Train the model\n",
|
41 |
-
"clf.fit(X_train, y_train)\n",
|
42 |
-
"\n",
|
43 |
-
"accuracy = clf.score(X_test, y_test)\n",
|
44 |
-
"print('Accuracy:', accuracy)\n",
|
45 |
-
"\n",
|
46 |
-
"# Export the trained model as a pickle file\n",
|
47 |
-
"with open('random_forest_model.pkl', 'wb') as f:\n",
|
48 |
-
" pickle.dump(clf, f)"
|
49 |
-
]
|
50 |
-
},
|
51 |
-
{
|
52 |
-
"cell_type": "code",
|
53 |
-
"execution_count": null,
|
54 |
-
"id": "ad204a75",
|
55 |
-
"metadata": {},
|
56 |
-
"outputs": [],
|
57 |
-
"source": []
|
58 |
-
},
|
59 |
-
{
|
60 |
-
"cell_type": "code",
|
61 |
-
"execution_count": null,
|
62 |
-
"id": "11ad2756",
|
63 |
-
"metadata": {},
|
64 |
-
"outputs": [],
|
65 |
-
"source": []
|
66 |
-
},
|
67 |
-
{
|
68 |
-
"cell_type": "code",
|
69 |
-
"execution_count": null,
|
70 |
-
"id": "913f5ce2",
|
71 |
-
"metadata": {},
|
72 |
-
"outputs": [],
|
73 |
-
"source": []
|
74 |
-
}
|
75 |
-
],
|
76 |
-
"metadata": {
|
77 |
-
"kernelspec": {
|
78 |
-
"display_name": "Python 3 (ipykernel)",
|
79 |
-
"language": "python",
|
80 |
-
"name": "python3"
|
81 |
-
},
|
82 |
-
"language_info": {
|
83 |
-
"codemirror_mode": {
|
84 |
-
"name": "ipython",
|
85 |
-
"version": 3
|
86 |
-
},
|
87 |
-
"file_extension": ".py",
|
88 |
-
"mimetype": "text/x-python",
|
89 |
-
"name": "python",
|
90 |
-
"nbconvert_exporter": "python",
|
91 |
-
"pygments_lexer": "ipython3",
|
92 |
-
"version": "3.9.12"
|
93 |
-
}
|
94 |
-
},
|
95 |
-
"nbformat": 4,
|
96 |
-
"nbformat_minor": 5
|
97 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|