Scikit Learn Machine Learning SVM Tutorial with Python p. 2 - Example

sentdex · 344K views · 2014 · 23:47

Open on YouTube

Machine learning & deep learningData science & statisticstutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as the source tutorial they were following when their digits/SVM code threw errors, and answerers cite it as the origin of the example code.

Recommended by 0 people across 0 different months, 2016 to 2020.

What it is

Part 2 of sentdex's scikit-learn tutorial series walks through a small image recognition example in Python, training an SVM classifier on the built-in handwritten digits dataset. The presenter stresses that the modelling step is easy and that gathering, labeling and scaling data is the hard part.

What people said

Cites Arun · 2016-01 · Stack Overflow · on “Why did I get an error at 'print(digits.images(0))' with the Wakari 'digits' dataset”

context I want to follow this [this video] tutorial on machine learning in Python using Wakari. At 7.07 minutes into the video I received a error: error text TypeError Traceback (most recent call last) <ipython-input-9-1322bba20f1e> in <module>() 10 print(digits.target) 11 ---> 12 print(digits.images(0)) TypeError: 'numpy.ndarray' object is not callable code/error screenshot [LINK] questions Why did I get the error? How do I get around it? Thanks

Cites Arun · 2016-01 · Stack Overflow · on “support vector machine for the image recognition with the scikit-py digit data set”

context I want to follow this [this video] tutorial on machine learning in Python using Wakari. At 12 minutes into the video I received an error: code import matplotlib.pyplot as plt from sklearn import datasets from sklearn import svm digits = datasets.load_digits() clf=svm.SVC(gamma-0.001, c-100) print(len(digits.data)) x, y = digits.data[:1], digits.target[:-1] clf.fit(x,y) print('Prediction:',clf.predict(digits.data[-1])) plt.imshow(digits.images[-1], cmap=plt.cm.gray_r, interpolation="nearest") plt.show() error text TypeError Traceback (most recent call last) <ipython-input-1-8cd67aede6c5> in <module>() 6 7 digits = datasets.load_digits() ----> 8 clf=svm.SVC(gamma-0.001, c-100) 9 10 print(le

Cites user2056487 · 2017-11 · Stack Overflow · on “Using SVM to predict text with label”

I have data in a csv file in the following format Name Power Money Jon Red 30 George blue 20 Tom Red 40 Bob purple 10 I consider values like "jon", "red" and "30 as inputs. Each input as a label. For instance inputs [jon,george,tom,bob] have label "name". Inputs [red,blue,purple] have label "power". This is basically how I have training data. I have bunch of values that are each mapped to a label. Now I want to use svm to train a model based on my training data to accurately identify given a new input what is its correct label. so for instance if the input provided is "444" , the model should be smart enough to categorize it as a "Money" label. I have installed py and also installed sklearn

Cites Rakibul Hassan · 2018-04 · Stack Overflow · on “Predicting numbers using sklearn digits dataset - error”

Thank you so much for the answers. All of you have responded to the point. Now, I understood the error. I actually took the example from [this video] and [LINK] It was mostly the python version, in previous version of python predict function accepts 1D array but now it is deprecated so by surrounding the 1D array with braces like [1D array] will make it a 2D array. Now the following code is working perfectly. import matplotlib.pyplot as plt from sklearn import datasets from sklearn import tree digits = datasets.load_digits() clf = tree.DecisionTreeClassifier() clf = clf.fit(digits.data[:-1], digits.target[:-1]) clf.predict(digits.data[[-1]]) The output is array([8]). Thank you once again for the

Cites stik · 2020-05 · Stack Overflow · on “TypeError: unsupported operand type(s) for -: 'module' and 'LinearSegmentedColormap'”

import matplotlib.pyplot as plt import matplotlib as cmap from sklearn import datasets from sklearn import svm digits = datasets.load_digits() clf = svm.SVC(gamma=0.001, C=100) print(len(digits.data)) x, y = digits.data[:-1], digits.target[:-1] clf.fit(x,y) print('Prediction:', clf.predict(digits.data[[-1]])) plt.imshow(digits.images[-1], cmap-plt.cm.gray_r, interpolation-"nearest") plt.show() when running this code in python 3.8.3, I get this error message: Traceback (most recent call last): File "C:\Users\Aben\Downloads\pythonstuff\machinelearning.py", line 18, in <module> plt.imshow(digits.images[-1], cmap-plt.cm.gray_r, interpolation-"nearest") TypeError: unsupported operand type(s) for

Cites stik · 2020-05 · Stack Overflow · on “AttributeError: type object 'DataFrame' has no attribute 'pd'”

import pandas as pd import os import time from datetime import datetime path = "C:/Users/Aben/Downloads/intraQuarter" def Key_Stats(gather="Total Debt/Equity (mrq)"): statspath = path+'/_KeyStats' stock_list = [x[0] for x in os.walk(statspath)] df = pd.DataFrame(columns = ['Date','Unix','Ticker','DE Ratio']) sp500_df = pd.DataFrame.pd.read_csv("YAHOO-INDEX_CSPC.csv") for each_dir in stock_list[1:]: each_file = os.listdir(each_dir) ticker = each_dir.split("\\")[1] if len(each_file) > 0: for file in each_file: date_stamp = datetime.strptime(file, '%Y%m%d%H%M%S.html') unix_time = time.mktime(date_stamp.timetuple()) full_file_path = each_dir+'/'+file source = open(full_file_path,'r').read() try: