Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Implement the program to avoid dataleakage with name data preparation select an appropriate dataset for your expeeriment and validate the results
- from sklearn.datasets import make_classification
- from sklearn.model_selection import train_test_split
- from sklearn.preprocessing import MinMaxScaler
- from sklearn.linear_model import LogisticRegression
- from sklearn.metrics import accuracy_score
- x,y = make_classification(n_samples=1000,n_features=20,n_informative=15,n_redundant=5,random_state=7)
- scaler = MinMaxScaler()
- x = scaler.fit_transform(x)
- x_train, x_test, y_train, y_test = train_test_split(x,y, test_size=0.33, random_state = 1)
- model=LogisticRegression()
- model.fit(x_train, y_train)
- yhat=model.predict(x_test)
- accuracy = accuracy_score(y_test, yhat)
- print("Accuracy: %.3f"%(accuracy*100))
Advertisement
Add Comment
Please, Sign In to add comment