Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know whether a model is new or not?

class Post < ActiveRecord::Base end  post = Post.new 

How do I judge whether the 'post' is a new model which is not pulled from the database?

like image 907
Croplio Avatar asked Jul 26 '10 08:07

Croplio


People also ask

How do you know if a model is valid?

Gathering evidence to determine model validity is largely accomplished by examining the model structure (i.e., the algorithms and relationships) to see how closely it corresponds to the actual system definition. For models having complex control logic, graphic animation can be used effectively as a validation tool.

Is 80% a good accuracy?

If your 'X' value is between 70% and 80%, you've got a good model. If your 'X' value is between 80% and 90%, you have an excellent model. If your 'X' value is between 90% and 100%, it's a probably an overfitting case.

What makes a model interpretable?

Models are interpretable when humans can readily understand the reasoning behind predictions and decisions made by the model. The more interpretable the models are, the easier it is for someone to comprehend and trust the model.

How do you test a new model for data?

run model. predict(X_new) where X_new is the new data (as you did with X_test, which essentially was "new" to your model/training) On a different note, I don't see 85% accuracy. The highest seems to be 79.87% and on the test set it seems to be 75.35%. I guess you are the one that has to show the code/data ;).


2 Answers

post.new_record? 
like image 93
Faisal Avatar answered Oct 12 '22 23:10

Faisal


ActiveRecord's new_record? method returns true if the object hasn't been saved yet.

  • new_record? documentation
like image 25
John Topley Avatar answered Oct 13 '22 01:10

John Topley