<jupyter_start><jupyter_text>Intel® Extension for Scikit-learn SVC for Adult dataset<jupyter_code>from time import time
from sklearn import metrics
from sklearn.model_selection import train_test_split
from sklearn.datasets import fetch_openml
x, y = fetch_openml(name='a9a', return_X_y=True)
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=42)<jupyter_output><empty_output><jupyter_text>Intel Extension for Scikit-learn (previously known as daal4py) contains drop-in replacement functionality for the stock scikit-learn package. You can take advantage of the performance optimizations of Intel Extension for Scikit-learn by adding just two lines of code before the usual scikit-learn imports:<jupyter_code>from sklearnex import patch_sklearn
patch_sklearn()<jupyter_output>Intel(R) Extension for Scikit-learn* enabled (https://github.com/intel/scikit-learn-intelex)<jupyter_text>Intel(R) Extension for Scikit-learn patching affects performance of specific Scikit-learn functionality. Refer to the [list of supported algorithms and parameters](https://intel.github.io/scikit-learn-intelex/algorithms.html) for details. In cases when unsupported parameters are used, the package fallbacks into original Scikit-learn. If the patching does not cover your scenarios, [submit an issue on GitHub](https://github.com/intel/scikit-learn-intelex/issues).<jupyter_code>params = {
    'C': 100.0,
    'kernel': 'rbf',
    'gamma': 'scale'
}<jupyter_output><empty_output><jupyter_text>Training of the SVC algorithm with Intel(R) Extension for Scikit-learn for Adult dataset<jupyter_code>start = time()
from sklearn.svm import SVC
classifier = SVC(**params).fit(x_train, y_train)
f"Intel(R) extension for Scikit-learn time: {(time() - start):.2f} s"<jupyter_output><empty_output><jupyter_text>Predict and get a result of the SVC algorithm with Intel(R) Extension for Scikit-learn<jupyter_code>predicted = classifier.predict(x_test)
report = metrics.classification_report(y_test, predicted)
print(f"Classification report for SVC:\n{report}\n")<jupyter_output>Classification report for SVC:
              precision    recall  f1-score   support

        -1.0       0.87      0.90      0.88      7414
         1.0       0.64      0.58      0.61      2355

    accuracy                           0.82      9769
   macro avg       0.76      0.74      0.75      9769
weighted avg       0.82      0.82      0.82      9769<jupyter_text>*The first column of the classification report above is the class labels.*    In order to cancel optimizations, we use *unpatch_sklearn* and reimport the class SVC.<jupyter_code>from sklearnex import unpatch_sklearn
unpatch_sklearn()<jupyter_output><empty_output><jupyter_text>Training of the SVC algorithm with original scikit-learn library for Adult dataset<jupyter_code>start = time()
from sklearn.svm import SVC
classifier = SVC(**params).fit(x_train, y_train)
f"Original Scikit-learn time: {(time() - start):.2f} s"<jupyter_output><empty_output><jupyter_text>Predict and get a result of the SVC algorithm with original Scikit-learn<jupyter_code>predicted = classifier.predict(x_test)
report = metrics.classification_report(y_test, predicted)
print(f"Classification report for SVC:\n{report}\n")<jupyter_output>Classification report for SVC:
              precision    recall  f1-score   support

        -1.0       0.87      0.90      0.88      7414
         1.0       0.64      0.58      0.61      2355

    accuracy                           0.82      9769
   macro avg       0.76      0.74      0.75      9769
weighted avg       0.82      0.82      0.82      9769
{'fraction_non_alphanumeric': 0.08556444935136627, 'fraction_numerical': 0.038642009384487995, 'mean_word_length': 3.670103092783505, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '159398', 'license': 'Apache-2.0', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1159, 'n_words': 324, 'path': 'examples/notebooks/svc_adult.ipynb', 'repo_name': 'napetrov/daal4py', 'size': '3623'}