Home > Blockchain >  I am new to ML and I dont know how to solve this problem,Can some one help me?
I am new to ML and I dont know how to solve this problem,Can some one help me?

Time:03-07

Download the dataset, where the first four columns are features, and the last column corresponds to categories (3 labels). Perform the following tasks.

  1. Split the dataset into train and test sets (80:20)
  2. Construct the Naive Bayes classifier from scratch and train it on the train set. Assume Gaussian distribution to compute probabilities.
  3. Evaluate the performance using the following metric on the test set a. Confusion matrix b. Overall and class-wise accuracy c. ROC curve, AUC
  4. Use any library (e.g. scikit-learn) and repeat 1 to 3
  5. Compare and comment on the performance of the results of the classifier in 2 and 4 6. Calculate the Bayes risk. Consider, λ = 2 1 6 4 2 4 6 3 1 Where λ is a loss function and rows and columns corresponds to classes (ci) and actions (aj) respectively, e.g. λ(a3 / c2) = 4

CodePudding user response:

It's not clear what specific part of the problem you're having trouble with, which makes it hard to give specific advice.

With that in mind, here is some reading that might help get you started:

Hope this is enough to get you started.

CodePudding user response:

  1. from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(label,targets, test_size=0.20,random_state=42)

  2. example of gaussian naive bayes

    from sklearn.naive_bayes import GaussianNB

    define the model

    model = GaussianNB()

    fit the model

    model.fit(X_train,y_train)

  3. predict=model.predict(x_test) matrix = classification_report(y_test,predict) print('Classification report :\n',matrix)

  4. https://scikit-learn.org/stable/modules/cross_validation.html

  • Related