-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use line function to test linear regression #15
Comments
@crazylk could you please share the link to your Jupyter notebook where you're playing with linear regression? I just need to see what training parameters you're using. |
Sorry, I use Java and JavaScript. I don't know python so much and don't know how to use Jupyter, so there are simple python file for you. Maybe there are some mistake. Thank you! import numpy as np def create_data(in_count):
(x_train, y_train, x_test, y_test) = create_data(100) plt.scatter(x_train, y_train, label='Training Dataset') Set up linear regression parameters.num_iterations = 50000 # Number of gradient descent iterations. Init linear regression instance.linear_regression = LinearRegression(x_train, y_train, polynomial_degree, sinusoid_degree) Train linear regression.(theta, cost_history) = linear_regression.train( Print training results.print('Initial cost: {:.2f}'.format(cost_history[0])) Print model parameterstheta_table = pd.DataFrame({'Model Parameters': theta.flatten()}) Get model predictions for the trainint set.predictions_num = 1300 Plot training data with predictions.plt.scatter(x_train, y_train, label='Training Dataset') train_cost = linear_regression.get_cost(x_train, y_train, regularization_param) print('Train cost: {:.2f}'.format(train_cost)) test_predictions = linear_regression.predict(x_test) test_predictions_table = pd.DataFrame({ test_predictions_table.head(10) |
use y = 4 + 0.5*x to create test data
but there are no right result.
The text was updated successfully, but these errors were encountered: