Question

Use Support Vector Machines to solve a text-mining problem of your choice. - Define your text...

Use Support Vector Machines to solve a text-mining problem of your choice.

  • - Define your text mining dataset and problem

  • - Run SVM in Python, R or Weka to gain knowledge from the dataset

  • - Generate results, screenshots of any interesting observations along the way

  • - Discuss the results

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#This peice of code is to solve a classification problem on a well known iris dataset using SVM in python
#This iris dataset comes with python package 'sklearn'
#in this data set we have 5 variables in total
# four predictors or independent variables(sepal_length, sepal_width', 'petal_length', 'petal_width') which
#are continuous in nature and will help us classify the species(the target variable)
# species variables takes three possible values as setosa, versicolor and virginica
# Our goal is run SVM classifier to predict species on test data
# we split the whole dataset into training and testing datasets into 80:20 ratio
# Run SVM on training data and run the classifier on test data


#importing python packages used for ML
import numpy as np
import pandas as pd
from sklearn import svm
from sklearn import datasets

#loading iris datase
#Iris dataset has four predictors as sepal_length, sepal_width', 'petal_length', 'petal_width' and target variable 'species'
iris = datasets.load_iris()

# fetching predictors and target variables out dataset
# y has three possible values 0,1 and 2 where
# 0 --> setosa
# 1 --> versicolor
# 2 --> virginica

X, y = iris.data, iris.target


#splitting data into training and test set
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.20)

#defining SVM classifier
clf = svm.SVC(gamma='scale')

#fitting model to the training data
clf.fit(X_train, y_train)

#Now making prections on testing dataset using model we have achieved

y_pred = clf.predict(X_test)
print(y_pred)

#evaluating model performance
from sklearn.metrics import accuracy_score
accuracy = accuracy_score(y_test, y_pred)

print(accuracy)

#As we can see model performa well as its accuracy is 94%, which is very good.

Add a comment
Know the answer?
Add Answer to:
Use Support Vector Machines to solve a text-mining problem of your choice. - Define your text...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Read the following problem. Use your knowledge about the Inclusion-Exclusion Principle to support your criteria. Telephone...

    Read the following problem. Use your knowledge about the Inclusion-Exclusion Principle to support your criteria. Telephone numbering is an application of the inclusion-exclusion principle. Discuss with your peers a way in which the current telephone numbering plan can be extended to accommodate the rapid demand for more telephone numbers. (See if you can find some of the proposals coming from the telecommunications industry). For each new numbering plan you discuss show how to find the number of different telephone numbers...

  • Read the following problem. Use your knowledge about the Inclusion-Exclusion Principle to support your criteria. Telephone numbering is an application of the inclusion-exclusion principle. Discuss w...

    Read the following problem. Use your knowledge about the Inclusion-Exclusion Principle to support your criteria. Telephone numbering is an application of the inclusion-exclusion principle. Discuss with your peers a way in which the current telephone numbering plan can be extended to accommodate the rapid demand for more telephone numbers. (See if you can find some of the proposals coming from the telecommunications industry). For each new numbering plan, you discuss show how to find the number of different telephone numbers...

  • Solve the following problem using your choice of a software program The steps to solve the...

    Solve the following problem using your choice of a software program The steps to solve the problem should be clearly outlined (can be handwritten or typed) The software program code should be printed out along with the results of the solution. DUE DATE - 8/3/2020 A steam power plant operates on the Rankine cycle with reheat, using the specified conditions below. Using stream nunbering shown in Figure 1, for each of the options given, determine: (a) The work output of...

  • USING EXCEL TO THINK LIKE AN ENGINEER. Text book Please use excel to answer the question....

    USING EXCEL TO THINK LIKE AN ENGINEER. Text book Please use excel to answer the question. Please do not attempt if you are new to excel, an example has been provided. You guys have gotten my last 4 answers wrong. -Assume that your company has received an order for 100,000 assemblies each consisting of two subassemblies. The two subassemblies end-to-end to create an assembly that is to be 3,000 mm in length with a lower specification limit of 2,995 mm...

  • Major Homework #2 Implement a C program major_hw2.c to solve the 15-puzzle problem using the A*...

    Major Homework #2 Implement a C program major_hw2.c to solve the 15-puzzle problem using the A* search algorithm. 1. Objectives • To gain more experience on using pointers and linked lists in C programs. • To learn how to solve problems using state space search and A* search algorithm. 2. Background A* search and 15-puzzle problem have been introduced in the class. For more information, please read the wiki page of 15-puzzle problem at https://en.wikipedia.org/wiki/15_puzzle, and the wiki page of...

  • Major Homework #2 Implement a C program major_hw2.c to solve the 15-puzzle problem using the A* s...

    Major Homework #2 Implement a C program major_hw2.c to solve the 15-puzzle problem using the A* search algorithm. Please include pictures that the code runs and shows the different states as it reaches goal state please. 1. Objectives • To gain more experience on using pointers and linked lists in C programs. • To learn how to solve problems using state space search and A* search algorithm. 2. Background A* search and 15-puzzle problem have been introduced in the class....

  • In the original flashcard problem, a user can ask the program to show an entry picked...

    In the original flashcard problem, a user can ask the program to show an entry picked randomly from a glossary. When the user presses return, the program shows the definition corresponding to that entry. The user is then given the option of seeing another entry or quitting. A sample session might run as follows: Enter s to show a flashcard and q to quit: s Define: word1 Press return to see the definition definition1 Enter s to show a flashcard...

  • STEP 1: In your own words define problem employees and the categories they may fall into....

    STEP 1: In your own words define problem employees and the categories they may fall into. For the second or last paragraph provide your opinion on which employee type is the most difficult. DEFINITION : I think that "problem employees" are employees that either directly or indirectly hinder the organization's mission or vision, and break down into roughly four categories. In general, problem employees can be classified into two broad categories - employees creating problems for the organization and employees...

  • Recursion and Trees Application – Building a Word Index Make sure you have read and understood...

    Recursion and Trees Application – Building a Word Index Make sure you have read and understood ·         lesson modules week 10 and 11 ·         chapters 9 and 10 of our text ·         module - Lab Homework Requirements before submitting this assignment. Hand in only one program, please. Background: In many applications, the composition of a collection of data items changes over time. Not only are new data items added and existing ones removed, but data items may be duplicated. A list data structure...

  • A new version of the operating system is being planned for installation into your department’s production...

    A new version of the operating system is being planned for installation into your department’s production environment. What sort of testing would you recommend is done before your department goes live with the new version? Identify each type of testing and describe what is tested. Explain the rationale for performing each type of testing. [ your answer goes here ] Would the amount of testing and types of testing to be done be different if you were installing a security...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT