faridcher / ml-course

Starter code of Prof. Andrew Ng's machine learning MOOC in R statistical language
https://www.coursera.org/learn/machine-learning
172 stars 148 forks source link

Problem with submission #6

Closed SteveSizzou closed 6 years ago

SteveSizzou commented 6 years ago

Thank you so much for creating this repository. This is exactly what I need! I am very eager to get this up and running, however, in testing it out, when trying to submit the warm up exercise in exercise 1, I get the following error message:

!! Submission failed: unexpected error: object 'A' not found !! Please try again later.Error: object of type 'special' is not subsettable

This error occurs after entering my coursera email and the token.

Attached is the exact code which I run to produce the error, and below is some info regarding my R version and ubuntu system:

Any help on this issue would be great. Thanks again!

R.Version() $platform [1] "x86_64-pc-linux-gnu"

$arch [1] "x86_64"

$os [1] "linux-gnu"

$system [1] "x86_64, linux-gnu"

$status [1] ""

$major [1] "3"

$minor [1] "4.2"

$year [1] "2017"

$month [1] "09"

$day [1] "28"

$svn rev [1] "73368"

$language [1] "R"

$version.string [1] "R version 3.4.2 (2017-09-28)"

$nickname [1] "Short Summer"

submission problem warm up.txt

faridcher commented 6 years ago

how do you submit? have you compared your solution with the provided solution in the repo?

SteveSizzou commented 6 years ago

Thanks for the reply. Here is an example of the exact script I run in order to submit, using the warm up exercise. The only difference is that "mynamehere" should be replaced with my actual name. The solution of the warm up exercise is actually taken from the solutions folder, just to test out the submission process. Thanks! Here's the code:

library(rgl)
library(lbfgsb3)
library(SnowballC)
library(raster)
library(jsonlite)
library(httr)

submit <- function(){

  source("/home/mynamehere/Desktop/machine-learning-course-master/Starter/mlclass-ex1/lib/submitWithConfiguration.r")

  conf = list()
  conf$assignmentSlug = 'linear-regression'
  conf$itemName = 'Linear Regression with Multiple Variables'
  conf$partArrays = c(
    '1', 'warmUpExercise.r' , 'Warm-up Exercise', 
    '2', 'computeCost.r' , 'Computing Cost (for One Variable)', 
    '3', 'gradientDescent.r' , 'Gradient Descent (for One Variable)', 
    '4', 'featureNormalize.r' , 'Feature Normalization', 
    '5', 'computeCostMulti.r' , 'Computing Cost (for Multiple Variables)', 
    '6', 'gradientDescentMulti.r' , 'Gradient Descent (for Multiple Variables)', 
    '7', 'normalEqn.r' , 'Normal Equations')
  conf$partArrays = matrix(conf$partArrays,7,3 , byrow = T)
  conf$output = output

  submitWithConfiguration(conf)
}

output = function(partId){
  source('/home/mynamehere/Desktop/machine-learning-course-master/Starter/mlclass-ex1/warmUpExercise.R')
  source('/home/mynamehere/Desktop/machine-learning-course-master/Starter/mlclass-ex1/computeCost.R')
  source('/home/mynamehere/Desktop/machine-learning-course-master/Starter/mlclass-ex1/gradientDescent.R')
  source('/home/mynamehere/Desktop/machine-learning-course-master/Starter/mlclass-ex1/featureNormalize.R')
  source('/home/mynamehere/Desktop/machine-learning-course-master/Starter/mlclass-ex1/computeCostMulti.R')
  source('/home/mynamehere/Desktop/machine-learning-course-master/Starter/mlclass-ex1/gradientDescentMulti.R')
  source('/home/mynamehere/Desktop/machine-learning-course-master/Starter/mlclass-ex1/normalEqn.R')
  # Random Test Cases
  #X1 = [ones(20,1) (exp(1) + exp(2) * (0.1:0.1:2))']
  X1 = cbind(rep(1,20), exp(1) + exp(2) * seq(.1, 2, .1 ) )
  X1 = round(X1,4)
  #Y1 = X1(:,2) + sin(X1(:,1)) + cos(X1(:,2))
  Y1 = X1[,2] + sin(X1[,1]) + cos(X1[,2])

  #X2 = [X1 X1(:,2).^0.5 X1(:,2).^0.25]
  X2 = cbind(X1, X1[,2]^0.5, X1[,2]^0.25)
  Y2 = Y1^0.5 + Y1

  if (partId == '1')
    out = paste0(sprintf('%0.5f ', warmUpExercise()), collapse = '')
  else if (partId == '2')
    # different rounding
    out = sprintf('%0.5f ', computeCost(X1, Y1, c(0.5, -0.5)))
  else if (partId == '3')
    out = paste0(sprintf('%0.5f ', gradientDescent(X1, Y1, c(0.5, -0.5), 0.01, 10)$theta), collapse = '')
  else if (partId == '4')
    out = paste0(sprintf('%0.5f ', featureNormalize(X2[,2:4])$X_norm ), collapse = '')
  else if (partId == '5')
    #round
    out = sprintf('%0.5f ', computeCostMulti(X2, Y2, c(0.1,0.2,0.3,0.4)))
  else if (partId == '6')
    out = paste0(sprintf('%0.5f ', gradientDescentMulti(X2, Y2, -1 * c(0.1,0.2,0.3,0.4) , 0.01, 10)$theta)
                 , collapse = '')
  else if (partId == '7')
    out = paste0(sprintf('%0.5f ', normalEqn(X2, Y2)), collapse = '')
}

warmUpExercise  <- function() {
  #WARMUPEXERCISE Example function in R
  #   A <- WARMUPEXERCISE() is an example function that returns the 5x5 identity matrix

  # ------------- YOUR CODE HERE --------------
  # Instructions: Return the 5x5 identity matrix
  #               In R, the final computed variable 
  #               will be returned as output.

  A <- diag(5) 
  A

  # -------------------------------------------

}

submit()
faridcher commented 6 years ago

You shouldn't change the submit.r file and its functions. As stated on the repository main page:

After completing each assignment, source the submit.r and type submit() in the R console.

the script will ask for your user credentials.

SteveSizzou commented 6 years ago

Hmmm, Ok, so what does it mean to "source" the file? Can you provide an example? Thanks!

SteveSizzou commented 6 years ago

Looking up "source" I have tried the following, which also returns a different error. Is this what you were referring to?

warmUpExercise  <- function() {
  #WARMUPEXERCISE Example function in R
  #   A <- WARMUPEXERCISE() is an example function that returns the 5x5 identity matrix

  # ------------- YOUR CODE HERE --------------
  # Instructions: Return the 5x5 identity matrix
  #               In R, the final computed variable 
  #               will be returned as output.

  A <- diag(5) 
  A

  # -------------------------------------------

}

source("/home/myname/Desktop/machine-learning-course-master/Starter/mlclass-ex1/submit.R")

submit()

This gives the following error:

Error in file(filename, "r", encoding = encoding) : cannot open the connection In addition: Warning message: In file(filename, "r", encoding = encoding) :

Show Traceback

Rerun with Debug Error in file(filename, "r", encoding = encoding) : cannot open the connection

faridcher commented 6 years ago

double check the address of the file (submit.r). you can also use relative path from the rstudio project folder or your current working directory.

getwd()
SteveSizzou commented 6 years ago

Unfortunately any solution that I try doesn't work, here's a screenshot of what I get when I setwd() beforehand: submission problem

faridcher commented 6 years ago

Since the course is locked now and Idon't have a valid token, I can't regenerate your error. Have you tried other exercises? Just open the Rstudio (*.Rproj) of the corresponding exercise; source(submit.r) and call submit() function from the solution folder.

SteveSizzou commented 6 years ago

Hi, I wasn't able to return to this problem for a while. the problem persists, however, if I source the submit.r file from the solutions folder then it works, however then then seems to think that I have completed all of the exercises, even though I have only completed the warm up. Furthermore, your own personal email address seems to be given out when I attempt it. See screen shot:

image

How can I source the submit function without it erroneously believing that I have completed all the assignments when that is not the case?

SteveSizzou commented 6 years ago

All is working now as it should. My mistake with the last comment