Close Menu
    Trending
    • STOP Building Useless ML Projects – What Actually Works
    • Credit Risk Scoring for BNPL Customers at Bati Bank | by Sumeya sirmula | Jul, 2025
    • The New Career Crisis: AI Is Breaking the Entry-Level Path for Gen Z
    • 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
    AIBS News
    • Home
    • Artificial Intelligence
    • Machine Learning
    • AI Technology
    • Data Science
    • More
      • Technology
      • Business
    AIBS News
    Home»Machine Learning»Logistic Regression Explained By Someone Who Misused It First | by M Ehtesham Ul Hassan Malik | Jun, 2025
    Machine Learning

    Logistic Regression Explained By Someone Who Misused It First | by M Ehtesham Ul Hassan Malik | Jun, 2025

    Team_AIBS NewsBy Team_AIBS NewsJune 24, 2025No Comments1 Min Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    # Step 1: Import required libraries
    import pandas as pd
    from sklearn.model_selection import train_test_split
    from sklearn.feature_extraction.textual content import CountVectorizer
    from sklearn.linear_model import LogisticRegression
    from sklearn.metrics import accuracy_score

    # Step 2: Pattern dataset
    information = {
    ‘textual content’: [
    ‘Congratulations! You have won a free iPhone!’,
    ‘Important update about your bank account’,
    ‘Let’s meet for coffee tomorrow?’,
    ‘WINNER! Claim your prize now’,
    ‘Can you send me the report?’,
    ‘Earn money quickly from home’,
    ‘Lunch at 1 PM?’,
    ‘You have been selected for a reward’,
    ],
    ‘label’: [1, 1, 0, 1, 0, 1, 0, 1] # 1 = spam, 0 = not spam
    }

    df = pd.DataFrame(information)

    # Step 3: Convert textual content to numeric options
    vectorizer = CountVectorizer()
    X = vectorizer.fit_transform(df[‘text’]) # Bag of phrases mannequin
    y = df[‘label’]

    # Step 4: Cut up information into coaching and testing units
    X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.3, random_state=42
    )

    # Step 5: Prepare the logistic regression mannequin
    mannequin = LogisticRegression()
    mannequin.match(X_train, y_train)

    # Step 6: Make predictions
    y_pred = mannequin.predict(X_test)

    # Step 7: Consider the mannequin
    accuracy = accuracy_score(y_test, y_pred)
    print(“Accuracy:”, accuracy)

    # Step 8: Take a look at on a customized e mail
    pattern = [“Don’t miss out on this limited offer!”]
    sample_features = vectorizer.rework(pattern)
    prediction = mannequin.predict(sample_features)
    print(“Prediction (1=Spam, 0=Not Spam):”, prediction[0])



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleMeerkat Substation Security: Protecting Energy Networks from Threats
    Next Article Reinforcement Learning from Human Feedback, Explained Simply
    Team_AIBS News
    • Website

    Related Posts

    Machine Learning

    Credit Risk Scoring for BNPL Customers at Bati Bank | by Sumeya sirmula | Jul, 2025

    July 1, 2025
    Machine Learning

    Why PDF Extraction Still Feels LikeHack

    July 1, 2025
    Machine Learning

    🚗 Predicting Car Purchase Amounts with Neural Networks in Keras (with Code & Dataset) | by Smruti Ranjan Nayak | Jul, 2025

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

    Top Posts

    STOP Building Useless ML Projects – What Actually Works

    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

    Meta’s Antitrust Trial Begins as FTC Argues Company Built Social Media Monopoly

    April 14, 2025

    What 8 Years in Corporate Life Did — and Didn’t — Prepare Me For as a Founder

    May 18, 2025

    Free Webinar | April 30: Maximize Your Marketing Impact on a Shoestring Budget

    April 11, 2025
    Our Picks

    STOP Building Useless ML Projects – What Actually Works

    July 1, 2025

    Credit Risk Scoring for BNPL Customers at Bati Bank | by Sumeya sirmula | Jul, 2025

    July 1, 2025

    The New Career Crisis: AI Is Breaking the Entry-Level Path for Gen Z

    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.