Recommend this page to a friend! |
Classes of Rafael Martin Soto | PHP Console Chart | README.md | Download |
|
DownloadCLI PHP Graph Bars for Machine Learning with Outliers alertCLI PHP for visualize Machine learning datasets in Graph bar format. Detect Outliers. See your data before Training V.1.0.3Before training processes at Deep Learning, the most hard work is to have a good datasets in its structure. Always we need to check the datasets before and if we see the data in graphs bars is more easy to detect outliers. This php class helps you to detect it with a shortest time. The class alert you about outliers with Red Bars. You can use it to display standard bar graphs too. The bar graphs are customizable in: - Colors - Background guidelines - Padding - Titles - Height - Show/Hide data information SCREENSHOTS:Screenshot of 3 float bar charts in CLI PHP environtment Screenshot of custom bar charts in CLI PHP environtment # REQUERIMENTS: - A minimum (minimum, minimum, minimum requeriments is needed). Tested on:
# FILES: There are 2 basic files: cli-graph-ml.class.php -> Master class. This file is the main file that you need to include in your code. example.php -> example file # DO YO WANT DISPLAY STANDARD BAR CHARTS? You can use the class to display bar charts with all features of colors, formats, ... as standard bar chart. To do it you simply need to hide the data explain the values. Outliers bars will not be drawed in red and will be a standard bar col too. See $bar_graph->set_explain_values( $boolean ); method. # NOTE ABOUT OUTLIER FACTOR: The class has a variable with the outlier_factor. There is no trivial solution for x, but usually, a value between 2 and 4 seems practical. See set_outlier_factor() Method # INSTALLATION: A lot of easy :smiley:. It is written in PURE PHP. Only need to include the files. Tested on basic PHP installation
DATA INFORMATION:The system will inform to you about: - Max Value - Min Value - Sum of all Values - Average of values - Median of values - Variance of values - Standard Derivation of values - Limit Outliers Upper - Limit Outliers Down - The outliers values will be drawed in RED column bar (See screenshots) # BASIC USAGE:
RESUME OF METHODS:
$bar_graph= new cli_graph_ml( $arr_val_example_1, $axis_x_values ); Example:
set_bar_width( $num_chars ) Example:
Outlier factor determines where a value is inside or outside a noramlly range values. There is no trivial solution for the value, but usually, a value between 2 and 4 seems practical. You can change the outlier factor value with set_outlier_factor( $float_factor ) Example:
One of this colors: lightblue, 'lightred', 'lightgreen', 'lightyellow, 'lightblack', 'lightmagenta', 'lightcyan', 'lightwhite', 'blue', 'red', 'green', 'yellow', 'black', 'magenta', 'cyan', 'white', 'orange' // if supported by the terminal, 'reset' set_bar_color( $str_color_name ) Example:
set_explain_values_same_line( $boolean ) Example:
By default, the underlines guides are drawed each line, but you can draw with a step set_underlines_every( $num_freq ); Example:
If you do not want to see the values under the graph, you can hide it. If you hide the values, outliers bars will not be drawed in red. $bar_graph->set_explain_values( $boolean ); Example:
If you need to teach a value 0 to be visible, you can create an array of column id's where to show the value even if it is 0 to be able to visualize it. In this case, if the field should be visible, half a gray box will be shown, indicating that the value is 0, but that there is set_arr_id_data_visible( $arr_id_data_visible ) Example:
By default, you will see 10 lines of chart. If you want more or less, you can configure it. set_graph_length( $in_lines ) Example:
You can send the result to the screen with this method draw( ) Example:
You can draw 1 line of the chart. Is used to concatenate more than 1 chart. See example.php. Then you can set some params more to do it. See example.php for more information and example: - $line_id; // Id of the line to be drawed. - $do_line_break = false; // Becouse the PHP_EOL will be done at last chart - $prepare_array_output = false; // becouse we prepare it previously Example:
When you create the class, it will be created with $data param, but you can change the data when you want. set_data( $arr_data ) Example:
You can give a Title for be showed as header up your graph. set_title( $str_title ) Example:
You can give a Title for be showed under Axis X. set_x_axis_title( $str_title ) Example:
You can give a Title for be showed under Axis Y. set_y_axis_title( $str_title ) Example:
You can to show or hide the Axis X Title set_show_x_axis_title( $boolean ) Example:
You can to show or hide the Axis Y Title set_show_y_axis_title( $boolean ) Example:
You can to show or hide the Axis X & Y Titles at the same time set_show_axis_titles( $boolean ) Example:
You can set a num of chars of padding each Top, Bottom, Left & Right set_padding( $num_chars_pad ); Example:
You can set a num of chars of left padding set_left_padding( $num_chars_pad ); Example:
You can set a num of chars of right padding set_right_padding( $num_chars_pad ); Example:
You can set a num of chars of top padding set_top_padding( $num_chars_pad ); Example:
You can set a num of chars of bottom padding set_bottom_padding( $num_chars_pad ); Example:
You can show or hide the underlines guides set_draw_underlines( $boolean ); Example:
You can set the values for show under the graph at Axis X set_axis_x_values( $arr_values ); Example:
You can change the bar graph when you want set_config( $arr_values ); Example:
prepare_array_output( ) Example:
With next methods you will need to know the numer of lines before de output. count_output_lines( ) Example:
V.1.0.3 Apply some minor changes to clean code. By https://github.com/bozhinov Of course. You can use it freely :vulcan_salute::alien: By Rafa. @author Rafael Martin Soto @author {@link http://www.inatica.com/ Inatica} @blog {@link https://rafamartin10.blogspot.com/ Rafael Martin's Blog} @since SEPTEMBER 2021 @version 1.0.3 @license GNU General Public License v3.0 |