<jupyter_start><jupyter_text>Descriptive statistics (Data Analysis + Visualization).<jupyter_code>df.describe()
df.mean()
lm1 = df.groupby(['sex']).count()
m1 = lm1['schoolsup']
m1
m1.hist();
m1.plot(kind='bar',figsize=(5,5));
df['sex'].hist();
lm2= df.groupby(['age']).count()
m2 =lm2['schoolsup']
m2
m2.hist();
m2.plot(kind='bar',figsize=(5,5));
lm3= df.groupby(['sex','studytime']).count()
m3 =lm3['schoolsup']
m3
m3.hist();
m3.plot(kind='bar',figsize=(5,5));
lm4= df.groupby(['sex','failures']).count()
m4 =lm4['schoolsup']
m4
m4.hist();
m4.plot(kind='bar',figsize=(5,5));
lm5= df.groupby(['failures']).count()
m5 =lm5['schoolsup']
m5
m5.hist();
m5.plot(kind='bar',figsize=(5,5));<jupyter_output><empty_output><jupyter_text>Feature Engineering<jupyter_code>df.columns

df =df[['sex','age','studytime','failures','schoolsup']]
df.head()<jupyter_output><empty_output><jupyter_text>Missing values treatment<jupyter_code>df.isnull().sum()<jupyter_output><empty_output><jupyter_text>Label encoding<jupyter_code>df.head()
df.columns
sex_encoder = LabelEncoder()
df['sex'] = sex_encoder.fit_transform(df['sex'].values)
schoolsup_encoder = LabelEncoder()
df['schoolsup'] = schoolsup_encoder.fit_transform(df['schoolsup'].values)
df.head()<jupyter_output><empty_output><jupyter_text>shrinks data<jupyter_code>X = df.iloc[:, 0:4].values
y = df.iloc[:, 4].values
# Splitting the dataset into the Training set and Test set
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 0)
# Feature Scaling
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)
# Fitting Logistic Regression to the Training set
from sklearn.linear_model import LogisticRegression
classifier = LogisticRegression(random_state = 0)
classifier.fit(X_train, y_train)
# Predicting the Test set results
y_pred = classifier.predict(X_test)
y_pred
# Making the Confusion Matrix
from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_test, y_pred)
cm
from sklearn.metrics import accuracy_score 
accuracy_score(y_test,y_pred,normalize=False)

from sklearn.metrics import classification_report
print(classification_report(y_test,y_pred))<jupyter_output>precision    recall  f1-score   support

          0       0.85      1.00      0.92        84
          1       0.00      0.00      0.00        15

avg / total       0.72      0.85      0.78        99
StarcoderdataJupyterStructuredCleanDedup