Close Menu
    Trending
    • Musk’s X appoints ‘king of virality’ in bid to boost growth
    • Why Entrepreneurs Should Stop Obsessing Over Growth
    • Implementing IBCS rules in Power BI
    • What comes next for AI copyright lawsuits?
    • Why PDF Extraction Still Feels LikeHack
    • GenAI Will Fuel People’s Jobs, Not Replace Them. Here’s Why
    • Millions of websites to get ‘game-changing’ AI bot blocker
    • I Worked Through Labor, My Wedding and Burnout — For What?
    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

    Implementing IBCS rules in Power BI

    July 1, 2025
    Artificial Intelligence

    Become a Better Data Scientist with These Prompt Engineering Tips and Tricks

    July 1, 2025
    Artificial Intelligence

    Lessons Learned After 6.5 Years Of Machine Learning

    July 1, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Musk’s X appoints ‘king of virality’ in bid to boost growth

    July 1, 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

    A Sweetgreen Co-Founder Talks About Where the Brand Is Going

    June 3, 2025

    Can AI help modernise Ireland’s healthcare system?

    February 28, 2025

    Hausi Müller’s Quantum Computing Journey

    June 27, 2025
    Our Picks

    Musk’s X appoints ‘king of virality’ in bid to boost growth

    July 1, 2025

    Why Entrepreneurs Should Stop Obsessing Over Growth

    July 1, 2025

    Implementing IBCS rules in Power BI

    July 1, 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.