Answer to Question #309014 in Python for Akash

Question #309014

You work in XYZ Company as a Python. The company officials want you to write code for reducing the dimensions of a dataset

Tasks to be performed: -

- Using load_digits function from sklearn import wines data

- Take a look at the shape of image data

- Import PCA, LDA and FactorAnalysis from Sklearn

- Project data in 2 D space using the PCA, LDA and FactorAnalysis algorithm form sklearn

- Take a look at the new data


1
Expert's answer
2022-03-10T07:16:55-0500

from sklearn import datasetsdigits = datasets.load_digits()Xtrain, Xtest, ytrain, ytest = train_test_split(digits.data, digits.target)

# Apply logistic regression and print scoreslr = LogisticRegression()lr.fit(Xtrain, ytrain)print(lr.score(Xtrain, ytrain))print(lr.score(Xtest, ytest))

# Apply SVM and print scoressvm = SVC()svm.fit(Xtrain, ytrain)print(svm.score(Xtrain, ytrain))print(svm.score(Xtest, ytest))


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS