CoolFace
Apppublic

2Nisavi2/Regretion_Salary

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
API_CODE.ipynb84 linesDownload Raw Back to root
1{2 "cells": [3  {4   "cell_type": "code",5   "execution_count": 2,6   "metadata": {},7   "outputs": [8    {9     "name": "stdout",10     "output_type": "stream",11     "text": [12      "* Running on local URL:  http://127.0.0.1:7862\n",13      "* Running on public URL: https://db4571dade71304cf0.gradio.live\n",14      "\n",15      "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from the terminal in the working directory to deploy to Hugging Face Spaces (https://huggingface.co/spaces)\n"16     ]17    },18    {19     "data": {20      "text/html": [21       "<div><iframe src=\"https://db4571dade71304cf0.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"22      ],23      "text/plain": [24       "<IPython.core.display.HTML object>"25      ]26     },27     "metadata": {},28     "output_type": "display_data"29    },30    {31     "data": {32      "text/plain": []33     },34     "execution_count": 2,35     "metadata": {},36     "output_type": "execute_result"37    }38   ],39   "source": [40    "import gradio as gr\n",41    "import joblib\n",42    "\n",43    "# Cargar modelo y transformer\n",44    "model = joblib.load(\"Model/model_poly.pkl\")\n",45    "transformer = joblib.load(\"Model/poly_transformer.pkl\")\n",46    "\n",47    "# Función de predicción con manejo de errores\n",48    "def predict(input_data):\n",49    "    try:\n",50    "        transformed_data = transformer.transform([[input_data]])\n",51    "        prediction = model.predict(transformed_data)\n",52    "        return str(prediction[0])\n",53    "    except Exception as e:\n",54    "        return f\"Error: {str(e)}\"\n",55    "\n",56    "# Crear interfaz web\n",57    "interface = gr.Interface(fn=predict, inputs=\"text\", outputs=\"text\")\n",58    "interface.launch(share=True)"59   ]60  }61 ],62 "metadata": {63  "kernelspec": {64   "display_name": "base",65   "language": "python",66   "name": "python3"67  },68  "language_info": {69   "codemirror_mode": {70    "name": "ipython",71    "version": 372   },73   "file_extension": ".py",74   "mimetype": "text/x-python",75   "name": "python",76   "nbconvert_exporter": "python",77   "pygments_lexer": "ipython3",78   "version": "3.12.7"79  }80 },81 "nbformat": 4,82 "nbformat_minor": 283}84