<jupyter_start><jupyter_text>DAT210x - Programming with Python for DS  Module6- Lab3 This code is intentionally missing! Read the directions on the course lab page!<jupyter_code>import pandas as pd
import numpy as np

from sklearn import model_selection
from sklearn import preprocessing

from sklearn.decomposition import PCA
from sklearn.manifold import Isomap

from sklearn import svm

X = pd.read_csv('./Datasets/parkinsons.data')
X.head()
y= X['status'].copy()
X.drop(['name','status'], axis=1, inplace = True)
X.head()
X.describe()
X.shape
X.isnull().any()
X.dtypes
X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, test_size=0.3, random_state=7)
#T = preprocessing.Normalizer()
#T = preprocessing.MaxAbsScaler()
#T = preprocessing.KernelCenterer()
T = preprocessing.StandardScaler()
best_score = 0
best_gamma = 0
best_c = 0
best_pca_comp = 0

for comp in np.arange(4,15):
    X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, test_size=0.3, random_state=7)
    T.fit(X_train)
    X_train = T.transform(X_train)
    X_test = T.transform(X_test)

    model = PCA(n_components = comp)
    model.fit(X_train)
    X_train = model.transform(X_train)
    X_test = model.transform(X_test)

    for ce in np.arange(0.5,2.5,0.5):
        for gamma in np.arange(0.001, 0.101,0.001):
            svcmodel = svm.SVC(C = ce, gamma = gamma)
            svcmodel.fit(X_train, y_train)
            score = svcmodel.score(X_test, y_test)
            if best_score <= score:
                best_score = score
                best_gamma = gamma
                best_c = ce
                best_pca_comp = comp
print(best_score, best_gamma, best_c, best_pca_comp)
best_score = 0
best_gamma = 0
best_c = 0
best_iso_comp = 0
best_iso_neigh = 0

for neigh in np.arange(2,6):
    for comp in np.arange(4,7):
        X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, test_size=0.3, random_state=7)
        T.fit(X_train)
        X_train = T.transform(X_train)
        X_test = T.transform(X_test)

        model = Isomap(n_neighbors = neigh, n_components = comp)
        model.fit(X_train)
        X_train = model.transform(X_train)
        X_test = model.transform(X_test)

        for ce in np.arange(0.5,2.5,0.5):
            for gamma in np.arange(0.001, 0.101,0.001):
                svcmodel = svm.SVC(C = ce, gamma = gamma)
                svcmodel.fit(X_train, y_train)
                score = svcmodel.score(X_test, y_test)
                if best_score <= score:
                    best_score = score
                    best_gamma = gamma
                    best_c = ce
                    best_iso_comp = comp
                    best_iso_neigh = neigh
print(best_score, best_gamma, best_c, best_iso_comp, best_iso_neigh)<jupyter_output>0.949152542373 0.1 2.0 6 5
{'fraction_non_alphanumeric': 0.1045566937477923, 'fraction_numerical': 0.03037795831861533, 'mean_word_length': 2.7019607843137257, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '587810', 'license': 'MIT', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1014, 'n_words': 227, 'path': 'Module6/Module6 - Lab3.ipynb', 'repo_name': 'Hazici/DAT210x', 'size': '2831'}