<jupyter_start><jupyter_text>Classify Protein Secondary Structure Using It's Amino Acid Sequence explaination of the project..... Imports<jupyter_code>import pandas as pd
import mltoolkit
import sklearn<jupyter_output><empty_output><jupyter_text>Read in processed DataFrame<jupyter_code>df = pd.read_pickle("./input_features.pkl")
df.head(3)<jupyter_output><empty_output><jupyter_text>Select only alpha and beta foldType<jupyter_code>df = df[(df.foldType == 'alpha') | (df.foldType == 'beta')]

print(f"Total number of data: {df.shape[0]}")
df.head(3)<jupyter_output>Total number of data: 2586<jupyter_text>Basic dataset information and setting<jupyter_code>label = 'foldType'
testFraction = 0.1
seed = 123


vector = df.features.iloc[0]
featureCount = len(vector)
print(f"Feature count    : {featureCount}")

 
classCount = df.foldType.unique().size
print(f"Class count    : {classCount}\n")

  
print(f"Dataset size (unbalanced)    : {df.shape[0]}")
print(df.foldType.value_counts())


df = mltoolkit.downsample(df, 'foldType')
print(f"\nDataset size (balanced)  : {df.shape[0]}")
print(df.foldType.value_counts())<jupyter_output>Feature count    : 50
Class count    : 2

Dataset size (unbalanced)    : 2586
alpha    1974
beta      612
Name: foldType, dtype: int64

Dataset size (balanced)  : 1224
beta     612
alpha    612
Name: foldType, dtype: int64<jupyter_text>Random Forest Classifier<jupyter_code>from sklearn.ensemble import RandomForestClassifier

clf = RandomForestClassifier()
mcc = mltoolkit.MultiClassClassifier(clf, 'foldType', testFraction=0.1)
matrics = mcc.fit(df)
for k,v in matrics.items(): print(f"{k}\t{v}")

# Plot ROC 
mltoolkit.plot_roc(mcc.TPR, mcc.FPR, mcc.AUC)    

print("Sample predictions: ")
mcc.prediction.head(10)<jupyter_output>Class	Train	Test

alpha	549	63

beta	552	60

Total time taken: 0.06161332130432129

Methods	RandomForestClassifier
AUC	0.96494708994709
F Score	0.9137931034482758
Accuracy	0.9186991869918699
Precision	0.9464285714285714
Recall	0.8833333333333333
False Positive Rate	0.05357142857142857
True Positive Rate	0.8955223880597015
	
Confusion Matrix
['alpha' 'beta']
[[60  3]
 [ 7 53]]<jupyter_text>Logistic Regression Classifier<jupyter_code>from sklearn.linear_model import LogisticRegression

clf = LogisticRegression()
mcc = mltoolkit.MultiClassClassifier(clf, 'foldType', testFraction=0.1)
matrics = mcc.fit(df)
for k,v in matrics.items(): print(f"{k}\t{v}")
    
# Plot ROC 
mltoolkit.plot_roc(mcc.TPR, mcc.FPR, mcc.AUC)
    
print("Sample predictions: ")
mcc.prediction.head(10)<jupyter_output>Class	Train	Test

alpha	545	67

beta	556	56

Total time taken: 0.020797252655029297

Methods	LogisticRegression
AUC	0.9123134328358209
F Score	0.8275862068965518
Accuracy	0.8373983739837398
Precision	0.8
Recall	0.8571428571428571
False Positive Rate	0.2
True Positive Rate	0.873015873015873
	
Confusion Matrix
['alpha' 'beta']
[[55 12]
 [ 8 48]]<jupyter_text>Simple Multilayer Perception Classifier<jupyter_code>from sklearn.neural_network import MLPClassifier

layers = [featureCount, 32, 32, classCount]
clf = MLPClassifier(solver='sgd', \
                    alpha=1e-5, \
                    hidden_layer_sizes = (32, 32))
mcc = mltoolkit.MultiClassClassifier(clf, 'foldType', testFraction=0.1)

matrics = mcc.fit(df)
for k,v in matrics.items(): print(f"{k}\t{v}")
    
# Plot ROC 
mltoolkit.plot_roc(mcc.TPR, mcc.FPR, mcc.AUC)
    
print("Sample predictions: ")
mcc.prediction.head(10)<jupyter_output>Class	Train	Test

alpha	559	53

beta	542	70

Total time taken: 1.3029253482818604

Methods	MLPClassifier
AUC	0.9549865229110511
F Score	0.9275362318840579
Accuracy	0.9186991869918699
Precision	0.9411764705882353
Recall	0.9142857142857143
False Positive Rate	0.058823529411764705
True Positive Rate	0.8909090909090909
	
Confusion Matrix
['alpha' 'beta']
[[49  4]
 [ 6 64]]
{'fraction_non_alphanumeric': 0.11029986962190352, 'fraction_numerical': 0.1290743155149935, 'mean_word_length': 5.414715719063545, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '106354', 'license': 'Apache-2.0', 'n_tokens_mistral': 1801, 'n_tokens_neox': 1481, 'n_words': 319, 'path': 'Secondary Structure Classification.ipynb', 'repo_name': 'marshuang80/ten_simple_rules', 'size': '3835'}