0% found this document useful (0 votes)
9 views

Logistic Regression - Colab

The document outlines a process for analyzing a dataset using Python, specifically focusing on logistic regression to predict insurance based on age. It includes data loading, visualization, splitting the dataset into training and testing sets, and fitting a logistic regression model. The model predicts insurance status for given ages, demonstrating the application of statistical theories in handling big data.

Uploaded by

dev009258
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Logistic Regression - Colab

The document outlines a process for analyzing a dataset using Python, specifically focusing on logistic regression to predict insurance based on age. It includes data loading, visualization, splitting the dataset into training and testing sets, and fitting a logistic regression model. The model predicts insurance status for given ages, demonstrating the application of statistical theories in handling big data.

Uploaded by

dev009258
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

import pandas as pd #handle big data and make conclusions based on statistical theories

from matplotlib import pyplot as plt


%matplotlib inline

df = pd.read_csv('logistic.csv')

df

age insurance
0 22 0

1 25 0

2 47 1

3 52 1

4 46 1

plt.scatter(df.age,df.insurance,marker='*',color='red')

<matplotlib.collections.PathCollection at 0x799f67280790>

from sklearn.model_selection import train_test_split


x_train, x_test, y_train, y_test= train_test_split(df[['age']], df.insurance, train_size=0.

x_train
age
0 22

1 25

3 52

2 47

len(x_test)

from sklearn.linear_model import LogisticRegression


model = LogisticRegression()

model.fit(x_train, y_train)

▾ LogisticRegression i ?

LogisticRegression()

x_test

age
4 46

model.predict(x_test)

array([1])

model.predict([[25]])

/usr/local/lib/python3.11/dist-packages/sklearn/utils/validation.py:2739: UserWa
warnings.warn(
array([0])

You might also like