<jupyter_start><jupyter_text>De já iremos elaborar o modelo de ML usando o algoritmo SVM<jupyter_code>from sklearn.model_selection import train_test_split<jupyter_output><empty_output><jupyter_text>**Nota: o np.ravel(), transforma os dados em um array de uma dimensão**<jupyter_code>X_train, X_test, y_train, y_test = train_test_split(df_cancer, np.ravel(df_cancer_target), test_size=0.3, random_state=101)
from sklearn.svm import SVC # Support Vector Classifier
svc = SVC()
svc.fit(X_train, y_train)
prediction = svc.predict(X_test)
from sklearn.metrics import classification_report, confusion_matrix
print(classification_report(y_test, prediction))<jupyter_output>precision    recall  f1-score   support

          0       0.00      0.00      0.00        66
          1       0.61      1.00      0.76       105

avg / total       0.38      0.61      0.47       171<jupyter_text>Outro método para melhorar ainda mais a precisão =)<jupyter_code>param_grid = {'C': [0.1, 1, 10, 100, 1000], 'gamma': [1, 0.1, 0.01, 0.001, 0.0001], 'kernel': ['rbf']}
from sklearn.model_selection import GridSearchCV
grid = GridSearchCV(SVC(), param_grid=param_grid, refit=True, verbose=3)
grid.fit(X_train, y_train)
grid.best_params_
svc_pred = grid.predict(X_test)
print(classification_report(y_test, svc_pred))
print(confusion_matrix(y_test, svc_pred))<jupyter_output>[[ 60   6]
 [  3 102]]
{'fraction_non_alphanumeric': 0.11070648215586307, 'fraction_numerical': 0.05680990531682447, 'mean_word_length': 4.4523809523809526, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '131966', 'license': 'Apache-2.0', 'n_tokens_mistral': 563, 'n_tokens_neox': 510, 'n_words': 116, 'path': 'secao20 - Support Vector Machines(SVMs)/aula97_SVM.ipynb', 'repo_name': 'IgoPereiraBarros/data-science-and-machine-learning', 'size': '1373'}