Created
May 3, 2026 13:30
-
-
Save jaiswalakshay508-maker/bb37c8f7bbe433e79240e1eb312a74eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import seaborn as sns | |
| import matplotlib.pyplot as plt | |
| from pyexpat import model | |
| from sklearn.model_selection import train_test_split | |
| from sklearn.neighbors import KNeighborsClassifier | |
| from sklearn.metrics import accuracy_score | |
| import joblib | |
| from Multiple_Regerision import X_train, X_test, y_train, y_test, y_predict | |
| df=pd.read_csv(r"C:\Users\hp\PycharmProjects\PythonProject5\Iris.csv") | |
| print(df) | |
| #sns.countplot(data=df,x="SepalLengthCm",hue="Species") | |
| #plt.show() | |
| #sns.countplot(data=df,x="SepalWidthCm",hue="Species") | |
| #plt.show() | |
| #sns.countplot(data=df,x="PetalLengthCm",hue="Species") | |
| #plt.show() | |
| #sns.countplot(data=df,x="PetalWidthCm",hue="Species") | |
| #plt.show() | |
| X=df.drop(["Species"],axis=1) | |
| y=df["Species"] | |
| X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1) | |
| joblib.dump(model,"K Nearest Neighbour.py.pkl") | |
| model = KNeighborsClassifier(n_neighbors=4) | |
| model.fit(X_train,y_train) | |
| y_predict= model.predict(X_test) | |
| acc=accuracy_score(y_test,y_predict) | |
| print(acc) | |
| print(model.predict([[5.2,3.6,1.5,0.3]])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment