<jupyter_start><jupyter_text>simple visualizations  feature pair plot<jupyter_code>from matplotlib import cm
cmap=cm.get_cmap('gnuplot')
pd.plotting.scatter_matrix(X_train,c=y_train,marker='o',s=5,hist_kwds={'bins':5},figsize=(8,8),cmap=cmap)
plt.rcParams.update({'font.size':12,'figure.figsize':(5,5)})
finalUsers.plot(kind='scatter',y='flag_churn',x='DUREE_APPEL_out')
from mpl_toolkits.mplot3d import Axes3D
fig=plt.figure(figsize=(12,12))
ax=fig.add_subplot(111,projection='3d')
ax.scatter(X_train['DUREE_APPEL_TT_GSM_out'],X_train['DUREE_APPEL_out'],X_train['DUREE_APPEL_TT_FIXE_out'],c=y_train,marker='o',s=1)
plt.show()<jupyter_output><empty_output><jupyter_text>K nearest neighbors classification  create classifier object<jupyter_code>from sklearn.neighbors import KNeighborsClassifier
knn=KNeighborsClassifier(n_neighbors=10)<jupyter_output><empty_output><jupyter_text>train the classifier (fit the estimator) using training data<jupyter_code>knn.fit(X_train,y_train)<jupyter_output><empty_output><jupyter_text>estimate the accuracy of the classifier on future data, using the test data<jupyter_code>knn.score(X_test,y_test)<jupyter_output><empty_output><jupyter_text>use the trained k-NN classifier model to classify new, previously unseen objects<jupyter_code>user_pred=knn.predict([[239.0,0,0,0,10,7000,0,0,0,0]])
user_pred[0]<jupyter_output><empty_output><jupyter_text>modify the value of k to find the best accuracy<jupyter_code>scores=[]
for k in range(1,15):
    knn=KNeighborsClassifier(n_neighbors=k)
    knn.fit(X_train,y_train)
    scores.append(knn.score(X_test,y_test))

plt.figure()
plt.xlabel('k')
plt.ylabel('accuracy')
plt.scatter(range(1,15),scores)
plt.xticks([0,2,4,6,8,10,12,14])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1442528735632184, 'fraction_numerical': 0.03218390804597701, 'mean_word_length': 12.928, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '557307', 'license': 'Apache-2.0', 'n_tokens_mistral': 756, 'n_tokens_neox': 713, 'n_words': 83, 'path': 'churnClassification.ipynb', 'repo_name': 'salemChniguir/ChurnClassification', 'size': '1740'}