"""
### *E.coli* protein sequence 

This data contains protein localization sites

Attribute Information:

1. Sequence Name: Accession number for the SWISS-PROT database
2. mcg: McGeoch's method for signal sequence recognition.
3. gvh: von Heijne's method for signal sequence recognition.
4. lip: von Heijne's Signal Peptidase II consensus sequence score. Binary attribute.
5. chg: Presence of charge on N-terminus of predicted lipoproteins. Binary attribute.
6. aac: score of discriminant analysis of the amino acid content of outer membrane and periplasmic proteins.
7. alm1: score of the ALOM membrane spanning region prediction program.
8. alm2: score of ALOM program after excluding putative cleavable signal regions from the sequence.
"""
"""
## Importing Libraies
"""
import pandas as pd 
import numpy as np

import matplotlib.pyplot as plt
import seaborn as sns

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler,MinMaxScaler

from sklearn.linear_model import LogisticRegression
data=pd.read_csv("../input/ecoli-uci-dataset/ecoli.csv")
data
data.info()
"""
### Preprocessing
"""
def preprocessing(df):
    df=df.copy() 
    
    #Dropping, since the SEQUENCE_NAME not required
    df=df.drop(["SEQUENCE_NAME"],axis=1)
    
    #Since it is a multiclass lable,We seen that  cp ratio is too high ,its  not a good model.so,it is now cp vs other
    df["SITE"]=df["SITE"].apply(lambda x: x if x=='cp' else"others")
    
    
    #Split X and y
    X=df.drop(["SITE"],axis=1)
    y=df["SITE"]
    
    
    # Training
    X_train,X_test,y_train,y_test=train_test_split(X,y,train_size=0.7,shuffle=True,random_state=1)
    
    #scalling
    scaler=StandardScaler()
    scaler.fit(X_train)
    X_train=pd.DataFrame(scaler.transform(X_train),index=X_train.index,columns=X_train.columns)
    X_test=pd.DataFrame(scaler.transform(X_test),index=X_test.index,columns=X_test.columns)
    return  X_train,X_test,y_train,y_test
X_train,X_test,y_train,y_test= preprocessing(data)
X_train.describe()
"""
Since it is a multiclass lable,
We seen that  cp ratio is too high ,its  not a good model
so,it is now cp vs other
"""
y_train
"""
### Training
"""
model=LogisticRegression()
model.fit(X_train,y_train)
print("Model accuracy:{:.2f}%".format(model.score(X_test,y_test)*100))