Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

learn python machine learning

This is the best website to learn python machine (https://www.w3schools.com/python/python_ml_getting_started.asp)
Comment

machine learning python

import pandas as pd
from sklearn.tree import DecisionTreeClassifier

hashdata = pd.read_csv("filename.csv")
X = hashdata.drop(columns=["output_column_name"])
y = hashdata.drop(columns=["input_column_name"])
model=DecisionTreeClassifier()
model.fit(X,y)
predictions=model.predict([[input]])
print(predictions)
Comment

machine learning python

thank you random grepper answer
Comment

python machine learning

# Create Decision Tree classifer object
clf = DecisionTreeClassifier(criterion="entropy", max_depth=3)

# Train Decision Tree Classifer
clf = clf.fit(X_train,y_train)

#Predict the response for test dataset
y_pred = clf.predict(X_test)

# Model Accuracy, how often is the classifier correct?
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
Comment

Python machine learning

from sklearn.datasets import load_wine
from sklearn.naive_bayes import GaussianNB
from sklearn.svm import SVC
from sklearn.ensemble import StackingClassifier, RandomForestClassifier
from sklearn.model_selection import StratifiedShuffleSplit
random_state = 42

X,y = load_wine(return_X_y = True)
mean, std = X.mean(axis = 0), X.std(axis = 0)
X = (X - mean)/std
def make_models():
  models = []
  models.append(('rfc', RandomForestClassifier(random_state = random_state, n_estimators = 20)))
  models.append(('svm', SVC(C = 0.01)))
  models.append(('gnb', GaussianNB()))
  return models

models = make_models()
clf = StackingClassifier(estimators = models, final_estimator = RandomForestClassifier(random_state = random_state),)

scores = []
i = 0
for indices in kfold.split(X, y):
  train_indices, test_indices = indices
  X_train, X_test = X[train_indices], X[test_indices] # Task 2 split the data set with StratifiedKFold
  y_train, y_test = y[train_indices], y[test_indices]
  clf.fit(X_train, y_train)
  curr_score = clf.score(X_test, y_test)
  i+=1
  print(f'{i}- Fold #{i} accuracy = ', str(round(curr_score,4)*100) + '%') # Task 4 dispaly the score
  scores.append(curr_score)
print(10*'--')
print('The mean of  scores is: ', str(round(sum(scores)/k,4)*100) + '%') #Task 4 display the mean of scors

#for more projects:
#https://github.com/MohammedAlbaqerH 


Error:

PS C:UsersMAHA.2> python -u "c:UsersMAHA.2DesktopNew foldermachine learning.py"
Traceback (most recent call last):
  File "c:UsersMAHA.2DesktopNew foldermachine learning.py", line 23, in <module>
    for indices in kfold.split(X, y):
NameError: name 'kfold' is not defined
PS C:UsersMAHA.2> 
(Pls tell me how to fix)
Comment

PREVIOUS NEXT
Code Example
Python :: python time 
Python :: request post python with api key integration 
Python :: python how to check if a dictionary key exists 
Python :: groupby get last group 
Python :: Append a line to a text file using the write() function 
Python :: boolean in python 
Python :: head first python 
Python :: chatterbot python 
Python :: Python Create a nonlocal variable 
Python :: indentation in python 
Python :: convert excel to pdf python 
Python :: how to use information from env variables in python 
Python :: plot multiplr linear regression model python 
Python :: any function in python 
Python :: pandas fillna 
Python :: what is iteration in python 
Python :: current page django 
Python :: interpreter vs compiler 
Python :: dict to tuple 
Python :: PHP echo multiple lines example Using Nowdoc 
Python :: python save plot 
Python :: tkinter hide widget 
Python :: creating numpy array using empty 
Python :: list functions 
Python :: CVE-2018-10933 
Python :: tkinter how to update optionmenu contents 
Python :: selenium delete cookies python 
Python :: fast way to load mongodb data into python list 
Python :: feature importance plot using lasso regression 
Python :: define a string in python 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =