<jupyter_start><jupyter_text>Usando Cross Validation<jupyter_code>import pandas as pd
from sklearn.model_selection import cross_val_score
from sklearn import svm
import warnings
warnings.filterwarnings('ignore')
dados = pd.read_csv('iris.csv')
dados.head()
#importando a imagem para o projeto
from IPython.display import Image
Image(filename = "cross-validation-folds.png", width=500, height=500)
classe = dados.Species
features = dados.drop('Species', axis=1, inplace=False)
classe.head()
features.head()
#pegando uma instancia do SVM
svm = svm.SVC()
#executando a validação cruzada
scores = cross_val_score(svm, features, classe, cv=5, scoring='accuracy')
scores
#verificando a acuracia
scores.mean()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10792349726775956, 'fraction_numerical': 0.01092896174863388, 'mean_word_length': 7.623529411764705, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '89370', 'license': 'MIT', 'n_tokens_mistral': 264, 'n_tokens_neox': 254, 'n_words': 64, 'path': 'Cross Validation.ipynb', 'repo_name': 'JoanesMiranda/Machine-learning', 'size': '732'}