<jupyter_start><jupyter_text>Machine Learning in Python*Prepared by:***<NAME>**  Faculty, Software Technology Department  College of Computer Studies - De La Salle University Time to practice what you have learned! Your task is to develop machine learning models for the datasets provided below.  Import libraries<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

import seaborn as sns

sns.set_style('darkgrid')

sns.set_palette('Set2')
# sns.color_palette('Set2')<jupyter_output><empty_output><jupyter_text>Exercise: Diabetes dataset - Split the data into train and test sets. Train set should get 80% of the original set. Test set should get the remaining 20%. Use `random_state = 42` when using sklearn's train-test split function to get consistent results. - Train a kNN model for this dataset.  - Return the score for the test set using the model you trained.<jupyter_code>from sklearn import datasets

data_bunch = datasets.load_diabetes(return_X_y=False)
print(data_bunch['DESCR'])
X, y = data_bunch['data'], data_bunch['target']
# your code here<jupyter_output><empty_output><jupyter_text>Exercise: Titanic DatasetLet's revisit one of your favorite datasets: the Titanic. Similar to the previous exercise, do the following: - set the `Survived` column as your target. - Split the data into train and test sets. Train set should get 80% of the original set. Test set should get the remaining 20%. Use `random_state = 42` when using sklearn's train-test split function to get consistent results. - Train a kNN and a linear model for this dataset.  - Return the score for the test set using the model you trained. Hint! Inspect your data first. You might need to do some preprocessing.<jupyter_code>df = pd.read_csv('https://raw.githubusercontent.com/Cyntwikip/data-repository/main/titanic.csv')
df.head()
# your code here<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07712625462229265, 'fraction_numerical': 0.007395668251452721, 'mean_word_length': 5.355704697986577, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 1, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '158491', 'license': 'MIT', 'n_tokens_mistral': 566, 'n_tokens_neox': 541, 'n_words': 229, 'path': 'ml_python_exercise.ipynb', 'repo_name': 'Cyntwikip/Machine-Learning', 'size': '1905'}