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
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))
Comments
Leave a comment