Git Product home page Git Product logo

machine_learning's People

Contributors

f0bs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

machine_learning's Issues

In Regression_tree.ipynb file, error is coming when running Part Three for the latest example on course.

In "Part Three: Implement cart [Graded]" when we are trying to run your code of cart(xTr,yTr) function in the latest eCornell course it gives error and failed out.
They have changed the init function.

class TreeNode(object):
    """
    Tree class.
    
    (You don't _need_ to add any methods or fields here but feel
    free to if you like. The tests will only reference the fields
    defined in the constructor below, so be sure to set these
    correctly.)
    """
    
    def __init__(self, left, right, feature, cut, prediction):
        # Check that all or no arguments are None
        node_or_leaf_args = [left, right, feature, cut]
        assert all([arg == None for arg in node_or_leaf_args]) or all([arg != None for arg in node_or_leaf_args])
        
        # Check that all None <==> leaf <==> prediction not None
        # Check that all non-None <==> non-leaf <==> prediction is None
        if all([arg == None for arg in node_or_leaf_args]):
            assert prediction is not None
        if all([arg != None for arg in node_or_leaf_args]):
            assert prediction is None
        
        self.left = left 
        self.right = right 
        self.feature = feature 
        self.cut = cut
        self.prediction = prediction 

When running your code for the given test cases it gives following error:

Running Test: cart_test1 ... ✖ Failed! Your code raises an exception. The following is the traceback of the failure:
  File "/home/codio/workspace/helper.py", line 29, in runtest
    if test():
   File "<ipython-input-77-a19ac5689e6b>", line 5, in cart_test1
    t=cart(xor4,yor4)
   File "<ipython-input-76-09d8e26c6cec>", line 34, in cart
    left_node = cart(left_xTr,left_yTr)
   File "<ipython-input-76-09d8e26c6cec>", line 34, in cart
    left_node = cart(left_xTr,left_yTr)
   File "<ipython-input-76-09d8e26c6cec>", line 34, in cart
    left_node = cart(left_xTr,left_yTr)
   File "<ipython-input-76-09d8e26c6cec>", line 36, in cart
    parent_node = TreeNode(left_node, right_node, feature, cut, prediction)
   File "<ipython-input-23-b2a152eb37ff>", line 21, in __init__
    assert prediction is None

Running Test: cart_test2 ... ✖ Failed! Your code raises an exception. The following is the traceback of the failure:
  File "/home/codio/workspace/helper.py", line 29, in runtest
    if test():
   File "<ipython-input-77-a19ac5689e6b>", line 11, in cart_test2
    t = cart(xor4,y);
   File "<ipython-input-76-09d8e26c6cec>", line 34, in cart
    left_node = cart(left_xTr,left_yTr)
   File "<ipython-input-76-09d8e26c6cec>", line 34, in cart
    left_node = cart(left_xTr,left_yTr)
   File "<ipython-input-76-09d8e26c6cec>", line 34, in cart
    left_node = cart(left_xTr,left_yTr)
   File "<ipython-input-76-09d8e26c6cec>", line 36, in cart
    parent_node = TreeNode(left_node, right_node, feature, cut, prediction)
   File "<ipython-input-23-b2a152eb37ff>", line 21, in __init__
    assert prediction is None

Running Test: cart_test3 ... ✖ Failed! Your code raises an exception. The following is the traceback of the failure:
  File "/home/codio/workspace/helper.py", line 29, in runtest
    if test():
   File "<ipython-input-77-a19ac5689e6b>", line 22, in cart_test3
    t = cart(xRep, yRep)
   File "<ipython-input-76-09d8e26c6cec>", line 34, in cart
    left_node = cart(left_xTr,left_yTr)
   File "<ipython-input-76-09d8e26c6cec>", line 36, in cart
    parent_node = TreeNode(left_node, right_node, feature, cut, prediction)
   File "<ipython-input-23-b2a152eb37ff>", line 21, in __init__
    assert prediction is None

Running Test: cart_test4 ... ✔ Passed!
Running Test: cart_test5 ... ✖ Failed! Your code raises an exception. The following is the traceback of the failure:
  File "/home/codio/workspace/helper.py", line 29, in runtest
    if test():
   File "<ipython-input-77-a19ac5689e6b>", line 49, in cart_test5
    t = cart(X, y) # your cart algorithm should generate one split
   File "<ipython-input-76-09d8e26c6cec>", line 36, in cart
    parent_node = TreeNode(left_node, right_node, feature, cut, prediction)
   File "<ipython-input-23-b2a152eb37ff>", line 21, in __init__
    assert prediction is None

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.