{ "cells": [ { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Inspection Time Test MSE: 4.0716280667897373e-13\n" ] } ], "source": [ "import pandas as pd\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.ensemble import HistGradientBoostingRegressor\n", "from sklearn.metrics import mean_squared_error\n", "import pickle\n", "# Load the dataset from CSV\n", "selected_columns = ['Process type', 'Part Od', 'Part ID', 'Part Width', 'Finish Wt', 'Input Weight',\n", " 'Raw material cost', 'Process cost', 'Machining Time', 'Machining cost ', 'Inspection Time'] # Add more columns as needed\n", "data = pd.read_csv('/Users/abhijay/Desktop/EY_INTERNSHIP/Data_4.csv', usecols=selected_columns) # Replace 'your_dataset.csv' with the path to your CSV file\n", "\n", "# For predicting inspection time, assume 'Inspection Time' is the target variable\n", "X_inspection = data.drop(columns=['Inspection Time'])\n", "y_inspection = data['Inspection Time']\n", "\n", "# Split the data for inspection time into training and testing sets (80% train, 20% test)\n", "X_inspection_train, X_inspection_test, y_inspection_train, y_inspection_test = train_test_split(X_inspection, y_inspection, test_size=0.2, random_state=42)\n", "\n", "# Train the model for inspection time\n", "model_inspection = HistGradientBoostingRegressor()\n", "model_inspection.fit(X_inspection_train, y_inspection_train)\n", "\n", "# Evaluate the model\n", "\n", "test_predictions_inspection = model_inspection.predict(X_inspection_test)\n", "\n", "test_mse_inspection = mean_squared_error(y_inspection_test, test_predictions_inspection)\n", "\n", "print(\"Inspection Time Test MSE:\", test_mse_inspection)\n", "\n", "# Save the model to disk\n", "with open('inspection_model.pkl', 'wb') as model_file:\n", " pickle.dump(model_inspection, model_file)\n" ] } ], "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.3" } }, "nbformat": 4, "nbformat_minor": 2 }