Solid state materials including semiconductors and metals deeply shaped our modern world, from smartphones and light-emitting diodes to electric cars. Besides the electrical transport properties, thermal transport properties also play significant roles in various applications, such as thermoelectrics and electronics thermal management, where thermal transport properties can affect both performance and reliability of the devices. In most semiconductors and insulators, it is the quasiparticle phonon that dominates the thermal transport, which is the quanta of vibrational modes in crystals. A fundamental study of phonon in semiconducting materials is thus of great importance in order to understand how heat is transported and how to better design new nanoscale devices and materials. Electron, on the other hand, contributes significantly to the thermal transport of metals in most cases, while it usually contributes little to thermal transport in semiconductors. It can, however, play a central role in thermoelectrics, where its transport is limited by the electron-phonon scattering. In this way, a comprehensive understanding of coupled electron and phonon properties are needed to fully understand thermal transport in metals and semiconductors.Nowadays, data-driven techniques have emerged as powerful tools for materials design when analytical principles are not established between material compositions and properties. It is thus of great interest and potential to apply the data-driven machine learning techniques to the area of thermal transport in solid state materials. With more data available on thermal transport properties, using machine learning techniques can help us understand and utilize the relations between thermal transport properties and materials structures without complex analytical expressions.In the first part of the thesis, considering the phonon-phonon scattering, lattice thermal conductivities of various two-dimensional (2D) semiconductors are studied by solving the phonon Boltzmann transport equation iteratively with the help of the parameter-free first-principles calculations. We found that a bond saturation rule can work as a general strategy for the design of high lattice thermal conductivity materials. Several ultrahigh thermal conductivity materials, such as the 2D penta-CN2, three-dimensional T12-carbon and AA T12-carbon are predicted.The electron-phonon scattering is then focused in the second part, where thermoelectric properties in semiconductors and the thermal and electrical transport properties of metals are studied in a first-principles calculation scheme. The 2D blue phosphorene is found to be with a low thermoelectric figure of merit, ZT, due to its high lattice thermal conductivity. However, with nanostructures which reduce lattice thermal conductivity, the ZT can be improved dramatically to around 1. In metallic hexagonal NbN, a promising and important superconductor, the first-principles calculation predicted thermal conductivity agrees well with experimental measurements.Finally, machine learning techniques, especially the transfer learning (TL), are applied to study the phonon properties of semiconductors. Considering the fact that electron properties are much easier to obtain. TL is used to leverage electron properties to help predict phonon properties. We found that TL can help improve the prediction accuracy significantly compared with direct training, indicating a deep connection between electron and phonon. Results also indicate that TL can leverage not-so-accurate proxy properties, as long as they encode composition-property relation, to improve models for target properties – a significant feature to materials informatics in general.In general, with the help of both the first-principles calculations and data-driven machine learning techniques, the thermal transport properties of semiconductors and metals are studied. These studies provide us a clearer understanding about how those quasi-particles can interact in solid state materials and they can potentially enable us to design materials and devices with desired thermal transport properties.