Close Menu
    Trending
    • Designing a Machine Learning System: Part Five | by Mehrshad Asadi | Aug, 2025
    • Innovations in Artificial Intelligence That Are Changing Agriculture
    • Hundreds of thousands of Grok chats exposed in Google results
    • Workers Over 40 Are Turning to Side Hustles — Here’s Why
    • From Pixels to Perfect Replicas
    • In a first, Google has released data on how much energy an AI prompt uses
    • Mastering Fine-Tuning Foundation Models in Amazon Bedrock: A Comprehensive Guide for Developers and IT Professionals | by Nishant Gupta | Aug, 2025
    • The Key to Building Effective Corporate-Startup Partnerships
    AIBS News
    • Home
    • Artificial Intelligence
    • Machine Learning
    • AI Technology
    • Data Science
    • More
      • Technology
      • Business
    AIBS News
    Home»Artificial Intelligence»Journey to Full-Stack Data Scientist: Model Deployment | by Alex Davis | Jan, 2025
    Artificial Intelligence

    Journey to Full-Stack Data Scientist: Model Deployment | by Alex Davis | Jan, 2025

    Team_AIBS NewsBy Team_AIBS NewsJanuary 4, 2025No Comments3 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    First, for our instance, we have to develop a mannequin. Since this text focuses on mannequin deployment, we is not going to fear concerning the efficiency of the mannequin. As a substitute, we are going to construct a easy mannequin with restricted options to give attention to studying mannequin deployment.

    On this instance, we are going to predict a knowledge skilled’s wage based mostly on a couple of options, resembling expertise, job title, firm dimension, and so on.

    See information right here: https://www.kaggle.com/datasets/ruchi798/data-science-job-salaries (CC0: Public Area). I barely modified the information to scale back the variety of choices for sure options.

    #import packages for information manipulation
    import pandas as pd
    import numpy as np

    #import packages for machine studying
    from sklearn import linear_model
    from sklearn.model_selection import train_test_split
    from sklearn.preprocessing import OneHotEncoder, OrdinalEncoder
    from sklearn.metrics import mean_squared_error, r2_score

    #import packages for information administration
    import joblib

    First, let’s check out the information.

    Picture by Writer

    Since all of our options are categorical, we are going to use encoding to rework our information to numerical. Under, we use ordinal encoders to encode expertise stage and firm dimension. These are ordinal as a result of they characterize some sort of development (1 = entry stage, 2 = mid-level, and so on.).

    For job title and employment sort, we are going to create a dummy variables for every possibility (notice we drop the primary to keep away from multicollinearity).

    #use ordinal encoder to encode expertise stage
    encoder = OrdinalEncoder(classes=[['EN', 'MI', 'SE', 'EX']])
    salary_data['experience_level_encoded'] = encoder.fit_transform(salary_data[['experience_level']])

    #use ordinal encoder to encode firm dimension
    encoder = OrdinalEncoder(classes=[['S', 'M', 'L']])
    salary_data['company_size_encoded'] = encoder.fit_transform(salary_data[['company_size']])

    #encode employmeny sort and job title utilizing dummy columns
    salary_data = pd.get_dummies(salary_data, columns = ['employment_type', 'job_title'], drop_first = True, dtype = int)

    #drop authentic columns
    salary_data = salary_data.drop(columns = ['experience_level', 'company_size'])

    Now that we have now remodeled our mannequin inputs, we are able to create our coaching and take a look at units. We’ll enter these options right into a easy linear regression mannequin to foretell the worker’s wage.

    #outline impartial and dependent options
    X = salary_data.drop(columns = 'salary_in_usd')
    y = salary_data['salary_in_usd']

    #cut up between coaching and testing units
    X_train, X_test, y_train, y_test = train_test_split(
    X, y, random_state = 104, test_size = 0.2, shuffle = True)

    #match linear regression mannequin
    regr = linear_model.LinearRegression()
    regr.match(X_train, y_train)

    #make predictions
    y_pred = regr.predict(X_test)

    #print the coefficients
    print("Coefficients: n", regr.coef_)

    #print the MSE
    print("Imply squared error: %.2f" % mean_squared_error(y_test, y_pred))

    #print the adjusted R2 worth
    print("R2: %.2f" % r2_score(y_test, y_pred))

    Let’s see how our mannequin did.

    Picture by Writer

    Appears like our R-squared is 0.27, yikes. Much more work would have to be performed with this mannequin. We might doubtless want extra information and extra data on the observations. However for the sake of this text, we are going to transfer ahead and save our mannequin.

    #save mannequin utilizing joblib
    joblib.dump(regr, 'lin_regress.sav')



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleBuilding Lightweight AI Agents with Hugging Face SmolAgents, OpenAI GPT, and Serper.dev | by Albin Issac | Tech Learnings | Jan, 2025
    Next Article A Faster PC Is Just One Click Away—and Just $14.99
    Team_AIBS News
    • Website

    Related Posts

    Artificial Intelligence

    From Pixels to Perfect Replicas

    August 21, 2025
    Artificial Intelligence

    AI Twin Generator from Image (Unfiltered): My Experience

    August 21, 2025
    Artificial Intelligence

    Elon Musk’s Grok Imagine Goes Android—“Superhuman Imagination Powers” at Your Fingertips (But Ethics Remain Cloudy)

    August 21, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Designing a Machine Learning System: Part Five | by Mehrshad Asadi | Aug, 2025

    August 21, 2025

    I Tried Buying a Car Through Amazon: Here Are the Pros, Cons

    December 10, 2024

    Amazon and eBay to pay ‘fair share’ for e-waste recycling

    December 10, 2024

    Artificial Intelligence Concerns & Predictions For 2025

    December 10, 2024

    Barbara Corcoran: Entrepreneurs Must ‘Embrace Change’

    December 10, 2024
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    Most Popular

    What Is Hypertargeting and Should I Use It in My Marketing Plan?

    April 16, 2025

    Own Office 2021 and Windows 11 Pro for Only $44.97

    July 10, 2025

    Understanding the Interplay of AI, ML, Technology, Software, and Development | by Tyler McGrath | Feb, 2025

    February 13, 2025
    Our Picks

    Designing a Machine Learning System: Part Five | by Mehrshad Asadi | Aug, 2025

    August 21, 2025

    Innovations in Artificial Intelligence That Are Changing Agriculture

    August 21, 2025

    Hundreds of thousands of Grok chats exposed in Google results

    August 21, 2025
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2024 Aibsnews.comAll Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.