Python numpy and pandas for machine learning

General Tech Learning Aids/Tools 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Learning Aids/Tools related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

just as a disclaimer, this question is in regards to schoolwork. Literally though, my professor said to use this site for aid.

I am taking machine learning, and while our professor is a brilliant mathematician, he may be a little lacking on the programming side of things.

The name of the s://forum.tuteehub.com/tag/game">game here is to read code portions and find/fix the mistake.

I spend hours on this part, and I reckon my issue is having a dot product between a dataframe and numpy zeroes.

Issues occur like unsupported operand s://forum.tuteehub.com/tag/type">type(s) for +: 'float' and 'str'

I tried reading documentation and this site for a workaround, but I very novice in programming, especially a library like numpy and pandas

This is programming with python pandas

# Initialize the paarmeter set theta with zeros length as equal to column size in X
X = pd.DataFrame(X)
theta = np.zeros(X.shape[1], ds://forum.tuteehub.com/tag/type">type = int)
print(theta)


def cost_function(X, y, theta):
    """
    cost_function(X, y, theta) computes the cost of using theta as the
    parameter for linear regression to fit the data points in X and y
    """
    ## number of training examples
    m = len(y) 

    ## Calculate the cost with the given parameters
    J = 1/(2*m)*np.sum((X.dot(theta)-y)**2)

    return J

#Initial cost
cost_function(X,y,theta)

running the last line yields the most issues.

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

tuteehub community

Join Our Community Today

Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.

tuteehub community