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

# # Mobile Network 

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns

# %matplotlib inline

dataset = pd.read_csv('dandi.csv')
X = dataset.iloc[:, 0:5].values
y = dataset.iloc[:, 5].values
dataset.head()

# ## EDA

# Checkking for missing values
sns.heatmap(dataset.isnull(), yticklabels = False, cbar = False,cmap = 'viridis')

df = dataset
df.info()

df.describe()

sns.countplot(x = "STATE", hue = "RSRQ", data = df)

sns.pairplot(df)

# ## Linear Discriment analysis
# - feature scaling the data
# - spliting the dataset into train and test data

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.1, random_state = 0)

from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)

from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
lda = LinearDiscriminantAnalysis(n_components = 2)
X_train = lda.fit_transform(X_train, y_train)
X_test = lda.transform(X_test)

# ## Logistic Regression
# *Classification*

from sklearn.linear_model import LogisticRegression
classifier = LogisticRegression(random_state = 0)
classifier.fit(X_train, y_train)

y_pred = classifier.predict(X_test)

from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix

"""
    Confusion matrix
"""
print(confusion_matrix(y_test, y_pred))

"""
Classification Report
"""
print(classification_report(y_test, y_pred))

y_pred = classifier.predict(X_test)
for i in range(len(y_pred)):
    if y_pred[i] == 0:
        print("Link Failure at ", X_test[i])

# # SVM
# - Support Vector Machine

from sklearn.svm import SVC

model = SVC()

model.fit(X_train, y_train)

prediction = model.predict(X_test)

print(confusion_matrix(y_test, prediction))

print(classification_report(y_test, prediction))



StarcoderdataJupyterScriptsDedupFiltered