f0bs / machine_learning Goto Github PK
View Code? Open in Web Editor NEWeCornell Machine Learning Certificate Jupyter Notebooks
eCornell Machine Learning Certificate Jupyter Notebooks
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.