<jupyter_start><jupyter_text>---<jupyter_code>from sklearn.svm import SVC
# help(SVM)
y = df['v']
X = df.drop('v',axis=1)
model = SVC(kernel='linear',C=1000)
model.fit(X,y)
from svm_margin_plot import plot_svm_boundary
plot_svm_boundary(model,X,y)
model = SVC(kernel='linear',C=.05)
model.fit(X,y)
plot_svm_boundary(model,X,y)
model = SVC(kernel='linear',C=.005)
model.fit(X,y)
plot_svm_boundary(model,X,y)
model = SVC(kernel='rbf',C=1)
model.fit(X,y)
plot_svm_boundary(model,X,y)

# the kernel is going to be projected to a higher dimensional space -> when we ploting back down it's no longer going to look linear
model = SVC(kernel='rbf',C=.1)
model.fit(X,y)
plot_svm_boundary(model,X,y)

# the kernel is going to be projected to a higher dimensional space -> when we ploting back down it's no longer going to look linear
model = SVC(kernel='rbf',C=1,gamma='auto')
model.fit(X,y)
plot_svm_boundary(model,X,y)

# as gamma get larger we are assigning more weight 
model = SVC(kernel='rbf',C=1,gamma='auto')
model.fit(X,y)
plot_svm_boundary(model,X,y)

# gamma defines how much influence a single training example has -> has gamma grows, the closer the other examples have to be in order to be affected 
model = SVC(kernel='rbf',C=1,gamma=10)
model.fit(X,y)
plot_svm_boundary(model,X,y)

# gamma defines how much influence a single training example has -> has gamma grows, the closer the other examples have to be in order to be affected -> we start overfitting
model = SVC(kernel='sigmoid')
model.fit(X,y)
plot_svm_boundary(model,X,y)
model = SVC(kernel='poly',degree=1)
model.fit(X,y)
plot_svm_boundary(model,X,y)
model = SVC(kernel='poly',degree=2)
model.fit(X,y)
plot_svm_boundary(model,X,y)
from sklearn.model_selection import GridSearchCV
svm = SVC()
p_grid = {'C':[.01,.1,1],'kernel':['linear','rbf']}
grid = GridSearchCV(svm, p_grid)
grid.fit(X,y)
grid.best_params_<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14300736067297581, 'fraction_numerical': 0.012092534174553101, 'mean_word_length': 6.7673469387755105, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '318886', 'license': 'MIT', 'n_tokens_mistral': 758, 'n_tokens_neox': 725, 'n_words': 182, 'path': 'prep-9-svm/svm1-classification.ipynb', 'repo_name': 'luiul/statistics-meets-logistics', 'size': '1902'}