Spaces:
Configuration error
Configuration error
File size: 5,408 Bytes
d81b645 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# Import Libraries\n",
"import pandas as pd\n",
"import pickle"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"with open('model.pkl', 'rb') as model_pipeline:\n",
" model = pickle.load(model_pipeline)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>warehouse_block</th>\n",
" <th>mode_of_shipment</th>\n",
" <th>customer_care_calls</th>\n",
" <th>customer_rating</th>\n",
" <th>cost_of_the_product</th>\n",
" <th>prior_purchases</th>\n",
" <th>product_importance</th>\n",
" <th>gender</th>\n",
" <th>discount_offered</th>\n",
" <th>weight_in_gms</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>A</td>\n",
" <td>Flight</td>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" <td>300</td>\n",
" <td>6</td>\n",
" <td>medium</td>\n",
" <td>M</td>\n",
" <td>30</td>\n",
" <td>3500</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>D</td>\n",
" <td>Road</td>\n",
" <td>5</td>\n",
" <td>1</td>\n",
" <td>20</td>\n",
" <td>2</td>\n",
" <td>low</td>\n",
" <td>F</td>\n",
" <td>10</td>\n",
" <td>3800</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" warehouse_block mode_of_shipment customer_care_calls customer_rating \\\n",
"0 A Flight 1 5 \n",
"1 D Road 5 1 \n",
"\n",
" cost_of_the_product prior_purchases product_importance gender \\\n",
"0 300 6 medium M \n",
"1 20 2 low F \n",
"\n",
" discount_offered weight_in_gms \n",
"0 30 3500 \n",
"1 10 3800 "
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data_inf = {\n",
" 'warehouse_block':['A','D'] , # Block Warehouse A, Block Warehouse D\n",
" 'mode_of_shipment': ['Flight','Road'], # Shipment Flight, Road\n",
" 'customer_care_calls':[1,5], # Enquiry Calls 1 Time, Enquiry Calls 5 Times\n",
" 'customer_rating': [5,1], # Rating 5 (highest), Rating 1 (Lowest)\n",
" 'cost_of_the_product':[300,20], # Cost $300, Cost $20\n",
" 'prior_purchases':[6,2], # Prior Purchase 6 Times Before, Prior Purchase 2 Times Before\n",
" 'product_importance':['medium','low'], # Importance Product Medium, Importance Product Low\n",
" 'gender':['M','F'], # Male, Female\n",
" 'discount_offered':[30,10], # Discount 30%, Discount 10%\n",
" 'weight_in_gms':[3500,3800], # Weight 3500 grams, Weight 3800 grams\n",
"}\n",
"data_inf = pd.DataFrame(data_inf)\n",
"data_inf"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"def label_cluster(cluster_number):\n",
" if cluster_number == 0:\n",
" return \"Shipping Not On Time !\"\n",
" elif cluster_number == 1:\n",
" return \"Shipping On Time !\"\n",
" else:\n",
" return \"Unknown\""
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Shipping On Time !', 'Shipping Not On Time !']\n"
]
}
],
"source": [
"data_inf_pred = model.predict(data_inf)\n",
"data_inf_pred\n",
"\n",
"labels = [label_cluster(cluster) for cluster in data_inf_pred]\n",
"print(labels)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|