Sha256: 1b3897019f2d22f96ea252edc7626a62a45302fe6728ae205f3bee94872023f3

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

require_relative "setup.rb"

class ValidationTest < MiniTest::Test

  def test_fminer_crossvalidation
    dataset = Dataset.from_csv_file "#{DATA_DIR}/hamster_carcinogenicity.csv"
    model = Model::LazarFminerClassification.create dataset#, features
    cv = ClassificationCrossValidation.create model
    p cv.accuracy
    p cv.weighted_accuracy
    assert cv.accuracy > 0.8
    assert cv.weighted_accuracy > cv.accuracy, "Weighted accuracy (#{cv.weighted_accuracy}) larger than unweighted accuracy(#{cv.accuracy}) "
  end

  def test_classification_crossvalidation
    dataset = Dataset.from_csv_file "#{DATA_DIR}/hamster_carcinogenicity.csv"
    model = Model::LazarClassification.create dataset#, features
    cv = ClassificationCrossValidation.create model
    p cv.accuracy
    p cv.weighted_accuracy
    assert cv.accuracy > 0.7
    assert cv.weighted_accuracy > cv.accuracy, "Weighted accuracy should be larger than unweighted accuracy."
  end

  def test_regression_crossvalidation
    dataset = Dataset.from_csv_file "#{DATA_DIR}/EPAFHM.medi.csv"
    #dataset = Dataset.from_csv_file "#{DATA_DIR}/EPAFHM.csv"
    model = Model::LazarRegression.create dataset
    cv = RegressionCrossValidation.create model
    p cv.rmse 
    p cv.weighted_rmse
    p cv.mae
    p cv.weighted_mae
    `inkview #{cv.plot}`
    assert cv.rmse < 30, "RMSE > 30"
    assert cv.weighted_rmse < cv.rmse, "Weighted RMSE (#{cv.weighted_rmse}) larger than unweighted RMSE(#{cv.rmse}) "
    assert cv.mae < 12
    assert cv.weighted_mae < cv.mae
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lazar-0.0.6 test/validation.rb
lazar-0.0.5 test/validation.rb
lazar-0.0.4 test/validation.rb
lazar-0.0.3 test/validation.rb
lazar-0.0.1 test/validation.rb