Close Menu
    Trending
    • Revisiting Benchmarking of Tabular Reinforcement Learning Methods
    • Is Your AI Whispering Secrets? How Scientists Are Teaching Chatbots to Forget Dangerous Tricks | by Andreas Maier | Jul, 2025
    • Qantas data breach to impact 6 million airline customers
    • He Went From $471K in Debt to Teaching Others How to Succeed
    • An Introduction to Remote Model Context Protocol Servers
    • Blazing-Fast ML Model Serving with FastAPI + Redis (Boost 10x Speed!) | by Sarayavalasaravikiran | AI Simplified in Plain English | Jul, 2025
    • AI Knowledge Bases vs. Traditional Support: Who Wins in 2025?
    • Why Your Finance Team Needs an AI Strategy, Now
    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

    Is Your AI Whispering Secrets? How Scientists Are Teaching Chatbots to Forget Dangerous Tricks | by Andreas Maier | Jul, 2025

    July 2, 2025
    Machine Learning

    Blazing-Fast ML Model Serving with FastAPI + Redis (Boost 10x Speed!) | by Sarayavalasaravikiran | AI Simplified in Plain English | Jul, 2025

    July 2, 2025
    Machine Learning

    From Training to Drift Monitoring: End-to-End Fraud Detection in Python | by Aakash Chavan Ravindranath, Ph.D | Jul, 2025

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

    Top Posts

    Revisiting Benchmarking of Tabular Reinforcement Learning Methods

    July 2, 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 Data Driven Exploration of TV Episode IMDb Ratings | by Ben Murphy | Dec, 2024

    December 10, 2024

    समुद्री ड्रोन: आधुनिक नौवहन और समुद्री अनुसंधान की नई दिशा | by Info India | Jun, 2025

    June 5, 2025

    Salto Robot Masters Squirrel-Like Branch Leaping

    March 19, 2025
    Our Picks

    Revisiting Benchmarking of Tabular Reinforcement Learning Methods

    July 2, 2025

    Is Your AI Whispering Secrets? How Scientists Are Teaching Chatbots to Forget Dangerous Tricks | by Andreas Maier | Jul, 2025

    July 2, 2025

    Qantas data breach to impact 6 million airline customers

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