Guest User

Experiment No. 5

a guest
Mar 25th, 2025
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #Implement the program to avoid dataleakage with name data preparation select an appropriate dataset for your expeeriment and validate the results
  2.  
  3. from sklearn.datasets import make_classification
  4. from sklearn.model_selection import train_test_split
  5. from sklearn.preprocessing import MinMaxScaler
  6. from sklearn.linear_model import LogisticRegression
  7. from sklearn.metrics import accuracy_score
  8.  
  9. x,y = make_classification(n_samples=1000,n_features=20,n_informative=15,n_redundant=5,random_state=7)
  10. scaler = MinMaxScaler()
  11. x = scaler.fit_transform(x)
  12. x_train, x_test, y_train, y_test = train_test_split(x,y, test_size=0.33, random_state = 1)
  13. model=LogisticRegression()
  14. model.fit(x_train, y_train)
  15. yhat=model.predict(x_test)
  16. accuracy = accuracy_score(y_test, yhat)
  17. print("Accuracy: %.3f"%(accuracy*100))
Advertisement
Add Comment
Please, Sign In to add comment