<jupyter_start><jupyter_text>Support Vector Regression (SVR)  Importing the libraries<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd<jupyter_output><empty_output><jupyter_text>Importing the dataset<jupyter_code>dataset = pd.read_csv('Position_Salaries.csv')
X = dataset.iloc[:, 1:-1].values
y = dataset.iloc[:, -1].values
y = y.reshape(len(y),1)<jupyter_output><empty_output><jupyter_text>Feature Scaling<jupyter_code>from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
sc_y = StandardScaler()
X = sc_X.fit_transform(X)
y = sc_y.fit_transform(y)<jupyter_output><empty_output><jupyter_text>Training the SVR model on the whole dataset<jupyter_code>from sklearn.svm import SVR
regressor = SVR(kernel='rbf')
regressor.fit(X, y)<jupyter_output>/Users/ethan/test/learn-machine-learning/venv/lib/python3.9/site-packages/sklearn/utils/validation.py:63: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
  return f(*args, **kwargs)<jupyter_text>Predicting a new result<jupyter_code>sc_y.inverse_transform(regressor.predict(sc_X.transform([[6.5]])))<jupyter_output><empty_output><jupyter_text>Visualising the SVR results<jupyter_code>plt.scatter(sc_X.inverse_transform(X), sc_y.inverse_transform(y), color='red')
plt.plot(sc_X.inverse_transform(X), sc_y.inverse_transform(regressor.predict(X)), color='blue')
plt.title('Truth or Bluff (SVR)')
plt.xlabel('Position level')
plt.ylabel('Salary')
plt.show()<jupyter_output><empty_output><jupyter_text>Visualising the SVR results (for higher resolution and smoother curve)<jupyter_code>X_grid = np.arange(min(sc_X.inverse_transform(X)), max(sc_X.inverse_transform(X)), 0.1)
X_grid = X_grid.reshape((len(X_grid), 1))
plt.scatter(sc_X.inverse_transform(X), sc_y.inverse_transform(y), color = 'red')
plt.plot(X_grid, sc_y.inverse_transform(regressor.predict(sc_X.transform(X_grid))), color = 'blue')
plt.title('Truth or Bluff (SVR)')
plt.xlabel('Position level')
plt.ylabel('Salary')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13867924528301886, 'fraction_numerical': 0.006603773584905661, 'mean_word_length': 8.911214953271028, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '475167', 'license': 'MIT', 'n_tokens_mistral': 821, 'n_tokens_neox': 783, 'n_words': 132, 'path': '02-Regression/04-Support-Vector-Regression/support_vector_regression.ipynb', 'repo_name': '0x00000024/learn-machine-learning', 'size': '2120'}