<jupyter_start><jupyter_text>AS PURCHASED COLUMN IS ALREADY ENCODED WE DONT HAVE TO USE ENCODER AND IT IS OUR DEPENEDENT VARIABLE .<jupyter_code>X=df[['Age','EstimatedSalary']]
y=df['Purchased']
print(X.head())
print(y.head())<jupyter_output>Age  EstimatedSalary
0   19            19000
1   35            20000
2   26            43000
3   27            57000
4   19            76000
0    0
1    0
2    0
3    0
4    0
Name: Purchased, dtype: int64<jupyter_text>NOW SPLIT THE DATASET INTO TRAINING SET AND TEST SET<jupyter_code>from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.3,random_state=23)
print(X_train.head())
print(X_test.head())
print(y_train.head())
print(y_test.head())<jupyter_output>Age  EstimatedSalary
64    59            83000
16    47            25000
77    22            27000
272   60            42000
10    26            80000
     Age  EstimatedSalary
133   21            68000
331   48           119000
167   35            71000
335   36            54000
239   53           143000
64     0
16     1
77     0
272    1
10     0
Name: Purchased, dtype: int64
133    0
331    1
167    0
335    0
239    1
Name: Purchased, dtype: int64<jupyter_text>NOW AS OUR INDEPENDENT VARIABLE MATRIX X IS NOT IN A SCALE .SO WE HAVE TO USE DATA SCALING<jupyter_code>from sklearn.preprocessing import StandardScaler
sc=StandardScaler()
X_train_sc=sc.fit_transform(X_train)
X_test_sc=sc.fit_transform(X_test)
X_train_sc,X_test_sc<jupyter_output>C:\Users\HP\Documents\New folder\lib\site-packages\sklearn\preprocessing\data.py:625: DataConversionWarning: Data with input dtype int64 were all converted to float64 by StandardScaler.
  return self.partial_fit(X, y)
C:\Users\HP\Documents\New folder\lib\site-packages\sklearn\base.py:462: DataConversionWarning: Data with input dtype int64 were all converted to float64 by StandardScaler.
  return self.fit(X, **fit_params).transform(X)
C:\Users\HP\Documents\New folder\lib\site-packages\sklearn\preprocessing\data.py:625: DataConversionWarning: Data with input dtype int64 were all converted to float64 by StandardScaler.
  return self.partial_fit(X, y)
C:\Users\HP\Documents\New folder\lib\site-packages\sklearn\base.py:462: DataConversionWarning: Data with input dtype int64 were all converted to float64 by StandardScaler.
  return self.fit(X, **fit_params).transform(X)<jupyter_text>IMPORT THE LIBRARIES<jupyter_code>from sklearn.svm import SVC
svc=SVC(kernel='rbf',random_state=23)
svc.fit(X_train_sc,y_train)<jupyter_output><empty_output><jupyter_text>SCORE OF THE ALGORITHM<jupyter_code>score=100.0* svc.score(X_test_sc,y_test)
print(score)
#you can check by using differrent Kernels(linear and rbf(radial basis function))
#using linear kernel will give accuracy 84.1666 and using rbf kernel will give 90.8333.
#By default it is rbf<jupyter_output>90.83333333333333<jupyter_text>CLASSIFICATION REPORT<jupyter_code>from sklearn.metrics import classification_report
labels=['Low','High']
result=svc.predict(X_test_sc)
print(classification_report(y_test,result))<jupyter_output>precision    recall  f1-score   support

           0       0.96      0.90      0.93        79
           1       0.83      0.93      0.87        41

   micro avg       0.91      0.91      0.91       120
   macro avg       0.89      0.91      0.90       120
weighted avg       0.91      0.91      0.91       120<jupyter_text>PERFORMANCE METRICS<jupyter_code>from sklearn.metrics import mean_absolute_error
from sklearn.metrics import mean_squared_error
from sklearn.metrics import r2_score

mae=mean_absolute_error(y_test,result)
mse=mean_squared_error(y_test,result)
r2=r2_score(y_test,result)
print(mae)
print(mse)
print(r2)<jupyter_output>0.09166666666666666
0.09166666666666666
0.5924668107440567
{'fraction_non_alphanumeric': 0.0808320168509742, 'fraction_numerical': 0.09847288046340179, 'mean_word_length': 3.5551558752997603, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 3, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '395699', 'license': 'MIT', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1361, 'n_words': 326, 'path': 'SVM/Untitled.ipynb', 'repo_name': 'nit-ap/Machine-Learning-in-Python', 'size': '3798'}