Python Forum
python machine learning model, macro precision score?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python machine learning model, macro precision score?
#1
Dear Python Pro's,
I am looking at python and machine learning.
One of the exercises is the following:

Using the fitted model m what is the macro precision score?
(Use y_test and X_test to compute the precision score.)

print(m)

SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,
  decision_function_shape=None, degree=3, gamma='auto', kernel='rbf',
  max_iter=-1, probability=False, random_state=None, shrinking=True,
  tol=0.001, verbose=False)
How do I approach this? What do I do with this fitted model since I dont have y_train and x_train.
Reply
#2
please post full context of assignment.
What model are you working with?
You were hopefully provided with package names, what are they?
Reply
#3
Are you in a regression or classifying task with that model?

I'm selftaught (and actually selfteaching currently) on ML and at that point myself as well.
If you have the fitted model m, you don't need y_train and x_train as their only use is to train the model (be it building the decision trees of a random forest, train the weights and biases of a neural network or whatever). your model is trained, and you now want to see if the trained model is able to generalize what it has fitted to.
I'm assuming X contains the inputs and Y contains the known outputs for a supervised learning program.

The idea now is to take x_test, use the model to make predictions, and compare with y_test how accurate your predictions were.

My pseudo code (i'm using a bunch of parallel random forests with each having a different representation of the input data) for this part looks like this:

x_test, y_test = generate_input_from_data(data)
precision, length = 0, len(x_test)
for i, x in enumerate(x_test):
    pred = model_predict(x)
    precision += math.fabs(float(pred)-y_test[i])/length
print int(100*precision), '%'
I am on a regression task, you'll have to find another way to express the precision of a single prediction, it should be much easier for you. You will likely have to write your equivalent for "model_predict()", this is the "hard" part of this exercise.
Reply
#4
@Larz60+

Thanks for your reply.
The model I am working with is called "m"
and I printed it to show how its defined.
Thats all I have.

There is no package defined but I read around
and have the idea that I should use plot the curve
and use the decision_function() to get the scores.

@Krookroo,
Thanks for your reply. I don't know.
All I know is that I have to compute the precision score.
Reply
#5
I'm afraid that you don't give enough information for me to give you any more help.
If your assignment doesn't say anything more, you surely have courses you can refer to.
Reply
#6
(Sep-19-2017, 06:51 AM)metalray Wrote: @Larz60+

Thanks for your reply.
The model I am working with is called "m"
and I printed it to show how its defined.
Thats all I have.

The code you shared references something called SVC. So, clearly, there is more that you haven't shared.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to update score value? Mavoz 5 2,451 Nov-08-2022, 12:37 AM
Last Post: Mavoz
  Errors with Machine Learning trading bot-- not sure why MattKahn13 2 1,556 Aug-08-2020, 06:43 PM
Last Post: MattKahn13
  How to correct the Python programming - Support Vector Machine vokoyo 7 4,416 Apr-06-2019, 10:11 AM
Last Post: scidam
  Machine Learning for Applications in Architecture JinLee 0 2,696 Sep-20-2017, 12:54 AM
Last Post: JinLee
  Machine Learning Antivirus [Urgent] Echoo0o 4 4,888 Jul-28-2017, 01:57 PM
Last Post: nilamo
  Average score MartinEvtimov 5 6,809 Apr-02-2017, 07:35 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020