Close Menu
    Trending
    • Future of Business Analytics in This Evolution of AI | by Advait Dharmadhikari | Jun, 2025
    • You’re Only Three Weeks Away From Reaching International Clients, Partners, and Customers
    • How Brain-Computer Interfaces Are Changing the Game | by Rahul Mishra | Coding Nexus | Jun, 2025
    • How Diverse Leadership Gives You a Big Competitive Advantage
    • Making Sense of Metrics in Recommender Systems | by George Perakis | Jun, 2025
    • AMD Announces New GPUs, Development Platform, Rack Scale Architecture
    • The Hidden Risk That Crashes Startups — Even the Profitable Ones
    • Systematic Hedging Of An Equity Portfolio With Short-Selling Strategies Based On The VIX | by Domenico D’Errico | Jun, 2025
    Finance StarGate
    • Home
    • Artificial Intelligence
    • AI Technology
    • Data Science
    • Machine Learning
    • Finance
    • Passive Income
    Finance StarGate
    Home»Machine Learning»Selection of the Loss Functions for Logistic Regression | by Rebecca Li | Mar, 2025
    Machine Learning

    Selection of the Loss Functions for Logistic Regression | by Rebecca Li | Mar, 2025

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


    To raised perceive the distinction, let’s visualize how MSE vs. Cross-Entropy Loss behave for classification.

    Now that we determined to make use of the Cross Entropy for loss operate. To make use of the loss operate to information the modifications of the weights and bias, we have to take the gradient of the loss operate.

    """
    ------ Psudo Code------
    # Practice logistic regression mannequin
    mannequin = LogisticRegression()
    mannequin.match(X_train, y_train)
    # Predict possibilities for take a look at set
    y_probs = mannequin.predict_proba(X_test)[:, 1] # Likelihood for sophistication 1 (related)
    # Rank objects primarily based on predicted possibilities
    rating = np.argsort(-y_probs) # Destructive signal for descending order
    ------ Fundamental operate ------
    """import numpy as np
    """
    Fundamental operate
    """
    def pred (X,w):
    # X: Enter options, w: Weights
    # y hat = sig (1/ 1+e^-z), z = wx +b
    z = np.matmul(X,w)
    y_hat = 1/(1+np.exp(-z))
    return y_hat
    def loss(X,Y,w):
    # Compute the binary cross-entropy loss
    # Loss just isn't instantly used within the practice,g however its gradient is used to replace the weights
    y_pred = pred(X, w)
    sum = - Y * np.log(y_pred) + (1-Y) * np.log(1-y_pred)
    return - np.imply (sum)
    def gradient (X,Y,w):
    # Spinoff of Loss to w and b
    # The gradient of the loss operate tells us the path and magnitude during which the mannequin’s parameters needs to be adjusted to attenuate the loss.
    y_pred = pred(X, w)
    g = - np.matmul( X.T, (y_pred- Y) ) / X.form[0]
    return g
    """
    Part of coaching and testing
    """
    def practice(X,Y, iter= 10000, learning_rate = 0.002):
    w = np.zeros((X.form[1],1)) # w0 intialization at Zero
    for i in vary(iter):
    w = w - learning_rate * gradient(X,Y,w)
    y_pred = pred(X,w)
    if i % 1000 == 0:
    print (f"iteration {i}, loss = { loss(X,Y,w)}" )
    return wdef take a look at(X,Y, w):
    y_pred = pred(X,w)
    y_pred_labels = (y_pred > 0.5).astype(int)
    accuracy = np.imply(y_pred_labels == Y)
    return accuracy



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleAPI Security Testing: Best Practices for Penetration Testing APIs
    Next Article Using GPT-4 for Personal Styling
    FinanceStarGate

    Related Posts

    Machine Learning

    Future of Business Analytics in This Evolution of AI | by Advait Dharmadhikari | Jun, 2025

    June 14, 2025
    Machine Learning

    How Brain-Computer Interfaces Are Changing the Game | by Rahul Mishra | Coding Nexus | Jun, 2025

    June 14, 2025
    Machine Learning

    Making Sense of Metrics in Recommender Systems | by George Perakis | Jun, 2025

    June 14, 2025
    Add A Comment

    Comments are closed.

    Top Posts

    Deep Learning for Echocardiogram Interpretation

    March 18, 2025

    AI Agent Developer: A Journey Through Code, Creativity, and Curiosity | by Talha Nazar | Feb, 2025

    February 19, 2025

    How Much Do Salesforce Employees Make? Median Salaries

    May 30, 2025

    Neural Networks – Intuitively and Exhaustively Explained

    February 4, 2025

    RISA Labs Raises $3.5M to Fight Treatment Delays with AI-Powered Workflow Automation in Oncology

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

    Deep Panic Thanks To DeepSeek’s Fast, Open-Source AI Model

    February 2, 2025

    Analisis Segmentasi Konsumen Berbasis Data | by Allysa Febriana | Apr, 2025

    April 13, 2025

    Klarna CEO Reverses Course By Hiring More Humans, Not AI

    May 10, 2025
    Our Picks

    AI learns how vision and sound are connected, without human intervention | MIT News

    May 22, 2025

    Towards Data Science is Launching as an Independent Publication

    February 4, 2025

    Zero Human Code: What I Learned from Forcing AI to Build (and Fix) Its Own Code for 27 Straight Days

    February 19, 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.