<jupyter_start><jupyter_text>What is machine learning?The art and science of:  giving computer the ability to learn to make decisions from data... without being explicitly programmed!!    Examples:           Learning to predict whether an email is spam or not (the most typical example).         Clustering wikipedia entries into different categories. Unsupervised learning: Uncovering hidden patterns from unlabeled data.Exmple:  Grouping customers into distinct categories (Clustering) Reinforcement learning: Software agents interact with an enviroment.     Learn how to optimize their behavior.    Given a system of rewards and punishments.            note: In 2016, reinforcement learning was used to train Google DeepMind's Alpha Go, which was the first computer program to beat the world champion in Go. Supervised learning : predictor variables/features and a target variable. The goal is predict the target variable, given the predictor variables.    In classification the target variable consist of categories.        note: Here, we will use scikit-learn/sklearn. Also, there are others like TensorFlow, Keras and Pytorch.         Now, we will import the libraries that we will need to code. Also, we will set the plotting style to 'ggplot' using plt dot style dot use. Firstl, because it looks great and secondly, in order to help all you R aficionados feel at home XD!!!<jupyter_code>import sklearn.datasets
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

plt.style.use('ggplot')<jupyter_output><empty_output><jupyter_text>Then, we load the dataset and assign the data to a variable iris. In the second line, we print the keys, where DESCR provides a description of the dataset; the target names which contains the values features; and the target, which is the target data.<jupyter_code>iris = sklearn.datasets.load_iris()
print(iris.keys())
type(iris.data), type(iris.target)<jupyter_output>dict_keys(['data', 'target', 'target_names', 'DESCR', 'feature_names'])<jupyter_text>In data, there are 150 rows and 4 columns. (samples are in rows and columns are in columns). The categories consist en 'setosa','vesicolor','virginica' which we can see them printing the target names (or categories).<jupyter_code>iris.data.shape
iris.target_names<jupyter_output><empty_output><jupyter_text>In order to realize EDA (Exploratory data analysis), we wil assign the feature and target data to x and y, respectively. So, we construct a DataFrame of Pandas (in this case as pd) with the feature names.<jupyter_code>X = iris.data
Y = iris.target
df = pd.DataFrame(X, columns = iris.feature_names)
print(df)<jupyter_output>sepal length (cm)  sepal width (cm)  petal length (cm)  petal width (cm)
0                  5.1               3.5                1.4               0.2
1                  4.9               3.0                1.4               0.2
2                  4.7               3.2                1.3               0.2
3                  4.6               3.1                1.5               0.2
4                  5.0               3.6                1.4               0.2
5                  5.4               3.9                1.7               0.4
6                  4.6               3.4                1.4               0.3
7                  5.0               3.4                1.5               0.2
8                  4.4               2.9                1.4               0.2
9                  4.9               3.1                1.5               0.1
10                 5.4               3.7                1.5               0.2
11                 4.8               3.4                1.6     [...]<jupyter_text>we will visualize the data using scatter. We pass it the our DataFrame, along with our target variables as argument to the parameter c (thus, ensuring that each species will be colored in direfent way). figsize specifies the size of figure. S determinates the marker size and the marker stablish the type.<jupyter_code>pd.plotting.scatter_matrix(df, c = Y, figsize = [5, 10], s = 100, marker = 'A')<jupyter_output><empty_output><jupyter_text>In the figure, the diagonal are histograms of the features. The off-diagonal figures are scatter plots of the column feature vs row feature colored by the target variable. How we can see in the sub-figure (row 3, column 4), the petal width and length are highly correlated, as you may expect, and that flowers are clustered according to species.        note: you should use the next methods in order to get data information.<jupyter_code>print(df.info())
print(df.describe())<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 150 entries, 0 to 149
Data columns (total 4 columns):
sepal length (cm)    150 non-null float64
sepal width (cm)     150 non-null float64
petal length (cm)    150 non-null float64
petal width (cm)     150 non-null float64
dtypes: float64(4)
memory usage: 4.8 KB
None
       sepal length (cm)  sepal width (cm)  petal length (cm)  \
count         150.000000        150.000000         150.000000   
mean            5.843333          3.054000           3.758667   
std             0.828066          0.433594           1.764420   
min             4.300000          2.000000           1.000000   
25%             5.100000          2.800000           1.600000   
50%             5.800000          3.000000           4.350000   
75%             6.400000          3.300000           5.100000   
max             7.900000          4.400000           6.900000   

       petal width (cm)  
count        150.000000  
mean           1.198667  
std            0.76[...]
{'fraction_non_alphanumeric': 0.06593995711222302, 'fraction_numerical': 0.0636168691922802, 'mean_word_length': 1.9504480759093306, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 23, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '295910', 'license': 'MIT', 'n_tokens_mistral': 1719, 'n_tokens_neox': 1490, 'n_words': 633, 'path': 'Machine learning basics/SupervisedLearningWithScikitLearn.ipynb', 'repo_name': 'sergiogaitan/Study_Guides', 'size': '5596'}