{ "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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
warehouse_blockmode_of_shipmentcustomer_care_callscustomer_ratingcost_of_the_productprior_purchasesproduct_importancegenderdiscount_offeredweight_in_gms
0AFlight153006mediumM303500
1DRoad51202lowF103800
\n", "
" ], "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 }