[pycon] Jupyter Notebook
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- numerical = df.drop(columns=["Load_Type"]).select_dtypes('number').columns.tolist()
- passthrough_features = df.drop(columns=["Load_Type"]).select_dtypes('object').columns.tolist()
- preprocessor = make_column_transformer(
- (make_pipeline(StandardScaler()),numerical,),
- ("passthrough", passthrough_features),)
- models = []
- names = [
- "logistic regression",
- "KNN",
- "Linear SVC / SVM Linear",
- "SVM RBF",
- "Decision Tree",
- "Naive Bayes",
- "Random forest",
- "AdaBoost",
- "XGBoost",
- "CatBoost",
- ]
- scores = []
- clf = [
- LogisticRegression(),
- KNeighborsClassifier(3),
- SVC(kernel="linear", C=1),
- SVC(kernel="rbf", gamma=1, C=1),
- DecisionTreeClassifier(max_depth=5),
- GaussianNB(),
- RandomForestClassifier(n_estimators=200, max_leaf_nodes=16),
- AdaBoostClassifier(DecisionTreeClassifier(max_depth=3)),
- XGBClassifier(),
- CatBoostClassifier(loss_function='MultiClass', eval_metric='Accuracy')
- ]
- for model in clf:
- pipe = make_pipeline(preprocessor, model)
- pipe.fit(X_train, y_train)
- print(model)
- score = pipe.score(X_test, y_test)
- scores.append(score)
- print("Model score: %.3f" %score)
- print("\n-------------------------\n")
- scores_df = pd.DataFrame(zip(names,scores), columns=['Classifier', 'Accuracy'])
Editor
You can edit this paste and save as new:
File Description
- Jupyter Notebook
- Paste Code
- 02 Dec-2022
- 1.33 Kb
You can Share it:
Latest Code Pastes