  Measuring distances of cosmological sources such as galaxies, stars and
quasars plays an increasingly critical role in modern cosmology. Obtaining the
optical spectrum and consequently calculating the redshift as a distance
indicator could instantly classify these objects. As long as spectroscopic
observations are not available for many galaxies and the process of measuring
the redshift is time-consuming and infeasible for large samples, machine
learning (ML) approaches could be applied to determine the redshifts of
galaxies from different features including their photometric colors. In this
paper, by using the flux magnitudes from the Sloan Digital Sky Survey (SDSS)
catalog, we develop two ML regression algorithms (Decision Tree and Random
Forest) for estimating the redshifts taking color indices as input features. We
find that the Random Forest algorithm produces the optimum result for the
redshift prediction, and it will be further improved when the dataset is
limited to a subset with z $\le$ 2 giving the normalised standard deviation
$\overline{\Delta Z}_{\text {norm}}=0.005$ and the standard deviation
$\sigma_{\Delta z}=0.12$. This work shows a great potential of using the ML
approach to determine the photometric redshifts of distant sources.
