# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + id="ecZE89cYoec2"
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt


# + id="-Rr8AoU7ovEg"
df = pd.read_csv('/content/data.csv')

# + colab={"base_uri": "https://localhost:8080/", "height": 203} id="rYKFlHBfozOh" outputId="6c1fb54b-c7d4-4da5-864c-d23793a2b024"
df.head()

# + colab={"base_uri": "https://localhost:8080/"} id="FqKGs57co1BI" outputId="b9185c26-ab36-4bac-b738-ed08691af87e"
type(df)

# + colab={"base_uri": "https://localhost:8080/"} id="vx-Rv1dIqlHy" outputId="9fe0b0d6-7999-452f-a18f-9442bb5472b9"
df.shape

# + colab={"base_uri": "https://localhost:8080/"} id="mZ6uGfIao3Ok" outputId="09731022-941a-494c-87ea-d5722053e2be"
df.info()

# + colab={"base_uri": "https://localhost:8080/", "height": 295} id="EtoQm4ZspqD9" outputId="be29c097-e23d-4df0-ffb6-8b4da85a79ea"
df.describe()

# + colab={"base_uri": "https://localhost:8080/"} id="n6LOUBQ7psp3" outputId="61e1664c-a6ef-4240-d414-517adaf69b08"
df.isnull().sum()


# + [markdown] id="4Df9z7-ppxIW"
# Train Test Splitting

# + id="hwD0hk1ypuXI"
def train_test_split(data, ratio):
  np.random.seed(56)
  shuffled = np.random.permutation(len(data))
  test_set_size = int(len(data)*ratio)
  test_indices = shuffled[:test_set_size]
  train_indices = shuffled[test_set_size:]
  return data.iloc[train_indices], data.iloc[test_indices]


# + id="2vzB5LNKqXuv"
train, test = train_test_split(df, 0.2)

# + colab={"base_uri": "https://localhost:8080/"} id="81QI9H9gqe7j" outputId="a822d8b6-7d3d-4551-cf16-2e9a146d65c6"
train.shape, test.shape

# + id="ffvPMFBDqhdy"
x_train = train[['fever','bodyPain','age','runnyNose','diffBreath']].to_numpy()
x_test = test[['fever','bodyPain','age','runnyNose','diffBreath']].to_numpy()

# + id="ji-FFsrzrvas"
y_train = train[['infectionProb']].to_numpy().reshape(2060,)
y_test = test[['infectionProb']].to_numpy().reshape(515,)


# + colab={"base_uri": "https://localhost:8080/"} id="cHGgrrZrsEPI" outputId="9d1f28e2-de74-4534-f330-c858a9bcb8a6"
x_train.shape, y_train.shape

# + colab={"base_uri": "https://localhost:8080/"} id="3Ru-QYcosJX8" outputId="afc78e98-53a3-4b6d-eefe-057b9fe0e04f"
x_test.shape, y_test.shape

# + [markdown] id="R6oXe_hqsUGw"
# Create the Model

# + id="tvIImEXAsQeA"
from sklearn.linear_model import LogisticRegression

# + id="gnUgHaeIsNHY"
clf = LogisticRegression()

# + colab={"base_uri": "https://localhost:8080/"} id="gjJaSaWrsbOb" outputId="04c4429b-cf41-4ffa-c557-15dce2dd7f3b"
clf.fit(x_train, y_train)

# + id="BXjM6mFKsfDi"
y_pred = clf.predict(x_test)

# + colab={"base_uri": "https://localhost:8080/"} id="BQ4wGbtWt7Um" outputId="8fe9ccbb-3c7d-4bb9-cd9a-13aeef69b4ca"
clf.score(x_train, y_train)

# + colab={"base_uri": "https://localhost:8080/"} id="9rBgTscqt-L8" outputId="3844e37b-f886-4d8d-e7fc-26396c8bfd38"
clf.score(x_test, y_test)

# + id="y4zg4rfIuA_T"
inputFeatures = [102, 1, 22, -1, 1]
infProb =clf.predict_proba([inputFeatures])[0][1]

# + colab={"base_uri": "https://localhost:8080/"} id="rL7UiUFRuNuI" outputId="c4809f85-b768-464d-922d-9aa5c6af7087"
infProb

# + id="hS5yX7Fgug6J"


StarcoderdataJupyterScriptsDedupFiltered