machine learning projects in python

Solutions on MaxInterview for machine learning projects in python by the best coders in the world

showing results for - "machine learning projects in python"
Vanessa
15 Feb 2020
1from sklearn.datasets import load_wine
2from sklearn.naive_bayes import GaussianNB
3from sklearn.svm import SVC
4from sklearn.ensemble import StackingClassifier, RandomForestClassifier
5from sklearn.model_selection import StratifiedShuffleSplit
6random_state = 42
7
8X,y = load_wine(return_X_y = True)
9mean, std = X.mean(axis = 0), X.std(axis = 0)
10X = (X - mean)/std
11def make_models():
12  models = []
13  models.append(('rfc', RandomForestClassifier(random_state = random_state, n_estimators = 20)))
14  models.append(('svm', SVC(C = 0.01)))
15  models.append(('gnb', GaussianNB()))
16  return models
17
18models = make_models()
19clf = StackingClassifier(estimators = models, final_estimator = RandomForestClassifier(random_state = random_state),)
20
21scores = []
22i = 0
23for indices in kfold.split(X, y):
24  train_indices, test_indices = indices
25  X_train, X_test = X[train_indices], X[test_indices] # Task 2 split the data set with StratifiedKFold
26  y_train, y_test = y[train_indices], y[test_indices]
27  clf.fit(X_train, y_train)
28  curr_score = clf.score(X_test, y_test)
29  i+=1
30  print(f'{i}- Fold #{i} accuracy = ', str(round(curr_score,4)*100) + '%') # Task 4 dispaly the score
31  scores.append(curr_score)
32print(10*'--')
33print('The mean of  scores is: ', str(round(sum(scores)/k,4)*100) + '%') #Task 4 display the mean of scors
34
35#for more projects:
36#https://github.com/MohammedAlbaqerH
37
queries leading to this page
simple machine learning projects pythonsmall python machine learning projectssimple machine learning projects using pythonml projects in pythonmachine learning projects pythonmachine learning python projects with source codepython and ml projectsmachine learning python projects for beginnersbegginner machine learning python projectsmachine learning python projectsbasic machine learning projects in pythonmachine learning using python projectspython machine learning projects with source codemachine learning projects with pythonbeginner machine learning projects pythonmachine learning based python projectmachine learning projects in python with source codepython projects machine learningmachine learning projects for beginners in pythonml projects pythonmachine learning real world projects in pythonmachine learning using python projectmachine learning projects for python open sourceprojects in python in machine learningython machine learning projectspython projects with mlmachine learning with python projectsrealtime machine learning python projectsmachine learning related projects in pythonmachine learning mini projects ideas using pythonpython machine learning projects for beginnersideas for python ml projectspython ml projects with source codepython projects for machine learning10 machine learning begginer projects pythonpython machine learning projectswhat are best ml projects pythonmachine learning projects for beginners with source code in pythonlearn machine learning python with projectstop 10 machine learning projects for beginners in pythonsimple machine learning projects for beginners in pythonmachine learning projects to make in pythonmachine learning projects in pythonmachine lerning projects on pythonpython projects with ml with source codemachine learning projects in python