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 :: how to install python pyautogui 
Python :: python split string into floats 
Python :: url encoded path using python 
Python :: python request coinmarketcap 
Python :: pi in python 
Python :: tkinter button relief options 
Python :: python run batch file 
Python :: import tsv as dataframe python 
Python :: python rock paper scissors 
Python :: ERROR: Command errored out with exit status 1 
Python :: nice python turtle code 
Python :: urllib download file to folder 
Python :: merge two columns pandas 
Python :: python to float 
Python :: python random walk 
Python :: 405 status code django 
Python :: depth first search python 
Python :: multiprocessing join python 
Python :: sns how to change color if negative or positive 
Python :: - inf in python 
Python :: local ip 
Python :: max int python 
Python :: generate binary number in python 
Python :: python reading csv files from web 
Python :: pandas if else 
Python :: python try and except 
Python :: download image from url python requests 
Python :: modify a list with for loop and range function in python 
Python :: change forms labels django 
Python :: remove part of string python 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =