Close Menu
    Trending
    • High Paying, Six Figure Jobs For Recent Graduates: Report
    • What If I had AI in 2018: Rent the Runway Fulfillment Center Optimization
    • YouBot: Understanding YouTube Comments and Chatting Intelligently — An Engineer’s Perspective | by Sercan Teyhani | Jun, 2025
    • Inspiring Quotes From Brian Wilson of The Beach Boys
    • AI Is Not a Black Box (Relatively Speaking)
    • From Accidents to Actuarial Accuracy: The Role of Assumption Validation in Insurance Claim Amount Prediction Using Linear Regression | by Ved Prakash | Jun, 2025
    • I Wish Every Entrepreneur Had a Dad Like Mine — Here’s Why
    • Why You’re Still Coding AI Manually: Build a GPT-Backed API with Spring Boot in 30 Minutes | by CodeWithUs | Jun, 2025
    Finance StarGate
    • Home
    • Artificial Intelligence
    • AI Technology
    • Data Science
    • Machine Learning
    • Finance
    • Passive Income
    Finance StarGate
    Home»Machine Learning»Deploying a Production-Ready AI Model — Titanic Survival Predictor | by Akhilesh Veerapareddy | Feb, 2025
    Machine Learning

    Deploying a Production-Ready AI Model — Titanic Survival Predictor | by Akhilesh Veerapareddy | Feb, 2025

    FinanceStarGateBy FinanceStarGateFebruary 24, 2025No Comments2 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    1. Coaching the Machine Studying Mannequin

    Step one was to scrub and preprocess the Titanic dataset and prepare a machine studying mannequin:

    import pandas as pd
    from sklearn.model_selection import train_test_split
    from sklearn.linear_model import LogisticRegression
    from sklearn.metrics import accuracy_score

    # Load dataset
    df = pd.read_csv("titanic.csv")
    df = df.drop(columns=["Cabin", "Name", "Ticket"])

    df = pd.get_dummies(df, columns=["Sex", "Embarked"], drop_first=True)

    # Cut up options and labels
    X = df.drop("Survived", axis=1)
    y = df["Survived"]

    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

    # Practice mannequin
    mannequin = LogisticRegression(max_iter=1000)
    mannequin.match(X_train, y_train)

    # Consider mannequin
    y_pred = mannequin.predict(X_test)
    print("Mannequin Accuracy:", accuracy_score(y_test, y_pred))

    2. Serving the Mannequin as a Flask API

    As soon as the mannequin was skilled, the following step was to make it accessible via a REST API:

    from flask import Flask, request, jsonify
    import joblib
    import numpy as np
    from flask_cors import CORS

    app = Flask(__name__)
    CORS(app)

    # Load skilled mannequin
    mannequin = joblib.load("mannequin/titanic_model.pkl")

    @app.route("/predict", strategies=["POST"])
    def predict():
    knowledge = request.get_json()
    options = np.array([[data["Pclass"], knowledge["Sex"], knowledge["Age"], knowledge["SibSp"], knowledge["Parch"], knowledge["Fare"], knowledge["Embarked_Q"], knowledge["Embarked_S"]]])
    likelihood = mannequin.predict_proba(options)[0][1]
    prediction = "Survived" if likelihood > 0.5 else "Did Not Survive"
    return jsonify({"prediction": prediction, "likelihood": spherical(likelihood * 100, 2)})

    if __name__ == "__main__":
    app.run(debug=True)

    3. Making a Trendy UI for Predictions

    A React frontend was constructed to work together with the API and show predictions in a wealthy, user-friendly interface:

    import { useState } from "react";
    import { ChakraProvider, Field, Button, Enter, Choose, Textual content, VStack } from "@chakra-ui/react";
    import axios from "axios";

    const API_URL = "https://your-api.onrender.com/predict";

    perform App() {
    const [formData, setFormData] = useState({ Pclass: "3", Intercourse: "male", Age: "", SibSp: "0", Parch: "0", Fare: "", Embarked: "S" });
    const [prediction, setPrediction] = useState(null);

    const handleSubmit = async (e) => {
    e.preventDefault();
    const payload = { ...formData, Intercourse: formData.Intercourse === "feminine" ? 1 : 0 };
    const res = await axios.submit(API_URL, payload);
    setPrediction(res.knowledge);
    };

    return (


    Titanic Survival Predictor


    setFormData({ ...formData, Age: e.goal.worth })} required />

    {prediction && {prediction.prediction} ({prediction.likelihood}%)}



    );
    }
    export default App;

    3. Undertaking Hyperlinks

    This enhanced Medium submit now offers a detailed, partaking walkthrough that showcases each the technical depth and deployment points of the mission.



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleThis Is the Real Secret to Exceeding Your Customer’s Expectations
    Next Article 6 Common LLM Customization Strategies Briefly Explained
    FinanceStarGate

    Related Posts

    Machine Learning

    YouBot: Understanding YouTube Comments and Chatting Intelligently — An Engineer’s Perspective | by Sercan Teyhani | Jun, 2025

    June 13, 2025
    Machine Learning

    From Accidents to Actuarial Accuracy: The Role of Assumption Validation in Insurance Claim Amount Prediction Using Linear Regression | by Ved Prakash | Jun, 2025

    June 13, 2025
    Machine Learning

    Why You’re Still Coding AI Manually: Build a GPT-Backed API with Spring Boot in 30 Minutes | by CodeWithUs | Jun, 2025

    June 13, 2025
    Add A Comment

    Comments are closed.

    Top Posts

    Makine Öğrenmesi Eğlencelidir! Bölüm 4: Derin Öğrenme ile Modern Yüz Tanıma | by Hasan Damirli | Mar, 2025

    March 14, 2025

    Protecting Digital Assets with Advanced Technology

    February 17, 2025

    ckhuxihyzu

    February 28, 2025

    What 2024 Taught Us About ESG Engagement

    March 10, 2025

    Why I Chose QDrant Vector Database for My Project? | by Preetham Dundigalla | Mar, 2025

    March 15, 2025
    Categories
    • AI Technology
    • Artificial Intelligence
    • Data Science
    • Finance
    • Machine Learning
    • Passive Income
    Most Popular

    How to Spend Less Time on Email Marketing – And Still Make Money

    March 13, 2025

    The Benefits and Risks of AI in Content Moderation

    February 21, 2025

    Is AI Worth the Investment? Calculate Your Real ROI

    February 4, 2025
    Our Picks

    Barbara Corcoran’s Beloved NYC Penthouse Is for Sale

    May 6, 2025

    The Role of Luck in Sports: Can We Measure It?

    June 6, 2025

    What HVAC Marketing Can Teach Every Industry About Winning in 2025

    February 4, 2025
    Categories
    • AI Technology
    • Artificial Intelligence
    • Data Science
    • Finance
    • Machine Learning
    • Passive Income
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2025 Financestargate.com All Rights Reserved.

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