15 const char *test_file =
"../../data/school_scores.csv";
16 freopen(test_file,
"r", stdin);
25 printf(
"LINEAR REGRESSION EXAMPLE ON YEAR/GPA DATA IN "
39 printf(
"Predicted value at %d = %f\n", v1, v1_v);
40 printf(
"Error value at %d = %f\n\n", v1, v1_e);
45 printf(
"Predicted value at %d = %f\n", v2, v2_v);
46 printf(
"Error value at %d = %f\n\n", v2, v2_e);
51 printf(
"Predicted value at %d = %f\n", v3, v3_v);
52 printf(
"Error value at %d = %f\n\n", v3, v3_e);
57 printf(
"Predicted value at %d = %f\n", v4, v4_v);
58 printf(
"Error value at %d = %f\n\n", v4, v4_e);
63 printf(
"Predicted value at %d = %f\n", v5, v5_v);
64 printf(
"Error value at %d = %f\n\n", v5, v5_e);
69 printf(
"Predicted value at %d = %f\n", v6, v6_v);
70 printf(
"Error value at %d = %f\n\n", v6, v6_e);
75 printf(
"Predicted value at %d = %f\n", v7, v7_v);
76 printf(
"Error value at %d = %f\n\n", v7, v7_e);
81 printf(
"Predicted value at %d = %f\n", v8, v8_v);
82 printf(
"Error value at %d = %f\n\n", v8, v8_e);
85 double v10_v = reg.
predict(v10);
87 printf(
"Predicted value at %d = %f\n", v10, v10_v);
88 printf(
"Error value at %d = %f\n\n", v10, v10_e);
91 double v11_v = reg.
predict(v11);
93 printf(
"Predicted value at %d = %f\n", v11, v11_v);
94 printf(
"Error value at %d = %f\n\n", v11, v11_e);
void best_fit()
Calculates and displays the best fitting line based on training data.
long double error_in(long double num)
Calculates the error (residual) for a given independent variable value.
long double predict(long double _x) const
Predict a value based on the input.
void get_input(const std::vector< long double > &x_data, const std::vector< long double > &y_data)
Sets the input data for the LinearRegression class from two vectors.