Question

In: Computer Science

-In google Colab from sklearn.datasets import load_breast_cancer allData = load_breast_cancer() X = allData['data'] y = allData['target']...

-In google Colab

from sklearn.datasets import load_breast_cancer
allData = load_breast_cancer()
X = allData['data']
y = allData['target']

-# How many features or attributes does this machine learning problem have? Hint use allData['DESCR'] to determine that.

- #Compute the shape or the dimensions of x,  and Compute the shape or the dimensions of y?

- Import a classifier, create an instance of the classifier and fit or train he classifier using the training data.

- #compute the number of true positives, true negatives, false negatives and false negative rate

Solutions

Expert Solution

  • allData has now all the breast_cancer data using
    • allData=load_breast_cancer()
  • X=allData['data'] loads the data of features into X
  • Y=allData['target'] loads the target values or class labels into y (Ex- Cancer Exists or Cancer Do not Exists)
  • X contains say 'i' different data examples in rows and 'j' features for each data example in columns. So, the matrix or data vector size is 'ixj'.
  • Y contains 'i' rows and only one column as target values.

-If the above are taken into consideration, then the given machine learning problem as got 'j' features.

- The shape or dimensions of X can be calculated as X.shape. The shape or dimensions of y can be calculated as y.shape.

The following statements can be used to print-

  • print ("X shape: " + str(X.shape))
  • print ("y shape: " + str(y.shape))

-  Import the classifier using 'from sklearn.ensemble import RandomForestClassifier' (Ex- RandomForest is cosen as classifier)

clf = RandomForestClassifier(n_estimators=1000) //Classifier is defined and instance is created

clf.fit(X, y) // Classifier is fitted

- Confusion Matrix gives true positives, true negatives, false negatives and false negative rates-

Confusion Matrix is printed using the following snippet code-

Note-

  • 1 indicates Cancer Exists.
  • 0 indicates Cancer Do not Exits.
  • The Above Snippet assumed that there are only 10 Data Examples. You can extend the same to your required size of data examples.

Related Solutions

For the following data, find the regression equation for predicting Y from X X Y 1...
For the following data, find the regression equation for predicting Y from X X Y 1 2 4 7 3 5 2 1 5 8 3 7 1a. Group of answer choices a. Ŷ = -2X + 8 b. Ŷ =2X + 8 c. Ŷ =1.8X - 0.4 d. Ŷ =1.8X + 0.4 1b. For the following scores, find the regression equation for predicting Y from X X Y 3 8 6 4 3 5 3 5 5 3
For the X,Y data below, compute:
For the X,Y data below, compute: X Y 2 5 4 6 4 7 5 11 6 12 (a) the correlation coefficient and determine if it is significantly different from zero. (b) find the regression line. c) interpret the coefficient of the regression line d) at 5% test if the Y is related to X e) find the coefficient of determination and interpret this coefficient. f) predict the value of average Y if the average of X is13 g) at...
PLEASE USE PYTHON CODE Compute the zero of the function y(x) from the following data: x...
PLEASE USE PYTHON CODE Compute the zero of the function y(x) from the following data: x = 0.2, 0.4, 0.6, 0.8, 1.0 y = 1.150, 0.855, 0.377, -0.266, -1.049 Use inverse interpolation with the natural cubic spline
what is the following (ARDUINO): -Libraries are code that allow -Lcd. setCursor (x,y) -Where to Import...
what is the following (ARDUINO): -Libraries are code that allow -Lcd. setCursor (x,y) -Where to Import a library into a given code -Digital pins can be used to
Use the following data to develop a quadratic model to predict y from x. Develop a...
Use the following data to develop a quadratic model to predict y from x. Develop a simple regression model from the data and compare the results of the two models. Does the quadratic model seem to provide any better predictability? Why or why not? x y x y 15 229 15 247 9 74 8 82 6 29 5 21 21 456 10 94 17 320
1) Generate a data set with three variables (X, Y and Z). X and Y have...
1) Generate a data set with three variables (X, Y and Z). X and Y have 10 observations for each (N=10), and Z has 13 observations (N=13). Each observation should have two digits (such as “83” or “8.3”). 2) Draw a stem-and-leaf display for variable Z only and draw a box plot display for variable Z after specifying the 5 numbers (UEX, LEX, FU, FL, MD). 3) Calculate the mean and standard deviation for variable X 4) Calculate the mean...
(a) Suppose you are given the following x, y data pairs x 1 3 6 y...
(a) Suppose you are given the following x, y data pairs x 1 3 6 y 5 5 8 Find the least-squares equation for these data. (Use 3 decimal places.) y hat = + x (b) Now suppose you are given these x, y data pairs. x 5 5 8 y 1 3 6 Find the least-squares equation for these data. (Use 3 decimal places.) y hat = + x (c) In the data for parts (a) and (b), did...
Suppose we have the following data on variable X (independent) and variable Y (dependent): X Y...
Suppose we have the following data on variable X (independent) and variable Y (dependent): X Y 2 70 0 70 4 130 a.) By hand, determine the simple regression equation relating Y and X. b.) Calculate the R-Square measure and interpret the result. c.) Calculate the adjusted R-Square. d.) Test to see whether X and Y are significantly related using a test on the population correlation. Test this at the 0.05 level. e.) Test to see whether X and Y...
Suppose we have the following data on variable X (independent) and variable Y (dependent): X         Y...
Suppose we have the following data on variable X (independent) and variable Y (dependent): X         Y 2          70 0          70 4          130 Test to see whether X and Y are significantly related using a t-test on the slope of X. Test this at the 0.05 level. Test to see whether X and Y are significantly related using an F-test on the slope of X. Test this at the 0.05 level.
Suppose we have the following data on variable X (independent) and variable Y (dependent): X Y...
Suppose we have the following data on variable X (independent) and variable Y (dependent): X Y 2 70 0 70 4 130 a.) By hand, determine the simple regression equation relating Y and X. b.) Calculate the R-Square measure and interpret the result. c.) Calculate the adjusted R-Square. d.) Test to see whether X and Y are significantly related using a test on the population correlation. Test this at the 0.05 level. e.) Test to see whether X and Y...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT